diff --git a/__manifest__.py b/__manifest__.py index 05fed293ca8c2a7f30fbf23752caeb2a29c2cfaa..ec81bae058b3bfe8e5bb04e9db4019d18391278b 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -3,11 +3,12 @@ "summary": "Ajout des taxes sur les devis", "author": "Le Filament", "website": "https://le-filament.com", - "version": "14.0.1.0.0", + "version": "14.0.2.0.0", "license": "AGPL-3", "depends": ["ap_sale_project", "product_category_tax"], "data": [ # views + "views/product_template_view.xml", "views/sale_intervention_view.xml", ], "installable": True, diff --git a/models/__init__.py b/models/__init__.py index 7e691b33f4f2a14c9880c0364ad52efe399686bc..9e1972044e7ce221ddea80f9df90ad15ff0a8691 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,6 +1,8 @@ # Copyright 2021-2022 Le Filament (https://le-filament.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) +from . import product_template from . import sale_intervention from . import sale_project from . import sale_order +from . import sale_order_line diff --git a/models/product_template.py b/models/product_template.py new file mode 100644 index 0000000000000000000000000000000000000000..b719b6f9b80d77e927261cf32a18e9dad5ab7f74 --- /dev/null +++ b/models/product_template.py @@ -0,0 +1,18 @@ +# 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.", + ) diff --git a/models/sale_order_line.py b/models/sale_order_line.py new file mode 100644 index 0000000000000000000000000000000000000000..f84f64c71cdc6d5df1faabd0a7fd53a28711ba3e --- /dev/null +++ b/models/sale_order_line.py @@ -0,0 +1,34 @@ +# 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 diff --git a/models/sale_project.py b/models/sale_project.py index abaa606d71878a36fa225bb1a2e4fffa9a14d4a8..ef56d8a7e7ee6096b473290bc0b12fd42ffdee51 100644 --- a/models/sale_project.py +++ b/models/sale_project.py @@ -111,7 +111,7 @@ class SaleProject(models.Model): **data_sol_section, **{ "price_unit": plant_price, - "name": sol_name + " - Plants garantis 3 ans", + "name": "Plants garantis 3 ans", "tax_id": [(6, 0, vat_plant_categ.ids)], }, } @@ -121,7 +121,7 @@ class SaleProject(models.Model): **data_sol_section, **{ "price_unit": price_unit - plant_price, - "name": sol_name + " - Paillage, protections, " + "name": "Paillage, protections, " "ingénierie, livraison et suivi", "tax_id": [(6, 0, vat_furniture_categ.ids)], }, diff --git a/views/product_template_view.xml b/views/product_template_view.xml new file mode 100644 index 0000000000000000000000000000000000000000..734575c82fc34d29bcb4bc87b88de109105fee01 --- /dev/null +++ b/views/product_template_view.xml @@ -0,0 +1,20 @@ +<?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> diff --git a/views/sale_intervention_view.xml b/views/sale_intervention_view.xml index d35c6d424843231852ce7a500c115f2c79708d56..3e5e370cc0576f25752ff26f2227b3c7ddb6259a 100644 --- a/views/sale_intervention_view.xml +++ b/views/sale_intervention_view.xml @@ -11,7 +11,7 @@ <field name="collarette_qty" position="after"> <field name="collarette_calc" - attrs="{'invisible': [('is_collarette', '!=', True), ('intervention_uom_name', '!=', 'm')]}" + attrs="{'invisible': [('is_collarette', '!=', True)]}" /> </field> </field>