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.

42 lines
1.9 KiB

5 years ago
5 years ago
5 years ago
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. @api.multi
  12. def action_invoice_create(self, grouped=False, final=False):
  13. print("----- TEST ------")
  14. return super(SaleOrder, self).action_invoice_create(
  15. grouped, final)
  16. class SaleOrderLine(models.Model):
  17. _inherit = "sale.order.line"
  18. @api.multi
  19. def invoice_line_create(self, invoice_id, qty):
  20. invoice_lines = self.env['account.invoice.line']
  21. for line in self:
  22. # Check if line has a pack_parent_line_id
  23. print("---- self.pack_parent_line_id.exists() -----", str(self.pack_parent_line_id.exists()))
  24. if self.pack_parent_line_id.exists():
  25. # Get the ref of parent pack
  26. sale_id_ref = self.env['sale.order.line'].search([('id', '=', self.pack_parent_line_id.id)])
  27. print("--- sale_id_ref ---", str(sale_id_ref))
  28. print("--- sale_id_ref.product_id.product_tmpl_id.pack_type ---", str(sale_id_ref.product_id.product_tmpl_id.pack_type))
  29. print("--- sale_id_ref.product_id.product_tmpl_id.pack_component_price ---", str(sale_id_ref.product_id.product_tmpl_id.pack_component_price))
  30. # Check if product is Pack detailed and option Totalized
  31. 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':
  32. return invoice_lines
  33. invoice_lines = super(SaleOrderLine, self).invoice_line_create(
  34. invoice_id, qty)
  35. return invoice_lines