[IMP] base_transaction_id: pre-commit execution

This commit is contained in:
SimoRubi
2022-03-10 14:31:46 +01:00
committed by Dũng (Trần Đình)
parent 1e4fe34769
commit 7424171c3b
5 changed files with 22 additions and 21 deletions

View File

@@ -2,17 +2,18 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models, fields, api
from odoo import api, fields, models
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
_inherit = "account.invoice"
transaction_id = fields.Char(string='Transaction ID',
index=True,
copy=False,
help="Transaction ID from the "
"financial institute")
transaction_id = fields.Char(
string="Transaction ID",
index=True,
copy=False,
help="Transaction ID from the " "financial institute",
)
@api.multi
def action_move_create(self):

View File

@@ -2,22 +2,22 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models, fields, api
from odoo import api, fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
_inherit = "sale.order"
transaction_id = fields.Char(
'Transaction ID',
"Transaction ID",
required=False,
copy=False,
help="Transaction id from the financial institute"
help="Transaction id from the financial institute",
)
@api.multi
def _prepare_invoice(self):
"""Propagate the transaction_id from the sale order to the invoice."""
invoice_vals = super()._prepare_invoice()
invoice_vals['transaction_id'] = self.transaction_id
invoice_vals["transaction_id"] = self.transaction_id
return invoice_vals

View File

@@ -9,4 +9,4 @@ You can then add a mapping on that SO field to save the e-commerce financial
Transaction ID into the Odoo sale order field.
The main purpose is to ease the reconciliation process and be able to find the partner
when importing the bank statement.
when importing the bank statement.

View File

@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="invoice_view_custom">
<field name="name">customer.invoice.transaction.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<!-- target account.invoice.origin
the first `origin` field of the view is declared in invoice lines -->
<xpath expr="//page[@name='other_info']//field[@name='origin']" position="after">
<field name="transaction_id"/>
<field name="transaction_id" />
</xpath>
</field>
</record>
@@ -17,10 +17,10 @@
<record model="ir.ui.view" id="invoice_tree_custom">
<field name="name">account.invoice.tree_inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="inherit_id" ref="account.invoice_tree" />
<field name="arch" type="xml">
<field name="origin" position="after">
<field name="transaction_id"/>
<field name="transaction_id" />
</field>
</field>
</record>

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_order_form" model="ir.ui.view">
<field name="name">base_transaction_id.sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<group name="sale_pay" position="inside">
<field name="transaction_id"/>
<field name="transaction_id" />
</group>
</field>
</record>