Skip to content

Commit

Permalink
[FIX] account_payment_sale: Force add payment mode in invoice vals
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiadavid committed Jul 5, 2024
1 parent 0ca46be commit f2a04c8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
18 changes: 9 additions & 9 deletions account_payment_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def _compute_payment_mode(self):
order.payment_mode_id = False

def _get_payment_mode_vals(self, vals):
if self.payment_mode_id:
vals["payment_mode_id"] = self.payment_mode_id.id
if (
self.payment_mode_id.bank_account_link == "fixed"
and self.payment_mode_id.payment_method_id.code == "manual"
):
vals[
"partner_bank_id"
] = self.payment_mode_id.fixed_journal_id.bank_account_id.id
vals["payment_mode_id"] = self.payment_mode_id.id
if (
self.payment_mode_id
and self.payment_mode_id.bank_account_link == "fixed"
and self.payment_mode_id.payment_method_id.code == "manual"
):
vals[
"partner_bank_id"
] = self.payment_mode_id.fixed_journal_id.bank_account_id.id

def _prepare_invoice(self):
"""Copy bank partner from sale order to invoice"""
Expand Down
19 changes: 19 additions & 0 deletions account_payment_sale/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,22 @@ def test_several_sale_to_invoice_payment_mode(self):
orders.action_confirm()
invoices = orders._create_invoices()
self.assertEqual(2, len(invoices))

def test_mixed_null_sale_to_invoice_payment_mode(self):
"""
Data:
A partner with a specific payment_mode
A sale order created with the payment_mode of the partner
A sale order created with null payment_mode
Test case:
Create the invoice from the sale orders
Expected result:
Two invoices should be generated
"""
order_1 = self.create_sale_order()
order_2 = self.create_sale_order()
order_2.payment_mode_id = False
orders = order_1 | order_2
orders.action_confirm()
invoices = orders._create_invoices()
self.assertEqual(2, len(invoices))

0 comments on commit f2a04c8

Please sign in to comment.