Skip to content

Commit

Permalink
Merge PR #1362 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by alexis-via
  • Loading branch information
OCA-git-bot committed Oct 1, 2024
2 parents dba499b + b6fd861 commit c653764
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
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

0 comments on commit c653764

Please sign in to comment.