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.

32 lines
1.3 KiB

5 years ago
  1. # © 2019 Le Filament (<http://www.le-filament.com>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import models, fields, api
  4. class SaleOrder(models.Model):
  5. _inherit = "sale.order"
  6. @api.one
  7. def _compute_website_order_line(self):
  8. self.website_order_line = self.order_line.filtered(
  9. lambda t: not t.pack_parent_line_id.exists(),
  10. )
  11. class SaleOrderLine(models.Model):
  12. _inherit = "sale.order.line"
  13. @api.multi
  14. def invoice_line_create(self, invoice_id, qty):
  15. invoice_lines = self.env['account.invoice.line']
  16. for line in self:
  17. # Check if line has a pack_parent_line_id
  18. if self.pack_parent_line_id.exists():
  19. # Get the ref of parent pack
  20. sale_id_ref = self.env['sale.order.line'].search([('id', '=', self.pack_parent_line_id.id)])
  21. # Check if product is Pack detailed and option Totalized
  22. 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':
  23. return invoice_lines
  24. invoice_lines = super(SaleOrderLine, self).invoice_line_create(
  25. invoice_id, qty)
  26. return invoice_lines