# © 2019 Le Filament () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, fields, api class SaleOrder(models.Model): _inherit = "sale.order" @api.one def _compute_website_order_line(self): self.website_order_line = self.order_line.filtered( lambda t: not t.pack_parent_line_id.exists(), ) class SaleOrderLine(models.Model): _inherit = "sale.order.line" @api.multi def invoice_line_create(self, invoice_id, qty): invoice_lines = self.env['account.invoice.line'] for line in self: # Check if line has a pack_parent_line_id if self.pack_parent_line_id.exists(): # Get the ref of parent pack sale_id_ref = self.env['sale.order.line'].search([('id', '=', self.pack_parent_line_id.id)]) # Check if product is Pack detailed and option Totalized if sale_id_ref.product_id.product_tmpl_id.pack_type == 'detailed' and sale_id_ref.product_id.product_tmpl_id.pack_component_price == 'totalized': return invoice_lines invoice_lines = super(SaleOrderLine, self).invoice_line_create( invoice_id, qty) return invoice_lines