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

[15.0][IMP] sale_order_invoice_amount: not count over-invoicing lines for uninvoicing amount #3338

Open
wants to merge 2 commits into
base: 15.0
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions sale_order_invoice_amount/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _compute_invoice_amount(self):
* (line.price_total / line.product_uom_qty)
for line in rec.order_line.filtered(
lambda sl: sl.product_uom_qty > 0
and sl.product_uom_qty > sl.qty_invoiced
)
),
)
Expand Down
41 changes: 41 additions & 0 deletions sale_order_invoice_amount/tests/test_sale_order_invoice_amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,44 @@ def test_03_sale_order_invoiced_amount_different_currencies_sale(self):
0.0,
"Uninvoiced Amount should be calculated.",
)

def test_04_sale_order_invoiced_amount_negative(self):
self.assertEqual(
self.sale_order_1.invoiced_amount,
0.0,
"Invoiced Amount should be 0.0",
)

self.sale_order_1.action_confirm()
aml1 = self.order_line_1._prepare_invoice_line()
aml1["quantity"] = 20.0
aml2 = self.order_line_2._prepare_invoice_line()
test_invoice = self.env["account.move"].create(
[
{
"move_type": "out_invoice",
"invoice_date": fields.Date.from_string("2024-01-01"),
"date": fields.Date.from_string("2024-01-01"),
"partner_id": self.res_partner_1.id,
"invoice_line_ids": [
(
0,
0,
aml1,
),
(
0,
0,
aml2,
),
],
}
]
)
test_invoice.action_post()
self.assertEqual(
self.sale_order_1.uninvoiced_amount,
121.0,
"Uninvoiced Amount should be 121, as we invoiced more than required in one line, "
"but we have not invoices sale order line 3.",
)
Loading