account_analytic_account.py 1.0 KB

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. # For copyright and license notices, see __openerp__.py file in module root
  4. # directory
  5. ##############################################################################
  6. from openerp import models, fields, api
  7. from openerp.addons.decimal_precision import decimal_precision as dp
  8. class account_analytic_account(models.Model):
  9. _inherit = "account.analytic.account"
  10. recurring_total_amount = fields.Float(
  11. 'Monto',
  12. compute='_compute_recurring_total_amount',
  13. # we dont make storable so it is compatible with contract
  14. # discount
  15. # store=True,
  16. digits=dp.get_precision('Account'),
  17. )
  18. @api.one
  19. @api.depends(
  20. 'recurring_invoice_line_ids.quantity',
  21. 'recurring_invoice_line_ids.price_unit',
  22. )
  23. def _compute_recurring_total_amount(self):
  24. self.recurring_total_amount = sum(
  25. self.recurring_invoice_line_ids.mapped('price_subtotal'))