Skip to content
Extraits de code Groupes Projets
Valider 63fe1330 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[ADD] different accounts on forfaits

parent 680af815
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
"summary": "Ajout des taxes sur les devis", "summary": "Ajout des taxes sur les devis",
"author": "Le Filament", "author": "Le Filament",
"website": "https://le-filament.com", "website": "https://le-filament.com",
"version": "14.0.1.0.0", "version": "14.0.2.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["ap_sale_project", "product_category_tax"], "depends": ["ap_sale_project", "product_category_tax"],
"data": [ "data": [
# views # views
"views/product_template_view.xml",
"views/sale_intervention_view.xml", "views/sale_intervention_view.xml",
], ],
"installable": True, "installable": True,
......
# Copyright 2021-2022 Le Filament (https://le-filament.com) # Copyright 2021-2022 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import product_template
from . import sale_intervention from . import sale_intervention
from . import sale_project from . import sale_project
from . import sale_order from . import sale_order
from . import sale_order_line
# Copyright 2022 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
# Specific behavior for AP32, added a second income account for forfaits
property_account_service_income_id = fields.Many2one(
"account.account",
company_dependent=True,
string="Compte de revenus (Service)",
domain=[("deprecated", "=", False)],
help="Ce champ permet de définir un compte différent pour les activités"
" de service sur un forfait.",
)
# Copyright 2022 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
# ------------------------------------------------------
# Business method
# ------------------------------------------------------
def _prepare_invoice_line(self, **optional_values):
# Method to update account on invoice line in case service account
# is different from base account (AP32 has 2 different accounts for the same product)
res = super(SaleOrderLine, self)._prepare_invoice_line(**optional_values)
if res.get("product_id"):
product_id = self.env["product.product"].browse(res.get("product_id"))
product_tmpl_id = product_id.product_tmpl_id
if product_tmpl_id.property_account_service_income_id and (
product_tmpl_id.property_account_income_id.id
!= product_tmpl_id.property_account_service_income_id.id
):
furniture_categ_id = self.env.ref(
"ap_sale_project.product_category_plantation_supply"
)
vat_furniture_categ = (
self.env["product.category"].browse(furniture_categ_id.id).taxes_id
)
if res.get("tax_ids") == [(6, 0, vat_furniture_categ.mapped("id"))]:
res[
"account_id"
] = product_tmpl_id.property_account_service_income_id.id
return res
...@@ -111,7 +111,7 @@ class SaleProject(models.Model): ...@@ -111,7 +111,7 @@ class SaleProject(models.Model):
**data_sol_section, **data_sol_section,
**{ **{
"price_unit": plant_price, "price_unit": plant_price,
"name": sol_name + " - Plants garantis 3 ans", "name": "Plants garantis 3 ans",
"tax_id": [(6, 0, vat_plant_categ.ids)], "tax_id": [(6, 0, vat_plant_categ.ids)],
}, },
} }
...@@ -121,7 +121,7 @@ class SaleProject(models.Model): ...@@ -121,7 +121,7 @@ class SaleProject(models.Model):
**data_sol_section, **data_sol_section,
**{ **{
"price_unit": price_unit - plant_price, "price_unit": price_unit - plant_price,
"name": sol_name + " - Paillage, protections, " "name": "Paillage, protections, "
"ingénierie, livraison et suivi", "ingénierie, livraison et suivi",
"tax_id": [(6, 0, vat_furniture_categ.ids)], "tax_id": [(6, 0, vat_furniture_categ.ids)],
}, },
......
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2022 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<record id="product_template_form_view_2nd_account" model="ir.ui.view">
<field name="name">product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view" />
<field name="arch" type="xml">
<field name="property_account_income_id" position="after">
<field
name="property_account_service_income_id"
attrs="{'invisible': [('categ_id', '!=', %(ap_sale_project.product_category_forfait)d)]}"
/>
</field>
</field>
</record>
</data>
</odoo>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<field name="collarette_qty" position="after"> <field name="collarette_qty" position="after">
<field <field
name="collarette_calc" name="collarette_calc"
attrs="{'invisible': [('is_collarette', '!=', True), ('intervention_uom_name', '!=', 'm')]}" attrs="{'invisible': [('is_collarette', '!=', True)]}"
/> />
</field> </field>
</field> </field>
......
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