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.

25 lines
701 B

  1. # Copyright 2017 LasLabs Inc.
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class AccountAnalyticInvoiceLine(models.Model):
  5. _inherit = 'account.analytic.invoice.line'
  6. sale_order_line_id = fields.Many2one(
  7. comodel_name="sale.order.line",
  8. string="Sale Order Line",
  9. required=False,
  10. copy=False,
  11. )
  12. @api.multi
  13. def _prepare_invoice_line(self, invoice_id):
  14. res = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line(
  15. invoice_id
  16. )
  17. if self.sale_order_line_id:
  18. res['sale_line_ids'] = [(6, 0, [self.sale_order_line_id.id])]
  19. return res