Skip to Content
Menu
This question has been flagged
2 Replies
2608 Views

I try to create filed related with account.invoice.mount_total, and when I do that I get error
My example:

class PlayInvoice(models.Model):
  _name = 'play.invoice'
  
  invoice_id = fields.Many2one('account.invoice', 'Invoice') 
  amount_total_invoice = fields.Monetary(string='Total', related='invoice_id.amount_total')

Error:

Traceback (most recent call last):
    return self._fields[key].__get__(self, type(self))
KeyError: 'currency_id'

Avatar
Discard

Try searching for monetary fields in this forum

Best Answer

Hi,

Add currency field in your model

 currency_id = fields.Many2one('res.currency', string='Currency', readonly=True},default=invoice_id.currency_id)

currency id set default from invoice.

Thanks

Aswini iWesabe

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
942
1
Jun 24
3564
1
Oct 23
8590
1
Oct 23
97
1
Aug 23
2192