Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1068 Widoki

I want the boolean field to be true automatic when there is a taxs on any product under the invoice lines


class Accountmove(models.Model):

    _inherit = 'account.move'
    taxs = fields.Boolean(string="Is Tax view", help="Tax view", store=True)

    @api.onchange('invoice_line_ids', 'tax_ids') 

   def _onchange_invoice_line_ids(self):  

      for line in self:       

     if not line.tax_ids:     

           self.taxs = False    

        else:    

           self.taxs = True

 

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

We want to compute taxes in invoices by iterating through the invoice lines and setting a boolean field (taxs) in the corresponding move. 

class Accountmove(models.Model):

    _inherit = 'account.move'

    taxs = fields.Boolean(string="Is Tax view", help="Tax view", store=True, compute='_compute_taxs')

    @api.depends('invoice_line_ids.tax_ids')

    def _compute_taxs(self):

        for invoice in self:

            if any(line.tax_ids for line in invoice.invoice_line_ids):

                invoice.move_id.taxs = True

For more details, refer to the blog:

https://www.cybrosys.com/blog/difference-between-compute-and-onchange-fields-odoo


Hope it helps

Awatar
Odrzuć