From 07bc7926e93360cf7382e80b00c4d52f2c5dccab Mon Sep 17 00:00:00 2001 From: JasminSForgeFlow Date: Mon, 4 Mar 2024 10:45:29 +0530 Subject: [PATCH] [MIG] account_move_line_purchase_info: Migration to 17.0 --- .../__manifest__.py | 2 +- .../models/purchase_order.py | 2 +- .../models/purchase_order_line.py | 2 +- .../models/stock_move.py | 2 +- .../test_account_move_line_purchase_info.py | 18 ++++++++++-------- .../views/purchase_order_view.xml | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/account_move_line_purchase_info/__manifest__.py b/account_move_line_purchase_info/__manifest__.py index 0b5dba7c8..6ea57bf68 100644 --- a/account_move_line_purchase_info/__manifest__.py +++ b/account_move_line_purchase_info/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Account Move Line Purchase Info", "summary": "Introduces the purchase order line to the journal items", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", "category": "Generic", diff --git a/account_move_line_purchase_info/models/purchase_order.py b/account_move_line_purchase_info/models/purchase_order.py index 11a05644e..fc4934e2c 100644 --- a/account_move_line_purchase_info/models/purchase_order.py +++ b/account_move_line_purchase_info/models/purchase_order.py @@ -38,7 +38,7 @@ class PurchaseOrder(models.Model): immediately. """ if not invoices: - self.sudo()._read(["journal_entry_ids"]) + self.sudo().read(["journal_entry_ids"]) invoices = self.journal_entry_ids result = self.env["ir.actions.act_window"]._for_xml_id( diff --git a/account_move_line_purchase_info/models/purchase_order_line.py b/account_move_line_purchase_info/models/purchase_order_line.py index 16f53d04c..0432ac98a 100644 --- a/account_move_line_purchase_info/models/purchase_order_line.py +++ b/account_move_line_purchase_info/models/purchase_order_line.py @@ -9,7 +9,7 @@ class PurchaseOrderLine(models.Model): def name_get(self): result = [] - orig_name = dict(super(PurchaseOrderLine, self).name_get()) + orig_name = dict(super().name_get()) for line in self: name = orig_name[line.id] if self.env.context.get("po_line_info", False): diff --git a/account_move_line_purchase_info/models/stock_move.py b/account_move_line_purchase_info/models/stock_move.py index f5a484159..e6db0388e 100644 --- a/account_move_line_purchase_info/models/stock_move.py +++ b/account_move_line_purchase_info/models/stock_move.py @@ -11,7 +11,7 @@ class StockMove(models.Model): def _prepare_account_move_line( self, qty, cost, credit_account_id, debit_account_id, svl_id, description ): - res = super(StockMove, self)._prepare_account_move_line( + res = super()._prepare_account_move_line( qty, cost, credit_account_id, debit_account_id, svl_id, description ) for line in res: diff --git a/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py b/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py index 8dc0a8074..3c44e2d8e 100644 --- a/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py +++ b/account_move_line_purchase_info/tests/test_account_move_line_purchase_info.py @@ -9,7 +9,7 @@ from odoo.tests import Form, common class TestAccountMoveLinePurchaseInfo(common.TransactionCase): @classmethod def setUpClass(cls): - super(TestAccountMoveLinePurchaseInfo, cls).setUpClass() + super().setUpClass() cls.purchase_model = cls.env["purchase.order"] cls.purchase_line_model = cls.env["purchase.order.line"] cls.product_model = cls.env["product.product"] @@ -160,8 +160,9 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): self.assertEqual( balance, expected_balance, - "Balance is not %s for Purchase Line %s." - % (str(expected_balance), purchase_line.name), + "Balance is not {} for Purchase Line {}.".format( + str(expected_balance), purchase_line.name + ), ) def test_purchase_invoice(self): @@ -176,7 +177,7 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): purchase.button_confirm() picking = purchase.picking_ids[0] picking.action_confirm() - picking.move_ids.write({"quantity_done": 1.0}) + picking.move_ids.write({"quantity": 1.0}) picking.button_validate() expected_balance = 1.0 @@ -203,7 +204,7 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): "from the invoice to the account move line.", ) - def test_name_get(self): + def test_display_name(self): purchase = self._create_purchase([(self.product, 1)]) po_line = purchase.order_line[0] name_get = po_line.with_context(**{"po_line_info": True}).name_get() @@ -212,8 +213,9 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): [ ( po_line.id, - "[%s] %s (%s)" - % (po_line.order_id.name, po_line.name, po_line.order_id.state), + "[{}] {} ({})".format( + po_line.order_id.name, po_line.name, po_line.order_id.state + ), ) ], ) @@ -229,7 +231,7 @@ class TestAccountMoveLinePurchaseInfo(common.TransactionCase): self.assertEqual(purchase.invoice_ids.id, False) self.assertEqual(purchase.journal_entries_count, 0) self.assertEqual(purchase.invoice_count, 0) - purchase.picking_ids.move_ids_without_package.quantity_done = 1 + purchase.picking_ids.move_ids_without_package.quantity = 1 purchase.picking_ids.button_validate() self.assertEqual(purchase.journal_entries_count, 1) self.assertEqual(purchase.invoice_count, 0) diff --git a/account_move_line_purchase_info/views/purchase_order_view.xml b/account_move_line_purchase_info/views/purchase_order_view.xml index 1be1f0758..6a7725fbc 100644 --- a/account_move_line_purchase_info/views/purchase_order_view.xml +++ b/account_move_line_purchase_info/views/purchase_order_view.xml @@ -10,7 +10,7 @@ name="action_view_journal_entries" class="oe_stat_button" icon="fa-list-ul" - attrs="{'invisible':['|', ('journal_entries_count', '=', 0), ('state', 'in', ('draft','sent','to approve'))]}" + invisible="journal_entries_count == 0 or state in ('draft', 'sent', 'to approve')" groups="account.group_account_user" >