[FIX] sale_fixed_discount: fix fixed discount on API-created order lines#3258
[FIX] sale_fixed_discount: fix fixed discount on API-created order lines#3258sefirosweb wants to merge 7 commits intoOCA:16.0from
Conversation
rousseldenis
left a comment
There was a problem hiding this comment.
@sefirosweb Could you fix this?
Moreover, adding a test case for that flow should be great.
|
@rousseldenis I saw a bit bug when is creating the records i fixed them |
|
/ocabot rebase |
This fix when you want to create order via API and you want use discount_fixed instead "discount" rate Without that the sales_order_line is created with discount_fixed but discount is 0
Co-authored-by: Denis Roussel (ACSONE) <rousseldenis@users.noreply.github.com>
Co-authored-by: Denis Roussel (ACSONE) <rousseldenis@users.noreply.github.com>
|
Congratulations, PR rebased to 16.0. |
|
@sefirosweb Could you improve your commits messages like |
|
@sefirosweb Do you plan to finish this ? |
|
OK! |
alexey-pelykh
left a comment
There was a problem hiding this comment.
Thanks for the fix @sefirosweb, the core idea of overriding _compute_discount is the right approach here.
A few things still need attention before this can be merged:
-
Remove
_onchange_discount_fixed-- as @rousseldenis mentioned in the earlier inline comment, once_compute_discountis in place the onchange is redundant. The compute method fires in both UI and API contexts, so the onchange should be dropped entirely. -
Test indentation -- the body of
test_05_discount_fixed_when_created_by_apiis indented with 12 spaces instead of the expected 8 (4 for class + 4 for method). Please align with the rest of the test file. -
Missing newline at end of file -- the test file is missing a trailing newline, which will also trip pre-commit.
-
Reuse existing fixtures -- the new test creates its own
res.partnerandproduct.productwhenself.partnerandself.product(orself.product2) fromsetUpClasscould be reused. Keeps tests consistent and leaner. -
Commit messages -- @rousseldenis already flagged this: commits should follow OCA format, e.g.
[FIX] sale_fixed_discount: .... The intermediate commits should be squashed into a single clean commit.
Points 1-4 are likely what's causing the CI failures. Should be straightforward to fix up.
@alexey-pelykh Comments for specific changes should be done in PR's code line level. Please avoid such reviews. Thanks |
This fix when you want to create order via API and you want use discount_fixed instead "discount" rate
Without that the sales_order_line is created with discount_fixed but discount is 0