I want to add check on field 'Email' in res.partner when confirming sale order.
class SaleOrderExtend(models.Model):
_inherit = 'sale.order'
def action_confirm(self):
partner = self.env['res.partner'].search(['partner_id', '=', self.partner_id])
if partner.email == '':
raise UserError(_("""Email is empty ."""))
....
but I got this error : The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
IndexError: tuple index out of range
What's wrong please? Thanks.