12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- from openerp import models, fields, api
- from openerp.tools.translate import _
- class AccountInvoice(models.Model):
- _name = "account.invoice"
- _inherit = "account.invoice"
- amount_untaxed = fields.Float(compute='_compute_amount_all')
- amount_tax = fields.Float(compute='_compute_amount_all')
- amount_total = fields.Float(compute='_compute_amount_all')
- @api.depends('invoice_line.price_subtotal')
- def _compute_amount_all(self):
- for order in self:
- amount_tax = amount_untaxed = 0.0
- currency = order.currency_id.with_context(date=order.date_invoice or fields.Date.context_today(order))
- for line in order.invoice_line:
- amount_untaxed += line.price_subtotal
- amount_tax += (line.quantity * line.price_unit) - line.price_subtotal
- order.amount_tax = currency.round(amount_tax)
- order.amount_untaxed = currency.round(amount_untaxed)
- order.amount_total = currency.round(amount_tax + amount_untaxed)
|