Skip to content
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
7 changes: 7 additions & 0 deletions sale_force_invoiced/model/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def _compute_invoice_status(self):
)
return res

@api.model
def write(self, vals):
res = super().write(vals)
if "force_invoiced" in vals:
self._compute_amount_to_invoice()
return res


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
Expand Down
26 changes: 22 additions & 4 deletions sale_force_invoiced/tests/test_sale_force_invoiced.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ def _create_product(self, name, product_ctg):
def test_sales_order(self):
so = self.sale_order_model.create({"partner_id": self.customer.id})
sol1 = self.sale_order_line_model.create(
{"product_id": self.service_1.id, "product_uom_qty": 1, "order_id": so.id}
{
"product_id": self.service_1.id,
"product_uom_qty": 1,
"order_id": so.id,
"price_unit": 1.0,
}
)
sol2 = self.sale_order_line_model.create(
{"product_id": self.service_2.id, "product_uom_qty": 2, "order_id": so.id}
{
"product_id": self.service_2.id,
"product_uom_qty": 2,
"order_id": so.id,
"price_unit": 2.0,
}
)

# confirm quotation
so.action_confirm()
# update quantities delivered
Expand Down Expand Up @@ -80,8 +89,17 @@ def test_sales_order(self):
self.assertEqual(
sol2.invoice_status, "invoiced", "The SOL invoice status should be Invoiced"
)

self.assertEqual(
so.amount_to_invoice,
0.0,
"Amount to invoice when invoice is forced should be 0",
)
so.force_invoiced = False
self.assertEqual(
so.invoice_status, "to invoice", "The invoice status should be To Invoice"
)
self.assertEqual(
so.amount_to_invoice,
5.0,
"Amount to invoice when invoice is not forced should be original amount",
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails.

2025-01-26T13:25:41.3342860Z 2025-01-26 13:25:41,333 298 �[1;31m�[1;49mERROR�[0m odoo odoo.addons.sale_force_invoiced.tests.test_sale_force_invoiced: FAIL: TestSaleForceInvoiced.test_sales_order
2025-01-26T13:25:41.3343574Z Traceback (most recent call last):
2025-01-26T13:25:41.3344183Z   File "/__w/sale-workflow/sale-workflow/sale_force_invoiced/tests/test_sale_force_invoiced.py", line 101, in test_sales_order
2025-01-26T13:25:41.3345029Z     self.assertEqual(
2025-01-26T13:25:41.3345466Z AssertionError: 3.45 != 5.0 : Amount to invoice when invoice is not forced should be original amount
2025-01-26T13:25:41.3345930Z  

Loading