diff --git a/l10n_fr_ecotaxe/__manifest__.py b/l10n_fr_ecotaxe/__manifest__.py index 851401332..76ff8f27c 100644 --- a/l10n_fr_ecotaxe/__manifest__.py +++ b/l10n_fr_ecotaxe/__manifest__.py @@ -4,7 +4,7 @@ { "name": "France Custom Ecotaxe", "summary": "Use Ecotaxe in French localisation contexte", - "version": "16.0.1.0.0", + "version": "16.0.2.0.0", "author": "Akretion, Odoo Community Association (OCA)", "website": "https://github.com/OCA/l10n-france", "category": "Localization/Account Taxes", diff --git a/l10n_fr_ecotaxe/migrations/16.0.2.0.0/pre-migration.py b/l10n_fr_ecotaxe/migrations/16.0.2.0.0/pre-migration.py new file mode 100644 index 000000000..8008d6add --- /dev/null +++ b/l10n_fr_ecotaxe/migrations/16.0.2.0.0/pre-migration.py @@ -0,0 +1,177 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author Mourad EL HADJ MIMOUNE +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "categ_id" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "accoun_tecotaxe_classification", + "account_ecotaxe_categ_id", + "categ_id", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "sector_id" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "account_ecotaxe_classification", + "ecotaxe_sector_id", + "sector_id", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "collector_id" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "account_ecotaxe_classification", + "ecotaxe_collector_id", + "collector_id", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "product_status" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "account_ecotaxe_classification", + "ecotaxe_product_status", + "product_status", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "supplier_status" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "account_ecotaxe_classification", + "ecotaxe_supplier_status", + "supplier_status", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "emebi_code" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "account_ecotaxe_classification", + "ecotaxe_deb_code", + "emebi_code", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_ecotaxe_classification", "scale_code" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.ecotaxe.classification", + "account_ecotaxe_classification", + "ecotaxe_scale_code", + "scale_code", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_move_line_ecotaxe", "classification_id" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.move.line.ecotaxe", + "account_move_line_ecotaxe", + "ecotaxe_classification_id", + "classification_id", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_move_line_ecotaxe", "amount_unit" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.move.line.ecotaxe", + "account_move_line_ecotaxe", + "ecotaxe_amount_unit", + "amount_unit", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_move_line_ecotaxe", "amount_total" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.move.line.ecotaxe", + "account_move_line_ecotaxe", + "ecotaxe_amount_total", + "amount_total", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "account_move_line_ecotaxe", "force_amount_unit" + ): + openupgrade.rename_fields( + env, + [ + ( + "account.move.line.ecotaxe", + "account_move_line_ecotaxe", + "force_ecotaxe_unit", + "force_amount_unit", + ), + ], + ) + if not openupgrade.column_exists( + env.cr, "ecotaxe_line_product", "classification_id" + ): + openupgrade.rename_fields( + env, + [ + ( + "ecotaxe.line.product", + "ecotaxe_line_product", + "ecotaxe_classification_id", + "classification_id", + ), + ], + ) diff --git a/l10n_fr_ecotaxe/models/account_ecotaxe_classification.py b/l10n_fr_ecotaxe/models/account_ecotaxe_classification.py index c9311f443..06b7331c7 100644 --- a/l10n_fr_ecotaxe/models/account_ecotaxe_classification.py +++ b/l10n_fr_ecotaxe/models/account_ecotaxe_classification.py @@ -24,15 +24,15 @@ def _default_company_id(self): ) ecotaxe_coef = fields.Float(digits="Ecotaxe") default_fixed_ecotaxe = fields.Float(help="Default fixed ecotaxe amount.") - account_ecotaxe_categ_id = fields.Many2one( + categ_id = fields.Many2one( comodel_name="account.ecotaxe.category", - string="Ecotaxe category", + string="Category", ) - ecotaxe_sector_id = fields.Many2one( + sector_id = fields.Many2one( comodel_name="ecotaxe.sector", string="Ecotaxe sector", ) - ecotaxe_collector_id = fields.Many2one( + collector_id = fields.Many2one( comodel_name="ecotaxe.collector", string="Ecotaxe collector", ) @@ -45,12 +45,11 @@ def _default_company_id(self): " company. Otherwise, this Fiscal Classification will be available" " for all companies.", ) - ecotaxe_product_status = fields.Selection( + product_status = fields.Selection( [("M", "Menager"), ("P", "Professionnel")], - string="Product Status", required=True, ) - ecotaxe_supplier_status = fields.Selection( + supplier_status = fields.Selection( [ ("FAB", "Fabricant"), ("REV", "Revendeur sous sa marque"), @@ -58,7 +57,6 @@ def _default_company_id(self): ("IMP", "Importateur"), ("DIS", "Vendeur à distance"), ], - string="Supplier Status", required=True, help="FAB ==> Fabricant : est établi en France et fabrique des EEE\n" "sous son propre nom ou sa propre marque, ou fait concevoir ou\n" @@ -75,8 +73,8 @@ def _default_company_id(self): "membre ou dans un pays tiers et vend en France des EEE par\n" "communication à distance", ) - ecotaxe_deb_code = fields.Char() - ecotaxe_scale_code = fields.Char() + emebi_code = fields.Char() + scale_code = fields.Char() @api.onchange("ecotaxe_type") def _onchange_ecotaxe_type(self): diff --git a/l10n_fr_ecotaxe/models/account_move_line.py b/l10n_fr_ecotaxe/models/account_move_line.py index 39d61d595..e575e26cb 100644 --- a/l10n_fr_ecotaxe/models/account_move_line.py +++ b/l10n_fr_ecotaxe/models/account_move_line.py @@ -24,13 +24,13 @@ class AcountMoveLine(models.Model): @api.depends( "move_id.currency_id", "ecotaxe_line_ids", - "ecotaxe_line_ids.ecotaxe_amount_unit", - "ecotaxe_line_ids.ecotaxe_amount_total", + "ecotaxe_line_ids.amount_unit", + "ecotaxe_line_ids.amount_total", ) def _compute_ecotaxe(self): for line in self: - unit = sum(line.ecotaxe_line_ids.mapped("ecotaxe_amount_unit")) - subtotal_ecotaxe = sum(line.ecotaxe_line_ids.mapped("ecotaxe_amount_total")) + unit = sum(line.ecotaxe_line_ids.mapped("amount_unit")) + subtotal_ecotaxe = sum(line.ecotaxe_line_ids.mapped("amount_total")) if line.move_id.currency_id: unit = line.move_id.currency_id.round(unit) @@ -49,15 +49,15 @@ def _onchange_product_ecotaxe_line(self): self.ecotaxe_line_ids = [(5,)] # Remove all ecotaxe classification ecotax_cls_vals = [] for ecotaxeline_prod in self.product_id.all_ecotaxe_line_product_ids: - classif_id = ecotaxeline_prod.ecotaxe_classification_id.id + classif_id = ecotaxeline_prod.classification_id.id forced_amount = ecotaxeline_prod.force_ecotaxe_amount ecotax_cls_vals.append( ( 0, 0, { - "ecotaxe_classification_id": classif_id, - "force_ecotaxe_unit": forced_amount, + "classification_id": classif_id, + "force_amount_unit": forced_amount, }, ) ) diff --git a/l10n_fr_ecotaxe/models/account_move_line_ecotaxe.py b/l10n_fr_ecotaxe/models/account_move_line_ecotaxe.py index 58827897f..40dc8603d 100644 --- a/l10n_fr_ecotaxe/models/account_move_line_ecotaxe.py +++ b/l10n_fr_ecotaxe/models/account_move_line_ecotaxe.py @@ -8,6 +8,8 @@ class AccountMoveLineEcotaxe(models.Model): _name = "account.move.line.ecotaxe" _inherit = "ecotaxe.line.mixin" + _description = "Account move line ecotaxe" + account_move_line_id = fields.Many2one( comodel_name="account.move.line", string="Account move line", diff --git a/l10n_fr_ecotaxe/models/ecotaxe_line_mixin.py b/l10n_fr_ecotaxe/models/ecotaxe_line_mixin.py index 99340132a..0b0a8e125 100644 --- a/l10n_fr_ecotaxe/models/ecotaxe_line_mixin.py +++ b/l10n_fr_ecotaxe/models/ecotaxe_line_mixin.py @@ -15,19 +15,19 @@ class EcotaxeLineMixin(models.AbstractModel): product_id = fields.Many2one("product.product", string="Product", readonly=True) currency_id = fields.Many2one("res.currency", string="Currency") - ecotaxe_classification_id = fields.Many2one( + classification_id = fields.Many2one( "account.ecotaxe.classification", - string="Ecotaxe Classification", + string="Classification", ) - ecotaxe_amount_unit = fields.Monetary( + amount_unit = fields.Monetary( compute="_compute_ecotaxe", help="Ecotaxe Amount computed form Classification or Manuel ecotaxe", store=True, ) - force_ecotaxe_unit = fields.Monetary( + force_amount_unit = fields.Monetary( help="Force ecotaxe.\n" "Allow to subtite default Ecotaxe Classification\n" ) - ecotaxe_amount_total = fields.Monetary( + amount_total = fields.Monetary( compute="_compute_ecotaxe", help="Ecotaxe Amount total computed form Classification or forced ecotaxe amount", store=True, @@ -35,24 +35,22 @@ class EcotaxeLineMixin(models.AbstractModel): quantity = fields.Float(digits="Product Unit of Measure", readonly=True) @api.depends( - "ecotaxe_classification_id", - "force_ecotaxe_unit", + "classification_id", + "force_amount_unit", "product_id", "quantity", ) def _compute_ecotaxe(self): for ecotaxeline in self: - ecotax_cls = ecotaxeline.ecotaxe_classification_id + ecotax_cls = ecotaxeline.classification_id if ecotax_cls.ecotaxe_type == "weight_based": amt = ecotax_cls.ecotaxe_coef * (ecotaxeline.product_id.weight or 0.0) else: amt = ecotax_cls.default_fixed_ecotaxe # force ecotaxe amount - if ecotaxeline.force_ecotaxe_unit: - amt = ecotaxeline.force_ecotaxe_unit + if ecotaxeline.force_amount_unit: + amt = ecotaxeline.force_amount_unit - ecotaxeline.ecotaxe_amount_unit = amt - ecotaxeline.ecotaxe_amount_total = ( - ecotaxeline.ecotaxe_amount_unit * ecotaxeline.quantity - ) + ecotaxeline.amount_unit = amt + ecotaxeline.amount_total = ecotaxeline.amount_unit * ecotaxeline.quantity diff --git a/l10n_fr_ecotaxe/models/ecotaxe_line_product.py b/l10n_fr_ecotaxe/models/ecotaxe_line_product.py index cfe32bc99..c5db9ec8d 100644 --- a/l10n_fr_ecotaxe/models/ecotaxe_line_product.py +++ b/l10n_fr_ecotaxe/models/ecotaxe_line_product.py @@ -16,9 +16,9 @@ class EcotaxeLineProduct(models.Model): ) product_id = fields.Many2one("product.product", string="Product", readonly=True) currency_id = fields.Many2one(related="product_tmplt_id.currency_id", readonly=True) - ecotaxe_classification_id = fields.Many2one( + classification_id = fields.Many2one( "account.ecotaxe.classification", - string="Ecotaxe Classification", + string="Classification", ) force_ecotaxe_amount = fields.Monetary( help="Force ecotaxe.\n" "Allow to substitute default Ecotaxe Classification\n" @@ -30,14 +30,14 @@ class EcotaxeLineProduct(models.Model): ) @api.depends( - "ecotaxe_classification_id", - "ecotaxe_classification_id.ecotaxe_type", - "ecotaxe_classification_id.ecotaxe_coef", + "classification_id", + "classification_id.ecotaxe_type", + "classification_id.ecotaxe_coef", "force_ecotaxe_amount", ) def _compute_ecotaxe(self): for ecotaxeline in self: - ecotax_cls = ecotaxeline.ecotaxe_classification_id + ecotax_cls = ecotaxeline.classification_id if ecotax_cls.ecotaxe_type == "weight_based": amt = ecotax_cls.ecotaxe_coef * ( @@ -54,13 +54,13 @@ def _compute_ecotaxe(self): _sql_constraints = [ ( - "unique_ecotaxe_classification_id_by_product", - "UNIQUE(ecotaxe_classification_id, product_id)", + "unique_classification_id_by_product", + "UNIQUE(classification_id, product_id)", "Only one ecotaxe classification occurrence by product", ), ( - "unique_ecotaxe_classification_id_by_product_tmpl", - "UNIQUE(ecotaxe_classification_id, product_tmplt_id)", + "unique_classification_id_by_product_tmpl", + "UNIQUE(classification_id, product_tmplt_id)", "Only one ecotaxe classification occurrence by product Template", ), ] diff --git a/l10n_fr_ecotaxe/models/product_product.py b/l10n_fr_ecotaxe/models/product_product.py index 679850832..2db6e069a 100644 --- a/l10n_fr_ecotaxe/models/product_product.py +++ b/l10n_fr_ecotaxe/models/product_product.py @@ -52,9 +52,9 @@ def _search_all_ecotaxe_line_product_ids(self, operator, operand): @api.depends( "all_ecotaxe_line_product_ids", - "all_ecotaxe_line_product_ids.ecotaxe_classification_id", - "all_ecotaxe_line_product_ids.ecotaxe_classification_id.ecotaxe_type", - "all_ecotaxe_line_product_ids.ecotaxe_classification_id.ecotaxe_coef", + "all_ecotaxe_line_product_ids.classification_id", + "all_ecotaxe_line_product_ids.classification_id.ecotaxe_type", + "all_ecotaxe_line_product_ids.classification_id.ecotaxe_coef", "all_ecotaxe_line_product_ids.force_ecotaxe_amount", "weight", ) @@ -62,7 +62,7 @@ def _compute_product_ecotaxe(self): for product in self: amount_ecotaxe = 0.0 for ecotaxeline_prod in product.all_ecotaxe_line_product_ids: - ecotax_cls = ecotaxeline_prod.ecotaxe_classification_id + ecotax_cls = ecotaxeline_prod.classification_id ecotaxe_line = 0.0 if ecotax_cls.ecotaxe_type == "weight_based": ecotaxe_line = ecotax_cls.ecotaxe_coef * (product.weight or 0.0) diff --git a/l10n_fr_ecotaxe/models/product_template.py b/l10n_fr_ecotaxe/models/product_template.py index 8f8b7049b..fafd0b444 100644 --- a/l10n_fr_ecotaxe/models/product_template.py +++ b/l10n_fr_ecotaxe/models/product_template.py @@ -22,9 +22,9 @@ class ProductTemplate(models.Model): @api.depends( "ecotaxe_line_product_ids", - "ecotaxe_line_product_ids.ecotaxe_classification_id", - "ecotaxe_line_product_ids.ecotaxe_classification_id.ecotaxe_type", - "ecotaxe_line_product_ids.ecotaxe_classification_id.ecotaxe_coef", + "ecotaxe_line_product_ids.classification_id", + "ecotaxe_line_product_ids.classification_id.ecotaxe_type", + "ecotaxe_line_product_ids.classification_id.ecotaxe_coef", "ecotaxe_line_product_ids.force_ecotaxe_amount", "weight", ) @@ -32,7 +32,7 @@ def _compute_ecotaxe(self): for tmpl in self: amount_ecotaxe = 0.0 for ecotaxeline_prod in tmpl.ecotaxe_line_product_ids: - ecotax_cls = ecotaxeline_prod.ecotaxe_classification_id + ecotax_cls = ecotaxeline_prod.classification_id ecotaxe_line = 0.0 if ecotax_cls.ecotaxe_type == "weight_based": ecotaxe_line = ecotax_cls.ecotaxe_coef * (tmpl.weight or 0.0) diff --git a/l10n_fr_ecotaxe/tests/test_ecotaxe.py b/l10n_fr_ecotaxe/tests/test_ecotaxe.py index cb9caaccd..acf6a5ecf 100644 --- a/l10n_fr_ecotaxe/tests/test_ecotaxe.py +++ b/l10n_fr_ecotaxe/tests/test_ecotaxe.py @@ -129,7 +129,7 @@ def _make_product(cls, ecotax_classification): 0, 0, { - "ecotaxe_classification_id": ecotax_classification.id, + "classification_id": ecotax_classification.id, }, ) ], @@ -162,7 +162,7 @@ def _make_product_variants(cls, ecotax_classification): 0, 0, { - "ecotaxe_classification_id": ecotax_classification.id, + "classification_id": ecotax_classification.id, }, ) ], @@ -374,7 +374,7 @@ def test_05_force_ecotax_on_invoice(self): """ product = self._make_product(self.ecotax_fixed) invoice = self._make_invoice(products=product) - invoice.invoice_line_ids[0].ecotaxe_line_ids.force_ecotaxe_unit = 2 + invoice.invoice_line_ids[0].ecotaxe_line_ids.force_amount_unit = 2 self._run_checks( invoice, {"amount_ecotaxe": 2.0, "amount_total": 100.0}, @@ -411,7 +411,7 @@ def test_06_product_variants(self): 0, 0, { - "ecotaxe_classification_id": self.ecotax_weight.id, + "classification_id": self.ecotax_weight.id, }, ) ] diff --git a/l10n_fr_ecotaxe/views/account_ecotaxe_classification_view.xml b/l10n_fr_ecotaxe/views/account_ecotaxe_classification_view.xml index 5df89c56f..76d530569 100644 --- a/l10n_fr_ecotaxe/views/account_ecotaxe_classification_view.xml +++ b/l10n_fr_ecotaxe/views/account_ecotaxe_classification_view.xml @@ -20,8 +20,8 @@ name="default_fixed_ecotaxe" attrs="{'invisible': [['ecotaxe_type', '!=', 'fixed']]}" /> - - + + @@ -46,13 +46,13 @@ - - - - - - - + + + + + + + diff --git a/l10n_fr_ecotaxe/views/account_move_view.xml b/l10n_fr_ecotaxe/views/account_move_view.xml index 017bfd0f6..36b975468 100644 --- a/l10n_fr_ecotaxe/views/account_move_view.xml +++ b/l10n_fr_ecotaxe/views/account_move_view.xml @@ -36,10 +36,10 @@ /> - - - - + + + + @@ -53,10 +53,10 @@ attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}" > - - - - + + + + - - - + + + diff --git a/l10n_fr_ecotaxe/views/product_template_view.xml b/l10n_fr_ecotaxe/views/product_template_view.xml index f36a182f4..687b51a66 100644 --- a/l10n_fr_ecotaxe/views/product_template_view.xml +++ b/l10n_fr_ecotaxe/views/product_template_view.xml @@ -18,7 +18,7 @@
- + diff --git a/l10n_fr_ecotaxe/views/product_view.xml b/l10n_fr_ecotaxe/views/product_view.xml index db1d37d76..9dc57a166 100644 --- a/l10n_fr_ecotaxe/views/product_view.xml +++ b/l10n_fr_ecotaxe/views/product_view.xml @@ -23,7 +23,7 @@ readonly="1" > - + @@ -40,7 +40,7 @@ nolabel="1" > - + @@ -68,7 +68,7 @@ nolabel="1" > - +