[REF+IMP] account_payment_order: Use native payments

The previous approach creates manually the journal entries and does all
the hard work, plus not being 100% compatible with the bank statement
reconciliation widget (requiring a patch on OCB to see blue lines).

That decision made sense on the moment it was done (v9), where the
native payment model (account.payment) was very limited, and wasn't able
to store all the needed information for the bank transaction.

Now that the limitations are gone, we can get rid off this extra model,
and generate instead `account.payment` records, using both the native
model + methods to perform the same operations.

This serves also to workaround the problem found in #966.

All the code, views and tests of main module have been adapted to this
new approach in this commit. Later commits will adapt the rest of the
modules of the suite, and add migration scripts to transit from the
previous approach to this new one.

TT39832
This commit is contained in:
Pedro M. Baeza
2022-11-06 09:11:45 +01:00
parent 55e9aff82a
commit b8d818967b
16 changed files with 121 additions and 568 deletions

View File

@@ -15,7 +15,6 @@
name="partner_bank_id"
domain="[('partner_id', '=', partner_id), '|', ('company_id', '=', company_id), ('company_id', '=', False)]"
/>
<field name="bank_payment_line_id" />
</group>
</field>
</record>

View File

@@ -40,7 +40,7 @@
/>
<field name="amount_company_currency" />
<field name="company_currency_id" invisible="1" />
<field name="bank_line_id" />
<field name="payment_ids" />
<field name="payment_type" invisible="1" />
</group>
</group>

View File

@@ -98,7 +98,7 @@
/>
<field name="payment_type" invisible="0" />
<field
name="bank_line_count"
name="payment_count"
attrs="{'invisible': [('state', 'in', ('draft', 'cancel'))]}"
/>
</group>
@@ -122,11 +122,11 @@
/>
</page>
<page
name="bank-lines"
string="Bank Transactions"
name="payment-lines"
string="Payment Transactions"
attrs="{'invisible': [('state', 'in', ('draft', 'cancel'))]}"
>
<field name="bank_line_ids" edit="0" create="0" />
<field name="payment_ids" edit="0" create="0" />
</page>
</notebook>
</sheet>
@@ -150,9 +150,9 @@
<field name="date_uploaded" />
<field name="description" optional="show" />
<field
name="bank_line_count"
name="payment_count"
optional="hide"
string="Bank Transactions"
string="Payment Transactions"
/>
<field name="total_company_currency" sum="Total Company Currency" />
<field name="company_currency_id" invisible="1" />

View File

@@ -1,106 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!--
© 2015-2016 Akretion (https://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<record id="bank_payment_line_form" model="ir.ui.view">
<field name="name">bank.payment.line.form</field>
<field name="model">bank.payment.line</field>
<field name="arch" type="xml">
<form string="Bank Payment Line" create="false">
<group name="main">
<field
name="order_id"
invisible="not context.get('bank_payment_line_main_view')"
/>
<field name="name" />
<field
name="company_id"
groups="base.group_multi_company"
invisible="not context.get('bank_payment_line_main_view')"
/>
<field name="partner_id" />
<field name="date" />
<field name="amount_currency" />
<field name="currency_id" invisible="1" />
<field name="partner_bank_id" />
<field name="communication_type" />
<field name="communication" />
</group>
<group string="Related Payment Lines" name="payment-lines">
<field name="payment_line_ids" nolabel="1" />
</group>
</form>
</field>
</record>
<record id="bank_payment_line_tree" model="ir.ui.view">
<field name="name">bank.payment.line.tree</field>
<field name="model">bank.payment.line</field>
<field name="arch" type="xml">
<tree string="Bank Payment Lines" create="false">
<field
name="order_id"
invisible="not context.get('bank_payment_line_main_view')"
/>
<field name="partner_id" />
<field name="communication" />
<field name="partner_bank_id" />
<field name="date" />
<field name="amount_currency" sum="Total Amount" />
<field name="currency_id" invisible="1" />
<field name="name" optional="show" />
<field
name="company_id"
groups="base.group_multi_company"
invisible="not context.get('bank_payment_line_main_view')"
/>
</tree>
</field>
</record>
<record id="bank_payment_line_search" model="ir.ui.view">
<field name="name">bank.payment.line.search</field>
<field name="model">bank.payment.line</field>
<field name="arch" type="xml">
<search string="Search Bank Payment Lines">
<field name="partner_id" />
<filter
name="inbound"
string="Inbound"
domain="[('payment_type', '=', 'inbound')]"
/>
<filter
name="outbound"
string="Outbound"
domain="[('payment_type', '=', 'outbound')]"
/>
<group string="Group By" name="groupby">
<filter
name="state_groupby"
string="State"
context="{'group_by': 'state'}"
/>
<filter
name="partner_groupby"
string="Partner"
context="{'group_by': 'partner_id'}"
/>
</group>
</search>
</field>
</record>
<record id="bank_payment_line_action" model="ir.actions.act_window">
<field name="name">Bank Payment Lines</field>
<field name="res_model">bank.payment.line</field>
<field name="view_mode">tree,form</field>
<field name="context">{'bank_payment_line_main_view': True}</field>
</record>
<menuitem
id="bank_payment_line_menu"
action="bank_payment_line_action"
parent="account.menu_finance_payables"
sequence="50"
groups="group_account_payment"
/>
</odoo>