diff --git a/product_contract/models/__init__.py b/product_contract/models/__init__.py index 388717d2..a275fa21 100644 --- a/product_contract/models/__init__.py +++ b/product_contract/models/__init__.py @@ -2,6 +2,7 @@ # Copyright 2017 LasLabs Inc. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import contract_line from . import product_template from . import sale_order from . import sale_order_line diff --git a/product_contract/models/contract_line.py b/product_contract/models/contract_line.py new file mode 100644 index 00000000..998da169 --- /dev/null +++ b/product_contract/models/contract_line.py @@ -0,0 +1,16 @@ +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import api, fields, models, _ + + +class AccountAnalyticInvoiceLine(models.Model): + _inherit = 'account.analytic.invoice.line' + + sale_order_line_id = fields.Many2one( + comodel_name="sale.order.line", + string="Sale Order Line", + required=False, + copy=False, + ) diff --git a/product_contract/models/sale_order.py b/product_contract/models/sale_order.py index 4b356f32..a2e8487d 100644 --- a/product_contract/models/sale_order.py +++ b/product_contract/models/sale_order.py @@ -64,7 +64,10 @@ class SaleOrder(models.Model): action = self.env.ref( "contract.action_account_analytic_sale_overdue_all" ).read()[0] + contracts = self.env['account.analytic.invoice.line'].search([ + ('sale_order_line', 'in', self.order_line.ids) + ]).mapped('contract_id') action["domain"] = [ - ("id", "in", self.order_line.mapped('contract_id').ids) + ("id", "in", contracts.ids) ] return action diff --git a/product_contract/models/sale_order_line.py b/product_contract/models/sale_order_line.py index b275e67e..1c13fdad 100644 --- a/product_contract/models/sale_order_line.py +++ b/product_contract/models/sale_order_line.py @@ -82,6 +82,7 @@ class SaleOrderLine(models.Model): 'recurring_invoicing_type': self.recurring_invoicing_type, 'recurring_rule_type': self.recurring_rule_type, 'contract_id': contract.id, + 'sale_order_line_id': self.id, } @api.multi