Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][PORT] 1333 from 16.0 - Add VIEW button on payment line #1362

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions account_payment_order/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,8 @@ def _prepare_account_payment_vals(self):
"destination_account_id"
] = self.partner_id.property_account_payable_id.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()
22 changes: 22 additions & 0 deletions account_payment_order/tests/test_payment_order_outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,25 @@ def test_supplier_manual_refund(self):
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)
10 changes: 9 additions & 1 deletion account_payment_order/views/account_payment_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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"
invisible="not move_line_id"
/>
</tree>
</field>
</record>
Expand Down
Loading