From f976a1080300f724cfe2bc365d677901e2c20726 Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Mon, 23 Sep 2019 09:40:15 +0000 Subject: [PATCH] [FIX] sale: fix returning to sale from rental portal This commit changes the behavior of the 'Back to edit mode' button in the customer portal preview of sales order. If the sales order is a rental order, the user is sent back to the Rental app. If not, the button makes him return to the Sale app. This doesn't take into account the app in which the order was opened: if a rental order was opened in the Sale app, the portal will send the user back to the Rental app. task-2071281 closes odoo/odoo#37423 Signed-off-by: Damien Bouvy (dbo) --- addons/sale/controllers/portal.py | 1 + addons/sale/models/sale.py | 5 +++++ addons/sale/views/sale_portal_templates.xml | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py index 7d0ee178db2..af7078619e6 100644 --- a/addons/sale/controllers/portal.py +++ b/addons/sale/controllers/portal.py @@ -169,6 +169,7 @@ class CustomerPortal(CustomerPortal): 'bootstrap_formatting': True, 'partner_id': order_sudo.partner_id.id, 'report_type': 'html', + 'action': order_sudo._get_portal_return_action(), } if order_sudo.company_id: values['res_company'] = order_sudo.company_id diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index f081041715e..4dfd96f2387 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -904,6 +904,11 @@ class SaleOrder(models.Model): self.ensure_one() return 'form_save' if self.require_payment else 'form' + def _get_portal_return_action(self): + """ Return the action used to display orders when returning from customer portal. """ + self.ensure_one() + return self.env.ref('sale.action_quotations_with_onboarding') + class SaleOrderLine(models.Model): _name = 'sale.order.line' diff --git a/addons/sale/views/sale_portal_templates.xml b/addons/sale/views/sale_portal_templates.xml index 2244a36b72f..c7f934ea695 100644 --- a/addons/sale/views/sale_portal_templates.xml +++ b/addons/sale/views/sale_portal_templates.xml @@ -117,7 +117,7 @@ - +