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.

31 lines
980 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 Tecnativa - Pedro M. Baeza
  3. # Copyright 2017 Tecnativa - Vicent Cubells
  4. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  5. from odoo import api, fields, models
  6. class AccountAnalyticAccount(models.Model):
  7. _inherit = "account.analytic.account"
  8. @api.model
  9. def _prepare_invoice_line(self, line, invoice_id):
  10. res = super(AccountAnalyticAccount, self)._prepare_invoice_line(
  11. line, invoice_id)
  12. if line.analytic_distribution_id:
  13. res.update({
  14. 'account_analytic_id': False,
  15. 'analytic_distribution_id': line.analytic_distribution_id.id,
  16. })
  17. return res
  18. class AccountAnalyticInvoiceLine(models.Model):
  19. _inherit = "account.analytic.invoice.line"
  20. analytic_distribution_id = fields.Many2one(
  21. comodel_name='account.analytic.distribution',
  22. string='Analytic Distribution',
  23. oldname='analytics_id',
  24. )