Skip to content

Commit 84b8085

Browse files
committed
fixup! [ADD] sale_action_paid
1 parent 5579530 commit 84b8085

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

sale_action_paid/models/sale_order.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ def action_paid(self):
1313
self.env["ir.config_parameter"].sudo().get_param("sale.automatic_invoice")
1414
)
1515
for order in self.filtered(lambda so: so.state in ("draft", "sent")):
16-
tx = order.sudo().transaction_ids._get_last()
17-
if tx and tx.state == "pending":
16+
txs = order.sudo().transaction_ids.filtered(
17+
lambda t: t.state in ("draft", "pending")
18+
)
19+
tx = txs._get_last()
20+
if not tx:
21+
tx = txs.sorted()[:1]
22+
if tx:
1823
tx._set_done()
1924
# Prevent to generate a new payment for marking the invoice as paid.
2025
# This will disable the send_payment_succeeded_for_order_mail,

sale_action_paid/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_action_paid

sale_action_paid/views/sale_order_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
type="object"
1212
class="oe_highlight"
1313
string="Paid"
14-
invisible="state != 'sent'"
14+
invisible="state not in ('draft', 'sent')"
1515
/>
1616
</button>
1717
</field>

0 commit comments

Comments
 (0)