Skip to content

Commit

Permalink
[MIG] account_payment_partner: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelalzanillas committed Nov 22, 2023
1 parent 4d46d09 commit 22c9274
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 22 deletions.
1 change: 1 addition & 0 deletions account_payment_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Contributors
- Raf Ven <[email protected]>

- Marçal Isern <[email protected]>
- Miquel Alzanillas <[email protected]>

Maintainers
-----------
Expand Down
10 changes: 5 additions & 5 deletions account_payment_partner/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand All @@ -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")
1 change: 1 addition & 0 deletions account_payment_partner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
</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">
Expand Down
14 changes: 7 additions & 7 deletions account_payment_partner/tests/test_account_payment_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ def setUpClass(cls):
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
Expand Down Expand Up @@ -375,7 +377,6 @@ def test_invoice_in_refund(self):
)
.create(
{
"refund_method": "refund",
"reason": "reason test create",
"journal_id": invoice.journal_id.id,
}
Expand Down Expand Up @@ -409,7 +410,6 @@ def test_invoice_out_refund(self):
)
.create(
{
"refund_method": "refund",
"reason": "reason test create",
"journal_id": invoice.journal_id.id,
}
Expand Down
6 changes: 4 additions & 2 deletions account_payment_partner/views/account_move_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 == True"
/>
</group>
</xpath>
Expand All @@ -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 == True"
/>
</field>
</field>
Expand Down
15 changes: 9 additions & 6 deletions account_payment_partner/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 == True"
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" />
Expand All @@ -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 == True 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']"
Expand Down
4 changes: 2 additions & 2 deletions account_payment_partner/views/account_payment_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 22c9274

Please sign in to comment.