You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
767 B

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Angel Moya <angel.moya@domatix.com>
  3. # © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from openerp import api, fields, models
  6. class AccountInvoice(models.Model):
  7. _inherit = 'account.invoice'
  8. analytic_account_ids = fields.Many2many(
  9. comodel_name='account.analytic.account',
  10. compute='_compute_analytic_account_ids',
  11. store=True,
  12. string='Contracts')
  13. @api.multi
  14. @api.depends('invoice_line_ids.account_analytic_id')
  15. def _compute_analytic_account_ids(self):
  16. for invoice in self:
  17. invoice.analytic_account_ids = invoice.mapped(
  18. 'invoice_line_ids.account_analytic_id'
  19. )