Reputation: 503
I have created a custom module in Odoo. I want to display a read only field in customer view(res.partner form view) where the last invoice id must be updated as soon as a new invoice of that customer is created and validated.
Which method should I refer in account.invoice
?
Upvotes: 1
Views: 108
Reputation: 11143
In your case, you should override ORM create() method of account.invoice object.
Try with this code.
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
@api.model
def create(self, vals):
#call super method
invoice = super(AccountInvoice,self).create(vals)
#update partner field with lastest created invoice
invoice.partner_id.your_field_name = invoice.number
return invoice
For more Odoo technical reference
Upvotes: 1