Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
sale_transaction_form_link/models/__init__.py
Executable file
1
sale_transaction_form_link/models/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import sale_order
|
||||
36
sale_transaction_form_link/models/sale_order.py
Executable file
36
sale_transaction_form_link/models/sale_order.py
Executable file
@@ -0,0 +1,36 @@
|
||||
# Copyright 2020 ACSONE SA/NV
|
||||
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
payment_transaction_count = fields.Integer(
|
||||
string="Number of payment transactions",
|
||||
compute="_compute_payment_transaction_count",
|
||||
)
|
||||
|
||||
@api.depends("transaction_ids")
|
||||
def _compute_payment_transaction_count(self):
|
||||
for rec in self:
|
||||
rec.payment_transaction_count = len(rec.transaction_ids)
|
||||
|
||||
def action_view_transaction(self):
|
||||
action = {
|
||||
"type": "ir.actions.act_window",
|
||||
"name": "Payment Transactions",
|
||||
"res_model": "payment.transaction",
|
||||
}
|
||||
if self.payment_transaction_count == 1:
|
||||
action.update({"res_id": self.transaction_ids.id, "view_mode": "form"})
|
||||
else:
|
||||
action.update(
|
||||
{
|
||||
"view_mode": "list,form",
|
||||
"domain": [("id", "in", self.transaction_ids.ids)],
|
||||
}
|
||||
)
|
||||
return action
|
||||
Reference in New Issue
Block a user