更新保存发票上的税金额

时间:2017-12-12 14:56:33

标签: openerp odoo-8 odoo-10

如果在添加新的发票行以及含增值税的产品后保存发票,则增值税总额不会自动更新。

有没有办法在保存发票时自动计算税额?

为什么它不是原生行为?

非常感谢任何帮助

干杯

1 个答案:

答案 0 :(得分:0)

amount_untaxed = fields.Monetary(string='Untaxed Amount',
    store=True, readonly=True, compute='_compute_amount', track_visibility='always')
amount_tax = fields.Monetary(string='Tax',
    store=True, readonly=True, compute='_compute_amount')
amount_total = fields.Monetary(string='Total',
    store=True, readonly=True, compute='_compute_amount')

@api.one
@api.depends('invoice_line_ids.price_subtotal', 'tax_line_ids.amount', 'currency_id', 'company_id', 'date_invoice', 'type')
def _compute_amount(self):
    round_curr = self.currency_id.round
    self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line_ids)
    self.amount_tax = sum(round_curr(line.amount) for line in self.tax_line_ids)
    self.amount_total = self.amount_untaxed + self.amount_tax

你可以看到account.invoice默认模块。始终在创建时更新记录。在自定义模块中,在create方法中更新上述记录。