fix billed amount
This commit is contained in:
parent
cb420ff081
commit
8daa1b6f6a
|
|
@ -8,6 +8,23 @@ from dateutil.relativedelta import relativedelta
|
|||
class PurchaseOrderCustom(models.Model):
|
||||
_inherit = "purchase.order"
|
||||
|
||||
billed_amount = fields.Float(store=True, compute='_compute_amount')
|
||||
remaining_amount = fields.Float(store=True, compute='_compute_amount')
|
||||
|
||||
@api.depends('invoice_ids','invoice_count')
|
||||
def _compute_amount(self):
|
||||
for order in self:
|
||||
billed_amount = 0.0
|
||||
for invoice in order.invoice_ids:
|
||||
billed_amount += invoice.amount_total
|
||||
|
||||
currency = order.currency_id or order.partner_id.property_purchase_currency_id or \
|
||||
self.env.company.currency_id
|
||||
order.update({
|
||||
'billed_amount': currency.round(billed_amount),
|
||||
'remaining_amount': order.amount_total - billed_amount,
|
||||
})
|
||||
|
||||
def copy(self, default=None):
|
||||
data = super(PurchaseOrderCustom, self).copy(default)
|
||||
data.email_to_vendor = False
|
||||
|
|
|
|||
Loading…
Reference in New Issue