Skip to content
Extraits de code Groupes Projets
Valider e38d3b40 rédigé par Julien - Le Filament's avatar Julien - Le Filament
Parcourir les fichiers

[ADD] configure product accessory

parent 3b5811d3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!214.0 double paillage,!114.0 accessory
...@@ -11,3 +11,4 @@ from . import sale_intervention ...@@ -11,3 +11,4 @@ from . import sale_intervention
from . import sale_intervention_stock from . import sale_intervention_stock
from . import res_partner from . import res_partner
from . import product_category from . import product_category
from . import product_template
...@@ -11,6 +11,7 @@ class ProductCategory(models.Model): ...@@ -11,6 +11,7 @@ class ProductCategory(models.Model):
# Fields declaration # Fields declaration
# ------------------------------------------------------ # ------------------------------------------------------
symbol = fields.Char("Symbole") symbol = fields.Char("Symbole")
accessory_label = fields.Char("Nom de l'accessoire associé")
# ------------------------------------------------------ # ------------------------------------------------------
# SQL Constraints # SQL Constraints
......
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import itertools
import logging
from collections import defaultdict
from odoo import api, fields, models, tools, _, SUPERUSER_ID
from odoo.exceptions import ValidationError, RedirectWarning, UserError
from odoo.osv import expression
_logger = logging.getLogger(__name__)
class ProductTemplate(models.Model):
_inherit = "product.template"
# ------------------------------------------------------
# Fields declaration
# ------------------------------------------------------
nb_accesories = fields.Float(string="Nombre d'accessoires")
# ------------------------------------------------------
# SQL Constraints
# ------------------------------------------------------
# ------------------------------------------------------
# Default methods
# ------------------------------------------------------
# ------------------------------------------------------
# Computed fields / Search Fields
# ------------------------------------------------------
# ------------------------------------------------------
# Onchange / Constraints
# ------------------------------------------------------
# ------------------------------------------------------
# CRUD methods (ORM overrides)
# ------------------------------------------------------
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
def get_accessory_label(self):
return self.env["product.category"].browse(self.gateg_id).accessory_label
# ------------------------------------------------------
# Business methods
# ------------------------------------------------------
...@@ -537,7 +537,12 @@ class SaleIntervention(models.Model): ...@@ -537,7 +537,12 @@ class SaleIntervention(models.Model):
@api.onchange("high_protection_qty") @api.onchange("high_protection_qty")
def _onchange_high_protection_qty(self): def _onchange_high_protection_qty(self):
self.stake_qty = self.high_protection_qty if self.high_protection_id.nb_accesories:
stake_multiplier = self.high_protection_id.nb_accesories
else:
stake_multiplier = 1
self.stake_qty = stake_multiplier * self.high_protection_qty
@api.onchange("low_protection_qty") @api.onchange("low_protection_qty")
def _onchange_low_protection_qty(self): def _onchange_low_protection_qty(self):
...@@ -705,7 +710,11 @@ class SaleIntervention(models.Model): ...@@ -705,7 +710,11 @@ class SaleIntervention(models.Model):
# Staples # Staples
if rec.mulch_has_staples or rec.mulch2_has_staples: if rec.mulch_has_staples or rec.mulch2_has_staples:
products.append(staples_product_id) products.append(staples_product_id)
quantities.append(rec.mulch_qty * 2 or 0) if rec.mulch_id.nb_accesories:
staples_multipier = rec.mulch_id.nb_accesories
else:
staples_multipier = 2
quantities.append(rec.mulch_qty * staples_multipier or 0)
partners.append(partner) partners.append(partner)
# High Protections # High Protections
...@@ -860,15 +869,20 @@ class SaleIntervention(models.Model): ...@@ -860,15 +869,20 @@ class SaleIntervention(models.Model):
} }
) )
if self.mulch_has_staples: if self.mulch_has_staples:
if self.mulch_id.nb_accesories:
staples_multipier = self.mulch_id.nb_accesories
else:
staples_multipier = 2
data.append( data.append(
{ {
"sale_intervention_id": self.id, "sale_intervention_id": self.id,
"product_id": staples_product_id.product_variant_id.id, "product_id": staples_product_id.product_variant_id.id,
"product_uom_qty": self.mulch_qty * 2, "product_uom_qty": self.mulch_qty * staples_multipier,
"price_unit": self.staple1_price, "price_unit": self.staple1_price,
} }
) )
if self.mulch2_id and self.mulch2_qty > 0: if self.mulch2_id and self.mulch2_qty > 0:
data.append( data.append(
{ {
"sale_intervention_id": self.id, "sale_intervention_id": self.id,
...@@ -878,11 +892,15 @@ class SaleIntervention(models.Model): ...@@ -878,11 +892,15 @@ class SaleIntervention(models.Model):
} }
) )
if self.mulch2_has_staples: if self.mulch2_has_staples:
if self.mulch2_id.nb_accesories:
staples_2_multipier = self.mulch2_id.nb_accesories
else:
staples_2_multipier = 2
data.append( data.append(
{ {
"sale_intervention_id": self.id, "sale_intervention_id": self.id,
"product_id": staples_product_id.product_variant_id.id, "product_id": staples_product_id.product_variant_id.id,
"product_uom_qty": self.mulch2_qty * 2, "product_uom_qty": self.mulch2_qty * staples_2_multipier,
"price_unit": self.staple2_price, "price_unit": self.staple2_price,
} }
) )
......
...@@ -9,6 +9,18 @@ ...@@ -9,6 +9,18 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="parent_id" position="after"> <field name="parent_id" position="after">
<field name="symbol" /> <field name="symbol" />
<field name="accessory_label" />
</field>
</field>
</record>
<record id="product_template_only_form_view_ap" model="ir.ui.view">
<field name="name">product.template.product.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="categ_id" position="after">
<field name="nb_accesories"> Nombre d accessoire </field>
</field> </field>
</field> </field>
</record> </record>
......
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