Merge pull request #186 from akretion/14.0-add-sale-show-transaction
add sale_show_transaction, that make transaction really visible on sale order
This commit is contained in:
1
sale_show_transaction/__init__.py
Normal file
1
sale_show_transaction/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
25
sale_show_transaction/__manifest__.py
Normal file
25
sale_show_transaction/__manifest__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2022 Akretion (https://www.akretion.com).
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Sale Show Transaction",
|
||||
"summary": "Make transaction hyper visible on sale order",
|
||||
"version": "14.0.1.0.0",
|
||||
"development_status": "Alpha",
|
||||
"category": "Uncategorized",
|
||||
"website": "www.akretion.com",
|
||||
"author": " Akretion",
|
||||
"license": "AGPL-3",
|
||||
"external_dependencies": {
|
||||
"python": [],
|
||||
"bin": [],
|
||||
},
|
||||
"depends": [
|
||||
"sale",
|
||||
],
|
||||
"data": [
|
||||
"views/sale_order_view.xml",
|
||||
],
|
||||
"demo": [
|
||||
],
|
||||
}
|
||||
1
sale_show_transaction/models/__init__.py
Normal file
1
sale_show_transaction/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import sale_order
|
||||
30
sale_show_transaction/models/sale_order.py
Normal file
30
sale_show_transaction/models/sale_order.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright 2022 Akretion (https://www.akretion.com).
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
main_acquirer_id = fields.Many2one(
|
||||
'payment.acquirer',
|
||||
'Online payment mode',
|
||||
compute="_compute_main_acquirer",
|
||||
store=True)
|
||||
|
||||
@api.depends("transaction_ids.state")
|
||||
def _compute_main_acquirer(self):
|
||||
for record in self:
|
||||
if len(record.transaction_ids.acquirer_id) > 1:
|
||||
for state in ["done", "authorized", "pending", "draft", "cancel", "error"]:
|
||||
transaction = record.transaction_ids.filtered(lambda s: s.state == state)
|
||||
if len(transaction.acquirer_id) > 1:
|
||||
transaction.sorted("amount")
|
||||
if transaction:
|
||||
record.main_acquirer_id = transaction[0].acquirer_id
|
||||
break
|
||||
else:
|
||||
record.main_acquirer_id = record.transaction_ids.acquirer_id
|
||||
|
||||
46
sale_show_transaction/views/sale_order_view.xml
Normal file
46
sale_show_transaction/views/sale_order_view.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="sale_order_view_form" model="ir.ui.view">
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="note" position="after">
|
||||
<separator string="Transaction" colspan="4"/>
|
||||
<field name="transaction_ids" nolabel="1" colspan="4">
|
||||
<tree
|
||||
decoration-danger="state in ('error', 'cancel')"
|
||||
decoration-success="state == 'done'"
|
||||
>
|
||||
<field name="reference"/>
|
||||
<field name="create_date"/>
|
||||
<field name="acquirer_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_order_tree" model="ir.ui.view">
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="state" position="after">
|
||||
<field name="main_acquirer_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_quotation_tree" model="ir.ui.view">
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_quotation_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="currency_id" position="after">
|
||||
<field name="main_acquirer_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user