From b4a29158f5f1af79eca3a662663e998ee6d37785 Mon Sep 17 00:00:00 2001 From: Antoni Marroig Campomar Date: Tue, 14 May 2024 09:08:00 +0200 Subject: [PATCH] [MIG] account_invoice_pricelist: Migration to 17.0 --- account_invoice_pricelist/README.rst | 3 +++ account_invoice_pricelist/__manifest__.py | 4 ++-- account_invoice_pricelist/models/account_move.py | 4 +--- account_invoice_pricelist/readme/CONTRIBUTORS.md | 2 ++ .../static/description/index.html | 4 ++++ .../tests/test_account_move_pricelist.py | 13 ++++++++----- .../views/account_invoice_view.xml | 13 +++++-------- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/account_invoice_pricelist/README.rst b/account_invoice_pricelist/README.rst index a45d3a03be3a..0e8e001a275f 100644 --- a/account_invoice_pricelist/README.rst +++ b/account_invoice_pricelist/README.rst @@ -77,6 +77,9 @@ Contributors - Alberto Martín - Nikul Chaudhary - Manuel Regidor +- `APSL-Nagarro `__: + + - Antoni Marroig Maintainers ----------- diff --git a/account_invoice_pricelist/__manifest__.py b/account_invoice_pricelist/__manifest__.py index 7bc1bccf3c5e..7e365ba60f0d 100644 --- a/account_invoice_pricelist/__manifest__.py +++ b/account_invoice_pricelist/__manifest__.py @@ -2,13 +2,13 @@ { "name": "Account - Pricelist on Invoices", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "summary": "Add partner pricelist on invoices", "category": "Accounting & Finance", "author": "GRAP," "Therp BV," "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-invoicing", "license": "AGPL-3", - "depends": ["account"], + "depends": ["account", "sale_management"], "data": ["views/account_invoice_view.xml"], "installable": True, } diff --git a/account_invoice_pricelist/models/account_move.py b/account_invoice_pricelist/models/account_move.py index 966f70aabf47..8b4ce031fbc8 100644 --- a/account_invoice_pricelist/models/account_move.py +++ b/account_invoice_pricelist/models/account_move.py @@ -11,11 +11,9 @@ class AccountMove(models.Model): pricelist_id = fields.Many2one( comodel_name="product.pricelist", string="Pricelist", - states={"draft": [("readonly", False)]}, compute="_compute_pricelist_id", tracking=True, store=True, - readonly=True, precompute=True, ) @@ -122,7 +120,7 @@ def _get_price_with_pricelist(self): qty, uom, date, - target_currency=self.currency_id, + currency=self.currency_id, ) price_unit = max(base_price, final_price) self.with_context( diff --git a/account_invoice_pricelist/readme/CONTRIBUTORS.md b/account_invoice_pricelist/readme/CONTRIBUTORS.md index c61fcdea97b7..8ff972f9afb8 100644 --- a/account_invoice_pricelist/readme/CONTRIBUTORS.md +++ b/account_invoice_pricelist/readme/CONTRIBUTORS.md @@ -5,3 +5,5 @@ - Alberto Martín \<\> - Nikul Chaudhary \<\> - Manuel Regidor \<\> +- [APSL-Nagarro](https://www.apsl.tech): + - Antoni Marroig \<\> \ No newline at end of file diff --git a/account_invoice_pricelist/static/description/index.html b/account_invoice_pricelist/static/description/index.html index 7b0a5c89d19f..58e825dd4fd6 100644 --- a/account_invoice_pricelist/static/description/index.html +++ b/account_invoice_pricelist/static/description/index.html @@ -422,6 +422,10 @@

Contributors

  • Alberto Martín <alberto.martin@guadaltech.es>
  • Nikul Chaudhary <nikulchaudhary2112@gmail.com>
  • Manuel Regidor <manuel.regidor@sygel.es>
  • +
  • APSL-Nagarro: +
  • diff --git a/account_invoice_pricelist/tests/test_account_move_pricelist.py b/account_invoice_pricelist/tests/test_account_move_pricelist.py index ec04c4d67202..55164ce7b8e4 100644 --- a/account_invoice_pricelist/tests/test_account_move_pricelist.py +++ b/account_invoice_pricelist/tests/test_account_move_pricelist.py @@ -124,7 +124,10 @@ def setUpClass(cls): ], } ) - cls.euro_currency = cls.env["res.currency"].search([("name", "=", "EUR")]) + cls.euro_currency = cls.env["res.currency"].search( + [("active", "=", False), ("name", "=", "EUR")] + ) + cls.euro_currency.active = True cls.usd_currency = cls.env["res.currency"].search([("name", "=", "USD")]) cls.sale_pricelist_with_discount_in_euros = cls.ProductPricelist.create( { @@ -280,14 +283,14 @@ def test_account_invoice_pricelist_with_discount_secondary_currency(self): self.invoice.pricelist_id = self.sale_pricelist_with_discount_in_euros.id self.invoice.button_update_prices_from_pricelist() invoice_line = self.invoice.invoice_line_ids[:1] - self.assertAlmostEqual(invoice_line.price_unit, 58.87) + self.assertAlmostEqual(invoice_line.price_unit, 75.55) self.assertEqual(invoice_line.discount, 0.00) def test_account_invoice_pricelist_without_discount_secondary_currency(self): self.invoice.pricelist_id = self.sale_pricelist_without_discount_in_euros.id self.invoice.button_update_prices_from_pricelist() invoice_line = self.invoice.invoice_line_ids[:1] - self.assertAlmostEqual(invoice_line.price_unit, 65.41) + self.assertAlmostEqual(invoice_line.price_unit, 83.94) self.assertEqual(invoice_line.discount, 10.00) def test_account_invoice_fixed_pricelist_with_discount_secondary_currency(self): @@ -301,8 +304,8 @@ def test_account_invoice_fixed_pricelist_without_discount_secondary_currency(sel self.invoice.pricelist_id = self.sale_pricelist_fixed_wo_disc_euros.id self.invoice.button_update_prices_from_pricelist() invoice_line = self.invoice.invoice_line_ids[:1] - self.assertAlmostEqual(invoice_line.price_unit, 65.41) - self.assertEqual(invoice_line.discount, 8.27) + self.assertAlmostEqual(invoice_line.price_unit, 83.94) + self.assertEqual(invoice_line.discount, 28.52) def test_check_currency(self): with self.assertRaises(UserError): diff --git a/account_invoice_pricelist/views/account_invoice_view.xml b/account_invoice_pricelist/views/account_invoice_view.xml index 7e2cac6e8f71..f083daf728e8 100644 --- a/account_invoice_pricelist/views/account_invoice_view.xml +++ b/account_invoice_pricelist/views/account_invoice_view.xml @@ -10,7 +10,7 @@ name="button_update_prices_from_pricelist" groups="product.group_product_pricelist" string="Update prices" - attrs="{'invisible': ['|', '|', ('pricelist_id', '=', False), ('state', 'not in', ['draft']), ('move_type', 'not in', ['out_invoice', 'out_refund'])]}" + invisible="not pricelist_id or state != 'draft' or move_type not in ['out_invoice', 'out_refund']" help="Update price in lines from the pricelist" /> @@ -18,17 +18,13 @@ expr="//group[@id='header_right_group']//field[@name='currency_id']" position="attributes" > - {'readonly': [('pricelist_id', '!=', False)]} + pricelist_id - {'readonly': [('pricelist_id', '!=', False)]} + pricelist_id