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][FW] [IMP] account_payment_sale: Add payment mode in invoicing grouping criteria #1354

Merged
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
6 changes: 6 additions & 0 deletions .oca/oca-port/blacklist/account_payment_sale.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pull_requests": {
"orphaned_commits": "Not relevant",
"1269": "Nothing to port from PR (already done through 6d4af78f71bcdd46d47068eee7cf7e39db373aab)"
}
}
11 changes: 11 additions & 0 deletions account_payment_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ def _prepare_invoice(self):
vals = super()._prepare_invoice()
self._get_payment_mode_vals(vals)
return vals

@api.model
def _get_invoice_grouping_keys(self) -> list:
"""
When several sale orders are generating invoices,
we want to add the payment mode in grouping criteria.
"""
keys = super()._get_invoice_grouping_keys()
if "payment_mode_id" not in keys:
keys.append("payment_mode_id")
return keys
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 @@ -94,3 +94,22 @@ def test_sale_to_invoice_payment_mode_via_payment(self):
self.assertEqual(len(invoice), 1)
self.assertEqual(invoice.payment_mode_id, self.payment_mode_2)
self.assertFalse(invoice.partner_bank_id)

def test_several_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 another payment mode
Test case:
Create the invoice from the sale orders
Expected result:
Two invoices should be generated
"""
payment_mode_2 = self.env.ref("account_payment_mode.payment_mode_outbound_dd1")
order_1 = self.create_sale_order()
order_2 = self.create_sale_order(payment_mode_2)
orders = order_1 | order_2
orders.action_confirm()
invoices = orders._create_invoices()
self.assertEqual(2, len(invoices))
Loading