[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) <dbo@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv)
2019-09-25 15:58:17 +00:00
parent 48b76921be
commit f976a10803
3 changed files with 7 additions and 1 deletions
+1
View File
@@ -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
+5
View File
@@ -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'
+1 -1
View File
@@ -117,7 +117,7 @@
<xpath expr="//div[hasclass('o_portal_sidebar')]" position="inside">
<t t-set="o_portal_fullwidth_alert" groups="sales_team.group_sale_salesman">
<t t-call="portal.portal_back_in_edit_mode">
<t t-set="backend_url" t-value="'/web#return_label=Website&amp;model=%s&amp;id=%s&amp;action=%s&amp;view_type=form' % (sale_order._name, sale_order.id, sale_order.env.ref('sale.action_quotations_with_onboarding').id)"/>
<t t-set="backend_url" t-value="'/web#return_label=Website&amp;model=%s&amp;id=%s&amp;action=%s&amp;view_type=form' % (sale_order._name, sale_order.id, action.id)"/>
</t>
</t>