[IMP] account_payment_order: add button to view business document

Quick access to business document on payment lines.
This commit is contained in:
Stéphane Bidoul
2024-08-16 11:34:53 +02:00
parent f498d2b72f
commit bd88cecd2f
3 changed files with 36 additions and 1 deletions

View File

@@ -244,3 +244,8 @@ class AccountPaymentLine(models.Model):
if transfer_journal:
vals["journal_id"] = transfer_journal.id
return vals
def action_open_business_doc(self):
if not self.move_line_id:
return False
return self.move_line_id.action_open_business_doc()

View File

@@ -516,3 +516,25 @@ class TestPaymentOrderOutbound(TestPaymentOrderOutboundBase):
self.assertEqual(len(payment_order.payment_line_ids), 1)
self.assertEqual("F1242 R1234", payment_order.payment_line_ids.communication)
def test_action_open_business_document(self):
# Open invoice
self.invoice.action_post()
# Add to payment order using the wizard
self.env["account.invoice.payment.line.multi"].with_context(
active_model="account.move", active_ids=self.invoice.ids
).create({}).run()
order = self.env["account.payment.order"].search(self.domain)
# Create payment line without move line
vals = {
"order_id": order.id,
"partner_id": self.partner.id,
"currency_id": order.payment_mode_id.company_id.currency_id.id,
"amount_currency": 200.38,
}
self.env["account.payment.line"].create(vals)
invoice_action = order.payment_line_ids[0].action_open_business_doc()
self.assertEqual(invoice_action["res_model"], "account.move")
self.assertEqual(invoice_action["res_id"], self.invoice.id)
manual_line_action = order.payment_line_ids[1].action_open_business_doc()
self.assertFalse(manual_line_action)

View File

@@ -18,7 +18,8 @@
name="move_line_id"
domain="[('reconciled','=', False), ('account_id.reconcile', '=', True)] "
/>
<!-- we removed the filter on amount_to_pay, because we want to be able to select refunds -->
<!-- we removed the filter on amount_to_pay, because we want to be able to
select refunds -->
<field name="date" readonly="1" force_save="1" />
<field name="ml_maturity_date" readonly="1" />
<field name="amount_currency" />
@@ -93,6 +94,13 @@
invisible="1"
/>
<field name="payment_type" invisible="1" />
<button
name="action_open_business_doc"
type="object"
string="View"
class="btn btn-secondary"
attrs="{'invisible': [('move_line_id', '=', False)]}"
/>
</tree>
</field>
</record>