Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 59feb04dac6cb09f7c3b488d9e4c6b00ad7c4605
  • 14.0 par défaut protégée
2 résultats

__init__.py

Blame
  • sale_order.py 1,14 Kio
    # Copyright 2021 Le Filament (https://le-filament.com)
    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
    
    from odoo import models
    
    
    class SaleOrder(models.Model):
        _inherit = "sale.order"
    
        # ------------------------------------------------------
        # Business method
        # ------------------------------------------------------
        def clean_sale_order(self):
            super(SaleOrder, self).clean_sale_order()
            sol_line_section = self.order_line.filtered(
                lambda s: s.display_type == 'line_section' and s.sale_project_id is not None
            )
            for sol_section in sol_line_section:
                next_sol = False
                for sol in self.order_line.sorted(key=lambda r: (r.sequence, r.id)):
                    if sol.sequence > sol_section.sequence \
                        or (sol.sequence == sol_section.sequence
                            and sol.id > sol_section.id):
                        next_sol = sol
                        break
                if not next_sol or\
                    next_sol.sale_project_id != sol_section.sale_project_id \
                        or not next_sol.product_id:
                    sol_section.unlink()