Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 63d3c066cdfe75e07f4ee98202a925d99de772a8
  • 14.0 par défaut
  • 14.0-2507-inpi
  • 12.0 protégée
  • 13.0
  • 12.0-lm-00 protégée
6 résultats

res_partner.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()