From ae85b7ae5c382c087714cb74dd76564399ed2f6f Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Mon, 1 Jul 2024 12:54:59 +0200 Subject: [PATCH] [MIG] account_move_line_tax_editable: Migration to 17.0 --- account_move_line_tax_editable/README.rst | 1 + account_move_line_tax_editable/__manifest__.py | 2 +- .../models/account_move_line.py | 10 +++++++--- account_move_line_tax_editable/readme/CONTRIBUTORS.md | 1 + .../static/description/index.html | 1 + .../tests/test_account_move_line_tax_editable.py | 2 +- account_move_line_tax_editable/views/account_move.xml | 8 +++----- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/account_move_line_tax_editable/README.rst b/account_move_line_tax_editable/README.rst index 214317e6d..e82f96d95 100644 --- a/account_move_line_tax_editable/README.rst +++ b/account_move_line_tax_editable/README.rst @@ -61,6 +61,7 @@ Contributors - `Tecnativa `__: - Ernesto Tejeda + - Carlos Roca - `Sygel `__: diff --git a/account_move_line_tax_editable/__manifest__.py b/account_move_line_tax_editable/__manifest__.py index 5ce901776..33fa6a930 100644 --- a/account_move_line_tax_editable/__manifest__.py +++ b/account_move_line_tax_editable/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Move Line Tax Editable", "summary": "Allows to edit taxes on non-posted account move lines", - "version": "16.0.1.0.1", + "version": "17.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", diff --git a/account_move_line_tax_editable/models/account_move_line.py b/account_move_line_tax_editable/models/account_move_line.py index cce9f67c3..11a1e0197 100644 --- a/account_move_line_tax_editable/models/account_move_line.py +++ b/account_move_line_tax_editable/models/account_move_line.py @@ -28,19 +28,23 @@ class AccountMoveLine(models.Model): else: repartition_lines = rec.tax_line_id.invoice_repartition_line_ids lines = repartition_lines.filtered( - lambda rl: rl.repartition_type == repartition_type + lambda rl, + repartition_type=repartition_type, + factor_percent=factor_percent: rl.repartition_type == repartition_type and rl.factor_percent == factor_percent ) if len(lines) > 1: lines = ( lines.filtered( - lambda rl: rl.repartition_type == "base" + lambda rl, has_account=has_account: rl.repartition_type + == "base" or has_account is bool(rl.account_id) )[:1] or lines[:1] ) elif not lines: lines = repartition_lines.filtered( - lambda rl: rl.repartition_type == repartition_type + lambda rl, repartition_type=repartition_type: rl.repartition_type + == repartition_type )[:1] rec.tax_repartition_line_id = lines diff --git a/account_move_line_tax_editable/readme/CONTRIBUTORS.md b/account_move_line_tax_editable/readme/CONTRIBUTORS.md index be16950db..849f40934 100644 --- a/account_move_line_tax_editable/readme/CONTRIBUTORS.md +++ b/account_move_line_tax_editable/readme/CONTRIBUTORS.md @@ -2,6 +2,7 @@ - Benjamin Willig \<\> - [Tecnativa](https://www.tecnativa.com): - Ernesto Tejeda + - Carlos Roca - [Sygel](https://www.sygel.es): - Manuel Regidor - [Factor Libre](https://factorlibre.com): diff --git a/account_move_line_tax_editable/static/description/index.html b/account_move_line_tax_editable/static/description/index.html index 93a0efebe..28b0f9ee3 100644 --- a/account_move_line_tax_editable/static/description/index.html +++ b/account_move_line_tax_editable/static/description/index.html @@ -406,6 +406,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Benjamin Willig <benjamin.willig@acsone.eu>
  • Tecnativa:
    • Ernesto Tejeda
    • +
    • Carlos Roca
  • Sygel:
      diff --git a/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py b/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py index 3537db74f..17bb02621 100644 --- a/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py +++ b/account_move_line_tax_editable/tests/test_account_move_line_tax_editable.py @@ -31,7 +31,7 @@ class TestAccountMoveLineTaxEditable(AccountTestInvoicingCommon): cls.account_expense = cls.company_data["default_account_expense"] cls.account_tax_sale = cls.company_data["default_account_tax_sale"] cls.tax_sale = cls.company_data["default_tax_sale"] - cls.tax_sale_copy = cls.tax_sale.copy() + cls.tax_sale_copy = cls.tax_sale.copy({"name": "Test sale tax"}) cls.test_move = cls.env["account.move"].create( { "move_type": "entry", diff --git a/account_move_line_tax_editable/views/account_move.xml b/account_move_line_tax_editable/views/account_move.xml index b42b05372..bce2120d8 100644 --- a/account_move_line_tax_editable/views/account_move.xml +++ b/account_move_line_tax_editable/views/account_move.xml @@ -12,16 +12,14 @@ expr="//field[@name='line_ids']/tree/field[@name='tax_line_id']" position="before" > - + - 0 - {'readonly': [('is_tax_editable', '=', False)]} + False + not is_tax_editable hide