From 4d1c73bd140880e01f19fdd3fa6f0ef18fe50051 Mon Sep 17 00:00:00 2001 From: Miquel Alzanillas Date: Wed, 22 Nov 2023 23:25:36 +0100 Subject: [PATCH] [MIG] account_payment_partner: Migration to 17.0 --- account_payment_partner/README.rst | 1 + account_payment_partner/hooks.py | 10 +++++----- .../static/description/index.html | 1 + .../tests/test_account_payment_partner.py | 14 +++++++------- .../views/account_move_line.xml | 6 ++++-- .../views/account_move_view.xml | 15 +++++++++------ .../views/account_payment_mode.xml | 4 ++-- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index 7847d172d..80d1ad30a 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -113,6 +113,7 @@ Contributors - Raf Ven - Marçal Isern +- Miquel Alzanillas Maintainers ----------- diff --git a/account_payment_partner/hooks.py b/account_payment_partner/hooks.py index f2a1b840c..a246b32be 100644 --- a/account_payment_partner/hooks.py +++ b/account_payment_partner/hooks.py @@ -5,7 +5,7 @@ from odoo.tools import sql logger = logging.getLogger(__name__) -def pre_init_hook(cr): +def pre_init_hook(env): """Prepare new payment_mode fields. Add columns to avoid Memory error on an existing Odoo instance @@ -16,7 +16,7 @@ def pre_init_hook(cr): customer_payment_mode_id on res.partner, so they can stay NULL, nothing to compute. """ - if not sql.column_exists(cr, "account_move", "payment_mode_id"): - sql.create_column(cr, "account_move", "payment_mode_id", "int4") - if not sql.column_exists(cr, "account_move_line", "payment_mode_id"): - sql.create_column(cr, "account_move_line", "payment_mode_id", "int4") + if not sql.column_exists(env.cr, "account_move", "payment_mode_id"): + sql.create_column(env.cr, "account_move", "payment_mode_id", "int4") + if not sql.column_exists(env.cr, "account_move_line", "payment_mode_id"): + sql.create_column(env.cr, "account_move_line", "payment_mode_id", "int4") diff --git a/account_payment_partner/static/description/index.html b/account_payment_partner/static/description/index.html index 1cec785e5..41899ac2f 100644 --- a/account_payment_partner/static/description/index.html +++ b/account_payment_partner/static/description/index.html @@ -460,6 +460,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Marçal Isern <marsal.isern@qubiq.es>
  • +
  • Miquel Alzanillas <malzanillas@apsl.net>
  • diff --git a/account_payment_partner/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index 705ec7043..41f5950d1 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -24,15 +24,17 @@ class TestAccountPaymentPartner(TransactionCase): cls.company = cls.env.ref("base.main_company") cls.company_2 = cls.env["res.company"].create({"name": "Company 2"}) - charts = cls.env["account.chart.template"].search([]) - if charts: - cls.chart = charts[0] - else: + chart = cls.env["account.chart.template"]._guess_chart_template( + cls.company.country_id + ) + if not chart: raise ValidationError(_("No Chart of Account Template has been defined !")) old_company = cls.env.user.company_id cls.env.user.company_id = cls.company_2.id cls.env.ref("base.user_admin").company_ids = [(4, cls.company_2.id)] - cls.chart.try_loading() + cls.env["account.chart.template"].try_loading( + "generic_coa", company=cls.company, install_demo=False + ) cls.env.user.company_id = old_company.id # refs @@ -375,7 +377,6 @@ class TestAccountPaymentPartner(TransactionCase): ) .create( { - "refund_method": "refund", "reason": "reason test create", "journal_id": invoice.journal_id.id, } @@ -409,7 +410,6 @@ class TestAccountPaymentPartner(TransactionCase): ) .create( { - "refund_method": "refund", "reason": "reason test create", "journal_id": invoice.journal_id.id, } diff --git a/account_payment_partner/views/account_move_line.xml b/account_payment_partner/views/account_move_line.xml index 3f34cbc86..51bcb9bf5 100644 --- a/account_payment_partner/views/account_move_line.xml +++ b/account_payment_partner/views/account_move_line.xml @@ -16,7 +16,8 @@ @@ -34,7 +35,8 @@ name="payment_mode_id" optional="hide" force_save="1" - attrs="{'invisible': [('account_type', 'not in', ['asset_receivable', 'liability_payable'])], 'readonly': ['|', ('account_type', 'not in', ['asset_receivable', 'liability_payable']), ('reconciled', '=', True)]}" + invisible="account_type not in ['asset_receivable', 'liability_payable']" + readonly="account_type not in ['asset_receivable', 'liability_payable'] or reconciled" /> diff --git a/account_payment_partner/views/account_move_view.xml b/account_payment_partner/views/account_move_view.xml index 4f2ac00a1..dba7a6e57 100644 --- a/account_payment_partner/views/account_move_view.xml +++ b/account_payment_partner/views/account_move_view.xml @@ -28,7 +28,8 @@ name="payment_mode_id" domain="[('payment_type', '=', payment_mode_filter_type_domain), ('company_id', '=', company_id)]" widget="selection" - attrs="{'readonly': [('has_reconciled_items', '=', True)], 'invisible': [('move_type', 'not in', ('out_invoice','out_refund','in_invoice','in_refund'))]}" + readonly="has_reconciled_items" + invisible="move_type not in ['out_invoice','out_refund','in_invoice','in_refund']" /> @@ -46,11 +47,13 @@ [('partner_id', '=', partner_bank_filter_type_domain), '|',('company_id', '=', company_id),('company_id', '=', False)] - - {'required': [('bank_account_required', '=', True),('move_type', 'in', ('in_invoice', 'in_refund'))], - 'readonly': [('state', '!=', 'draft')], - 'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund', 'in_receipt'))]} - + bank_account_required and move_type in ['in_invoice', 'in_refund'] + state != 'draft' + move_type not in ['in_invoice', 'in_refund', 'in_receipt']