Skip to content

[18.0][ADD] sale_pricelist_delivery_date#4002

Closed
AungKoKoLin1997 wants to merge 1 commit intoOCA:18.0from
qrtl:18.0-add-sale_pricelist_delivery_date
Closed

[18.0][ADD] sale_pricelist_delivery_date#4002
AungKoKoLin1997 wants to merge 1 commit intoOCA:18.0from
qrtl:18.0-add-sale_pricelist_delivery_date

Conversation

@AungKoKoLin1997
Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 commented Nov 11, 2025

This module allows users to calculate the unit price of sale order lines based on the delivery date of the sales order.

@qrtl QT5925

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-sale_pricelist_delivery_date branch from 780b364 to 8fd8d1a Compare November 11, 2025 06:55
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-sale_pricelist_delivery_date branch from 8fd8d1a to 666199b Compare November 11, 2025 07:21
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-sale_pricelist_delivery_date branch from 666199b to 9be63d7 Compare November 12, 2025 01:14
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-sale_pricelist_delivery_date branch 2 times, most recently from 0e77f7f to ad460b3 Compare November 13, 2025 01:40
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-sale_pricelist_delivery_date branch 4 times, most recently from 0d7dca6 to 19766bb Compare November 14, 2025 07:55
@AungKoKoLin1997
Copy link
Contributor Author

I am a bit confused about the test failures in CI. I checked the modules that fail in CI using my development environment, but the failures are not the same. In my dev environment, only the following test case fails.

2021-10-02 15:30:00,000 3068706 ERROR 5odoo183 odoo.addons.sale_order_product_recommendation.tests.test_recommendation: FAIL: RecommendationCaseTests.test_recommendations_price_origin
Traceback (most recent call last):
  File "/home/lin/ws/odoo18/sale-workflow/sale_order_product_recommendation/tests/test_recommendation.py", line 268, in test_recommendations_price_origin
    self.assertEqual(wiz_line_prod2.price_unit, 89.00)
AssertionError: 50.0 != 89.0

As far as I can see, the reason is that technical_price_unit has the same value as price_unit at creation time, even though the product’s list price is different from the assigned price_unit (89).

cls.prod_2 = cls.product_obj.create(
{
"name": "Test Product 2",
"type": "service",
"list_price": 50.00,
"categ_id": cls.cat_b.id,
}
)

cls.order2 = cls.env["sale.order"].create(
{
"partner_id": cls.partner.id,
"partner_shipping_id": cls.partner_delivery.id,
"locked": "True",
"date_order": "2021-05-03",
"order_line": [
(
0,
0,
{
"product_id": cls.prod_2.id,
"name": cls.prod_2.name,
"product_uom_qty": 50,
"qty_delivered_method": "manual",
"qty_delivered": 50,
"price_unit": 89.00,
},
),
],
}
)

When I reproduce the same workflow in the UI, these two fields have different values (50 and 89).

Because of this, when date_order is changed in the test case and _compute_price_unit is triggered, it does not treat the line as having a manual price (see has_manual_price), and it recalculates price_unit, which causes the test failure.
https://github.com/odoo/odoo/blob/ec212f38e50520edf612522717952855c8c09a80/addons/sale/models/sale_order_line.py#L563-L570

I haven’t found an optimal solution yet, so any suggestions or guidance would be very welcome.

@AungKoKoLin1997
Copy link
Contributor Author

As far as I can see, the reason is that technical_price_unit has the same value as price_unit at creation time, even though the product’s list price is different from the assigned price_unit (89).

I think this may be the case.
https://github.com/odoo/odoo/blob/ec212f38e50520edf612522717952855c8c09a80/addons/sale/models/sale_order_line.py#L1274-L1278

@yostashiro
Copy link
Member

As far as I can see, the reason is that technical_price_unit has the same value as price_unit at creation time, even though the product’s list price is different from the assigned price_unit (89).

I think this may be the case. https://github.com/odoo/odoo/blob/ec212f38e50520edf612522717952855c8c09a80/addons/sale/models/sale_order_line.py#L1274-L1278

Looks like it is. In that case, I suppose changing the way https://github.com/OCA/sale-workflow/blob/18.0/sale_order_product_recommendation/tests/test_recommendation_common.py creates order lines may fix the issue? The lines should first be created with no price_unit assignment, so precompute is not interfered with, and then updated later with a price_unit value.

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 18.0-add-sale_pricelist_delivery_date branch from 51fc3f0 to 21df6ab Compare January 26, 2026 02:16
@AungKoKoLin1997
Copy link
Contributor Author

Close this PR since it shares the same behavior with existing one.
#4159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants