Skip to content
Extraits de code Groupes Projets
Valider 8fd7c203 rédigé par jordan's avatar jordan
Parcourir les fichiers

[update] refactor code to put update_order_lines in project + add clean_sale_order function

parent 48e3fc87
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright 2021 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import sale_intervention
from . import sale_project
......@@ -4,10 +4,10 @@
from odoo import models
class SaleIntervention(models.Model):
_inherit = "sale.intervention"
class SaleProject(models.Model):
_inherit = "sale.project"
def _update_order_lines(self):
def update_order_lines(self):
"""
Rewrite function to use Taxes
"""
......@@ -21,8 +21,8 @@ class SaleIntervention(models.Model):
vat_furniture_categ = (
self.env["product.category"].browse(furniture_categ_id.id).taxes_id
)
lines = self.read_group(
(("project_id", "=", self.project_id.id),),
lines = self.env['sale.intervention'].read_group(
(("project_id", "=", self.id),),
("price", "intervention_length", "plant_qty"),
"intervention_type_id",
lazy=False,
......@@ -51,7 +51,7 @@ class SaleIntervention(models.Model):
plant_price = plant_pricelist_item.fixed_price
existing_lines = self.sale_order_id.order_line.filtered(
lambda r: r.product_id.id == product_tmpl.product_variant_id.id
and r.sale_project_id.id == self.project_id.id
and r.sale_project_id.id == self.id
)
if existing_lines:
sol_plant = existing_lines.filtered(
......@@ -87,10 +87,10 @@ class SaleIntervention(models.Model):
"order_id": self.sale_order_id.id,
"product_id": product_tmpl.product_variant_id.id,
"product_uom_qty": quantity,
"sale_project_id": self.project_id.id,
"sale_project_id": self.id,
}
sol_name = (
"Projet " + self.project_id.name + " - " + product_tmpl.name
"Projet " + self.name + " - " + product_tmpl.name
)
sols.append(
{
......@@ -124,6 +124,6 @@ class SaleIntervention(models.Model):
)
for sol in sols:
self.env["sale.order.line"].create(sol)
else:
super(SaleIntervention, self)._update_order_lines()
super(SaleProject, self).update_order_lines()
self.sale_order_id.clean_sale_order()
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter