fix billed amount

This commit is contained in:
ronozoro 2024-11-14 01:22:18 -08:00
parent cb420ff081
commit 8daa1b6f6a
No known key found for this signature in database
GPG Key ID: 7C2BDED35C62C0F3
1 changed files with 17 additions and 0 deletions

View File

@ -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