From 6bf8c4a9803cebc314c7271e7505494e740594cf Mon Sep 17 00:00:00 2001 From: Ethan Hildick Date: Tue, 21 Nov 2023 09:08:16 +0100 Subject: [PATCH] [MIG] account_check_printing_report_base: Migration to 16.0 --- account_check_printing_report_base/README.rst | 12 +- .../__manifest__.py | 2 +- .../migrations/15.0.1.0.0/pre-migration.py | 44 ------- .../static/description/index.html | 8 +- .../tests/test_check_printing_report.py | 122 +++++++++--------- .../tests/test_num2words_lang_solution.py | 9 +- 6 files changed, 80 insertions(+), 117 deletions(-) delete mode 100644 account_check_printing_report_base/migrations/15.0.1.0.0/pre-migration.py diff --git a/account_check_printing_report_base/README.rst b/account_check_printing_report_base/README.rst index f00833979425..ef8ef3bc4b43 100644 --- a/account_check_printing_report_base/README.rst +++ b/account_check_printing_report_base/README.rst @@ -7,7 +7,7 @@ Account Check Printing Report Base !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:be02fe72e9fdc9c5e7cf0ae6bfeedd5722a76cb9d6b4bfd49aa211e0debe6834 + !! source digest: sha256:bb55783143c1ac5d84c90fa06d598eaaff087b45d912ea989d2b6855892a221d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Account Check Printing Report Base :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github - :target: https://github.com/OCA/account-payment/tree/15.0/account_check_printing_report_base + :target: https://github.com/OCA/account-payment/tree/16.0/account_check_printing_report_base :alt: OCA/account-payment .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-payment-15-0/account-payment-15-0-account_check_printing_report_base + :target: https://translation.odoo-community.org/projects/account-payment-16-0/account-payment-16-0-account_check_printing_report_base :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -64,7 +64,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -103,6 +103,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/account-payment `_ project on GitHub. +This module is part of the `OCA/account-payment `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_check_printing_report_base/__manifest__.py b/account_check_printing_report_base/__manifest__.py index 4ed7b8588d3c..af5c9b51dae4 100644 --- a/account_check_printing_report_base/__manifest__.py +++ b/account_check_printing_report_base/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Account Check Printing Report Base", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "Eficent," "Serpent Consulting Services Pvt. Ltd.," diff --git a/account_check_printing_report_base/migrations/15.0.1.0.0/pre-migration.py b/account_check_printing_report_base/migrations/15.0.1.0.0/pre-migration.py deleted file mode 100644 index 540c80d6fb8d..000000000000 --- a/account_check_printing_report_base/migrations/15.0.1.0.0/pre-migration.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2022 Tecnativa - Carlos Roca -# Copyright 2023 Tecnativa - Sergio Teruel -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - - -def set_account_check_printing_layout(env): - # Change in companies - openupgrade.logged_query( - env.cr, - """ - UPDATE res_company - SET account_check_printing_layout = imd.module ||'.'|| imd.name - FROM ir_model_data imd - WHERE imd.module='account_check_printing_report_base' - AND imd.model='account.payment.check.report' - AND imd.res_id=res_company.check_layout_id - """, - ) - # Change in journals - openupgrade.logged_query( - env.cr, - """ - ALTER TABLE account_journal ADD COLUMN - IF NOT EXISTS account_check_printing_layout VARCHAR - """, - ) - openupgrade.logged_query( - env.cr, - """ - UPDATE account_journal - SET account_check_printing_layout = imd.module ||'.'|| imd.name - FROM ir_model_data imd - WHERE imd.module='account_check_printing_report_base' - AND imd.model='account.payment.check.report' - AND imd.res_id=account_journal.check_layout_id - """, - ) - - -@openupgrade.migrate() -def migrate(env, version): - set_account_check_printing_layout(env) diff --git a/account_check_printing_report_base/static/description/index.html b/account_check_printing_report_base/static/description/index.html index a6fde8dc6aee..b60fa9d1dd84 100644 --- a/account_check_printing_report_base/static/description/index.html +++ b/account_check_printing_report_base/static/description/index.html @@ -367,9 +367,9 @@

Account Check Printing Report Base

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:be02fe72e9fdc9c5e7cf0ae6bfeedd5722a76cb9d6b4bfd49aa211e0debe6834 +!! source digest: sha256:bb55783143c1ac5d84c90fa06d598eaaff087b45d912ea989d2b6855892a221d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-payment Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/account-payment Translate me on Weblate Try me on Runboat

This module provides the basic framework for check printing, and a sample layout.

Table of contents

@@ -415,7 +415,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -456,7 +456,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/account-payment project on GitHub.

+

This module is part of the OCA/account-payment project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/account_check_printing_report_base/tests/test_check_printing_report.py b/account_check_printing_report_base/tests/test_check_printing_report.py index d2195c50fd2f..13ed279e38f0 100644 --- a/account_check_printing_report_base/tests/test_check_printing_report.py +++ b/account_check_printing_report_base/tests/test_check_printing_report.py @@ -10,44 +10,43 @@ class TestAccountCheckPrintingReportBase(TransactionCase): - def setUp(self): - super().setUp() - self.langs = ("en_US", "es_ES") - self.rl = self.env["res.lang"] - for lang in self.langs: - if not self.rl.search([("code", "=", lang)]): - self.rl.load_lang(lang) - self.account_invoice_model = self.env["account.move"] - self.journal_model = self.env["account.journal"] - self.payment_method_model = self.env["account.payment.method"] - self.account_account_model = self.env["account.account"] - self.payment_model = self.env["account.payment"] - self.report = self.env[ + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.langs = ("en_US", "es_ES") + cls.rl = cls.env["res.lang"] + for lang in cls.langs: + if not cls.rl.search([("code", "=", lang)]): + cls.rl.load_lang(lang) + cls.account_invoice_model = cls.env["account.move"] + cls.journal_model = cls.env["account.journal"] + cls.payment_method_model = cls.env["account.payment.method"] + cls.account_account_model = cls.env["account.account"] + cls.payment_model = cls.env["account.payment"] + cls.report = cls.env[ "report.account_check_printing_report_base.report_check_base" ] - self.partner1 = self.env.ref("base.res_partner_1") - self.company = self.env.ref("base.main_company") - self.currency_usd_id = self.env.ref("base.USD").id - self.currency_euro_id = self.env.ref("base.EUR").id - self.acc_payable = self.env.ref("account.data_account_type_payable") - self.acc_expense = self.env.ref("account.data_account_type_expenses") - self.product = self.env.ref("product.product_product_4") - self.check_report = ( - "account_check_printing_report_base.action_report_check_base" - ) - self.check_report_a4 = ( + cls.partner1 = cls.env.ref("base.res_partner_1") + cls.company = cls.env.ref("base.main_company") + cls.currency_usd_id = cls.env.ref("base.USD").id + cls.currency_euro_id = cls.env.ref("base.EUR").id + cls.acc_payable = "liability_payable" + cls.acc_expense = "expense" + cls.product = cls.env.ref("product.product_product_4") + cls.check_report = "account_check_printing_report_base.action_report_check_base" + cls.check_report_a4 = ( "account_check_printing_report_base.action_report_check_base_a4" ) - self.action_check_report = self.env.ref( + cls.action_check_report = ( "account_check_printing_report_base.action_report_check_base" ) - self.payment_method_check = self.payment_method_model.search( + cls.payment_method_check = cls.payment_method_model.search( [("code", "=", "check_printing")], limit=1, ) - if not self.payment_method_check: - self.payment_method_check = self.payment_method_model.create( + if not cls.payment_method_check: + cls.payment_method_check = cls.payment_method_model.create( { "name": "Check", "code": "check_printing", @@ -55,68 +54,71 @@ def setUp(self): "check": True, } ) - self.purchase_journal = self.journal_model.create( + cls.purchase_journal = cls.journal_model.create( {"name": "Purchase Journal - Test", "type": "purchase", "code": "Test"} ) - self.bank_journal = self.journal_model.create( + cls.bank_journal = cls.journal_model.create( { "name": "Cash Journal - Test", "type": "bank", "code": "bank", "check_manual_sequencing": True, # "outbound_payment_method_ids": [ - # (4, self.payment_method_check.id, None) + # (4, cls.payment_method_check.id, None) # ], } ) - self.acc_payable = self._create_account( - "account payable test", "ACPRB1", self.acc_payable, True + cls.acc_payable = cls._create_account( + "account payable test", "ACPRB1", cls.acc_payable, True ) - self.vendor_bill = self._create_vendor_bill(self.acc_payable) - self.vendor_bill.invoice_date = time.strftime("%Y") + "-07-15" - self.acc_expense = self._create_account( - "account expense test", "ACPRB2", self.acc_expense, False + cls.vendor_bill = cls._create_vendor_bill(cls.acc_payable) + cls.vendor_bill.invoice_date = time.strftime("%Y") + "-07-15" + cls.acc_expense = cls._create_account( + "account expense test", "ACPRB2", cls.acc_expense, False ) - self._create_invoice_line(self.acc_expense, self.vendor_bill) + cls._create_invoice_line(cls.acc_expense, cls.vendor_bill) - self.vendor_bill.action_post() + cls.vendor_bill.action_post() # Pay the invoice using a bank journal associated to the main company - ctx = {"active_model": "account.move", "active_ids": [self.vendor_bill.id]} - register_payments = self.payment_model.with_context(**ctx).create( + ctx = {"active_model": "account.move", "active_ids": [cls.vendor_bill.id]} + register_payments = cls.payment_model.with_context(**ctx).create( { "date": time.strftime("%Y") + "-07-15", - "journal_id": self.bank_journal.id, - "payment_method_line_id": self.payment_method_check.id, + "journal_id": cls.bank_journal.id, + "payment_method_line_id": cls.payment_method_check.id, } ) register_payments.action_post() - self.payment = self.payment_model.search([], order="id desc", limit=1) + cls.payment = cls.payment_model.search([], order="id desc", limit=1) - def _create_account(self, name, code, user_type, reconcile): - account = self.account_account_model.create( + @classmethod + def _create_account(cls, name, code, user_type, reconcile): + account = cls.account_account_model.create( { "name": name, "code": code, - "user_type_id": user_type.id, - "company_id": self.company.id, + "account_type": user_type, + "company_id": cls.company.id, "reconcile": reconcile, } ) return account - def _create_vendor_bill(self, account): - vendor_bill = self.account_invoice_model.create( + @classmethod + def _create_vendor_bill(cls, account): + vendor_bill = cls.account_invoice_model.create( { "move_type": "in_invoice", - "partner_id": self.partner1.id, - "currency_id": self.company.currency_id.id, - "journal_id": self.purchase_journal.id, - "company_id": self.company.id, + "partner_id": cls.partner1.id, + "currency_id": cls.company.currency_id.id, + "journal_id": cls.purchase_journal.id, + "company_id": cls.company.id, } ) return vendor_bill - def _create_invoice_line(self, account, invoice): + @classmethod + def _create_invoice_line(cls, account, invoice): invoice = invoice.write( { "invoice_line_ids": [ @@ -128,7 +130,7 @@ def _create_invoice_line(self, account, invoice): "account_id": account.id, "quantity": 1.000, "price_unit": 2.99, - "product_id": self.product.id, + "product_id": cls.product.id, }, ) ] @@ -151,7 +153,9 @@ def test_01_check_printing_no_layout(self): self.assertFalse(self.payment.journal_id.account_check_printing_layout) with self.assertRaises(RedirectWarning): self.payment.do_print_checks() - content = self.action_check_report._render_qweb_pdf(self.payment.id) + content = self["ir.actions.report"]._render_qweb_pdf( + self.action_check_report, res_ids=self.payment.ids + ) self.assertEqual(content[1], "html") def test_02_check_printing_with_layout(self): @@ -167,7 +171,9 @@ def test_02_check_printing_with_layout(self): e = e.name self.assertEqual(e, False) - content = self.action_check_report._render_qweb_pdf(self.payment.id) + content = self["ir.actions.report"]._render_qweb_pdf( + self.action_check_report, res_ids=self.payment.ids + ) self.assertEqual(content[1], "html") def test_03_fotmat_form(self): diff --git a/account_check_printing_report_base/tests/test_num2words_lang_solution.py b/account_check_printing_report_base/tests/test_num2words_lang_solution.py index 2c4c3404041f..74f8be55b680 100644 --- a/account_check_printing_report_base/tests/test_num2words_lang_solution.py +++ b/account_check_printing_report_base/tests/test_num2words_lang_solution.py @@ -3,12 +3,13 @@ class TestNum2WordsLangSolution(TransactionCase): - def setUp(self): - super().setUp() - self.propissory_note_amount = self.env[ + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.propissory_note_amount = cls.env[ "report.account_check_printing_report_base.promissory_footer_a4" ] - self.amount = 3.09 + cls.amount = 3.09 def test_num2words_es_correction(self): amount_in_word = self.propissory_note_amount.with_context(