[FIX] sale,sale_management: prevent traceback on get_access_action
The field `sale_order_template_id` is only defined on `sale_management`, so
calling that method without `sale_management` would crash (traceback).
The method was in `sale_management` in the first place but commit
34c47eecd3 happened and some mistakes were made
that day.
PR: #30000
closes odoo/odoo#30294
This commit is contained in:
committed by
Jeremy Kersten
parent
9df7d244a0
commit
13b104bf9e
@@ -873,21 +873,6 @@ class SaleOrder(models.Model):
|
||||
self.ensure_one()
|
||||
return '%s %s' % (self.type_name, self.name)
|
||||
|
||||
@api.multi
|
||||
def get_access_action(self, access_uid=None):
|
||||
""" Instead of the classic form view, redirect to the online quote if it exists. """
|
||||
self.ensure_one()
|
||||
user = access_uid and self.env['res.users'].sudo().browse(access_uid) or self.env.user
|
||||
|
||||
if not self.sale_order_template_id or (not user.share and not self.env.context.get('force_website')):
|
||||
return super(SaleOrder, self).get_access_action(access_uid)
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': self.get_portal_url(),
|
||||
'target': 'self',
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
def _get_share_url(self, redirect=False, signup_partner=False, pid=None):
|
||||
self.ensure_one()
|
||||
if self.state not in ['sale', 'done']:
|
||||
|
||||
@@ -114,6 +114,21 @@ class SaleOrder(models.Model):
|
||||
self.sale_order_template_id.mail_template_id.send_mail(order.id)
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def get_access_action(self, access_uid=None):
|
||||
""" Instead of the classic form view, redirect to the online quote if it exists. """
|
||||
self.ensure_one()
|
||||
user = access_uid and self.env['res.users'].sudo().browse(access_uid) or self.env.user
|
||||
|
||||
if not self.sale_order_template_id or (not user.share and not self.env.context.get('force_website')):
|
||||
return super(SaleOrder, self).get_access_action(access_uid)
|
||||
return {
|
||||
'type': 'ir.actions.act_url',
|
||||
'url': self.get_portal_url(),
|
||||
'target': 'self',
|
||||
'res_id': self.id,
|
||||
}
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
Reference in New Issue
Block a user