[MIG] account_payment_partner: Migration to 17.0

This commit is contained in:
Miquel Alzanillas
2023-11-22 23:25:36 +01:00
parent 4d46d09a4b
commit 4d1c73bd14
7 changed files with 29 additions and 22 deletions

View File

@@ -113,6 +113,7 @@ Contributors
- Raf Ven <raf.ven@dynapps.be>
- Marçal Isern <marsal.isern@qubiq.es>
- Miquel Alzanillas <malzanillas@apsl.net>
Maintainers
-----------

View File

@@ -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")

View File

@@ -460,6 +460,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</ul>
</li>
<li>Marçal Isern &lt;<a class="reference external" href="mailto:marsal.isern&#64;qubiq.es">marsal.isern&#64;qubiq.es</a>&gt;</li>
<li>Miquel Alzanillas &lt;<a class="reference external" href="mailto:malzanillas&#64;apsl.net">malzanillas&#64;apsl.net</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">

View File

@@ -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,
}

View File

@@ -16,7 +16,8 @@
<field
name="payment_mode_id"
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"
/>
</group>
</xpath>
@@ -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"
/>
</field>
</field>

View File

@@ -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']"
/>
<field name="has_reconciled_items" invisible="1" />
<field name="bank_account_required" invisible="1" />
@@ -46,11 +47,13 @@
[('partner_id', '=', partner_bank_filter_type_domain),
'|',('company_id', '=', company_id),('company_id', '=', False)]
</attribute>
<attribute name="attrs">
{'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'))]}
</attribute>
<attribute
name="required"
>bank_account_required and move_type in ['in_invoice', 'in_refund']</attribute>
<attribute name="readonly">state != 'draft'</attribute>
<attribute
name="invisible"
>move_type not in ['in_invoice', 'in_refund', 'in_receipt']</attribute>
</xpath>
<xpath
expr="//page[@id='other_tab']//field[@name='partner_bank_id']"

View File

@@ -15,12 +15,12 @@
<field name="show_bank_account" />
<field
name="show_bank_account_from_journal"
attrs="{'invisible': [('show_bank_account', '=', 'no')]}"
invisible="show_bank_account == 'no'"
/>
<field
name="show_bank_account_chars"
string="# of chars"
attrs="{'invisible': [('show_bank_account', 'not in', ['first', 'last'])]}"
invisible="show_bank_account not in ['first', 'last']"
/>
</group>
</group>