Skip to content

Commit 42b396b

Browse files
committed
[FW][IMP] website_sale: add hook to _get_checkout_steps for easier override
`_get_checkout_steps` didn't provide a friendly way to add steps in the checkout flow. Developers had to reimplement part of the parent logic in their overrides. This commit introduces `get_checkout_step_list`. This method will allow an easier override of the checkout steps while keeping the logic to return a single step in the parent method. closes odoo#158429 Forward-port-of: odoo#158026 Signed-off-by: Valentin Chevalier <vcr@odoo.com>
1 parent 033352e commit 42b396b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

addons/website_sale/models/website.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,9 @@ def _display_partner_b2b_fields(self):
550550

551551
return self.is_view_active('website_sale.address_b2b')
552552

553-
def _get_checkout_steps(self, current_step=None):
553+
def _get_checkout_step_list(self):
554554
""" Return an ordered list of steps according to the current template rendered.
555555
556-
If `current_step` is provided, returns only the corresponding step.
557-
558-
Note: self.ensure_one()
559-
560-
:param str current_step: The xmlid of the current step, defaults to None.
561556
:rtype: list
562557
:return: A list with the following structure:
563558
[
@@ -606,6 +601,19 @@ def _get_checkout_steps(self, current_step=None):
606601
'back_button': _lt("Back to cart"),
607602
'back_button_href': '/shop/cart',
608603
}))
604+
return steps
605+
606+
def _get_checkout_steps(self, current_step=None):
607+
""" Return an ordered list of steps according to the current template rendered.
608+
If `current_step` is provided, returns only the corresponding step.
609+
Note: self.ensure_one()
610+
:param str current_step: The xmlid of the current step, defaults to None.
611+
:rtype: list
612+
:return: A list containing the steps generated by :meth:`_get_checkout_step_list`.
613+
"""
614+
self.ensure_one()
615+
616+
steps = self._get_checkout_step_list()
609617

610618
if current_step:
611619
return next(step for step in steps if current_step in step[0])[1]

0 commit comments

Comments
 (0)