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

[fix] error with read_group

parent 96789756
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -11,7 +11,6 @@ class SaleIntervention(models.Model):
"""
Rewrite function to use Taxes
"""
product_tmpl = self.intervention_type_id
plant_categ_id = self.env.ref("ap_sale_project.product_category_plant")
vat_plant_categ = (
self.env["product.category"].browse(plant_categ_id.id).taxes_id
......@@ -22,28 +21,30 @@ 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),),
("price", "intervention_length", "plant_qty"),
"intervention_type_id",
lazy=False,
)
for line in lines:
product_tmpl_id = line["intervention_type_id"][0]
product_tmpl = self.env["product.template"].browse(product_tmpl_id)
pricelist = self.project_subvention_id.product_pricelist_ids.filtered(
lambda i: i.intervention_type_id.id == product_tmpl.id
lambda i: i.intervention_type_id.id == product_tmpl_id
)
if (
pricelist
and pricelist.item_ids.filtered(lambda i: i.categ_id == plant_categ_id)
and self.env.user.company_id.vat
):
interventions = self.project_id.intervention_ids.filtered(
lambda i: i.intervention_type_id == self.intervention_type_id
)
quantity = 0
price = 0
for inter in interventions:
quantity += (
inter.intervention_length
quantity = (
line["intervention_length"]
if product_tmpl.uom_name == "m"
else inter.plant_qty
else line["plant_qty"]
)
price += inter.price
if quantity != 0:
price_unit = price / quantity
price_unit = line["price"] / quantity
plant_pricelist_item = pricelist.item_ids.filtered(
lambda i: i.categ_id == plant_categ_id
)
......
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