From 59fefc0a029ca75a45d92a29cfbffbe7da720503 Mon Sep 17 00:00:00 2001 From: charliedao Date: Wed, 20 Mar 2024 13:52:22 +0000 Subject: [PATCH] [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/odoo#158026 Signed-off-by: Valentin Chevalier --- addons/website_sale/models/website.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/website_sale/models/website.py b/addons/website_sale/models/website.py index 30058ab121d..dd250bad9f1 100644 --- a/addons/website_sale/models/website.py +++ b/addons/website_sale/models/website.py @@ -564,14 +564,9 @@ class Website(models.Model): return self.is_view_active('website_sale.address_b2b') - def _get_checkout_steps(self, current_step=None): + def _get_checkout_step_list(self): """ Return an ordered list of steps according to the current template rendered. - If `current_step` is provided, returns only the corresponding step. - - Note: self.ensure_one() - - :param str current_step: The xmlid of the current step, defaults to None. :rtype: list :return: A list with the following structure: [ @@ -620,6 +615,19 @@ class Website(models.Model): 'back_button': _lt("Back to cart"), 'back_button_href': '/shop/cart', })) + return steps + + def _get_checkout_steps(self, current_step=None): + """ Return an ordered list of steps according to the current template rendered. + If `current_step` is provided, returns only the corresponding step. + Note: self.ensure_one() + :param str current_step: The xmlid of the current step, defaults to None. + :rtype: list + :return: A list containing the steps generated by :meth:`_get_checkout_step_list`. + """ + self.ensure_one() + + steps = self._get_checkout_step_list() if current_step: return next(step for step in steps if current_step in step[0])[1]