Skip to content
Snippets Groups Projects
Commit b13eece4 authored by Yannick Tivisse's avatar Yannick Tivisse
Browse files

[IMP] sale_timesheet: Fix undeterministic crashing test


The method 'test_timesheet_delivery' tests the following use case:

Test timesheet invoicing with 'invoice on delivery' timetracked products
1. Create SO and confirm it
2. log timesheet
3. create invoice
4. log other timesheet
5. create a second invoice
6. add new SO line (delivered service)
7. And finally check the AMOUNTS

But it could happen, according to the installed modules, that the class
TestSaleTimesheet, which is directly linked to
-> TestCommonSaleTimesheetNoChart (sale_timesheet)
--> TestCommonSaleNoChart (sale)
---> AccountTestNoChartCommon (account)
----> SavepointCaseWithUserDemo (base)
-----> SavepointCase (base)
is influenced by other installed modules, that in our case, introduce
new res.currency.rate values.

In our test, on the sale.order.line 'so_line_ordered_global_project',
we use the product 'product_order_timesheet2', with a price_unit=90.

Then we call manually the onchange method:
``` python3
so_line_ordered_global_project.product_id_change()
```

As the order has a pricelist and a partner, we recompute the price
unit, in case a discount applies:
``` python3
if self.order_id.pricelist_id and self.order_id.partner_id:
    vals['price_unit'] = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)
self.update(vals)
```

And then , the call the _get_display_price returns an different amount
that what we expect, as
``` python3
product.with_context(pricelist=self.order_id.pricelist_id.id).price
```

will return the price converted using the related res.currency.rate
at the current date.

As we don't wish to test the conversion into another currency in this
test, we simply unlink all the currency rates, to avoid any external
influence.

closes odoo/odoo#43179

Taskid: 2166237
Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent ebc8d85d
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tools import float_is_zero
from odoo.exceptions import UserError
from odoo.addons.sale_timesheet.tests.common import TestCommonSaleTimesheetNoChart
......@@ -169,6 +168,7 @@ class TestSaleTimesheet(TestCommonSaleTimesheetNoChart):
6. add new SO line (delivered service)
"""
# create SO and confirm it
self.env['res.currency.rate'].search([]).unlink()
sale_order = self.env['sale.order'].create({
'partner_id': self.partner_customer_usd.id,
'partner_invoice_id': self.partner_customer_usd.id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment