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

[16.0][IMP] sale_global_discount: refactor _compute_amounts #2

Open
wants to merge 189 commits into
base: 16.0-mig-sale_global_discount
Choose a base branch
from

Conversation

trisdoan
Copy link

@trisdoan trisdoan commented Jun 11, 2024

Context

In simple case (tax is not included in price), flow of the module as follow:

  • Let tax is computed as usual, as odoo native supports
  • Afterwards, checking if global discount is applied on Sale order:
    1. If not, only add amt_untaxed_before_global_discount and amt_total_before_global_discount,
    2. If yes, precompute tax

A example of Sale order is below:

  • Tax is not included in price
  • With 20% global discount
Product Name Quantity Unit Price SubTotal
Example Product 2 $75 $150
Untaxed Amt
$120
Tax
$18.0
Total
$138.0

=> So tax is recalculated based on Final price (after global discount)

  • Before this change, if enabling included-in-price tax, it breaks the intended flow as it triggers the part 'handling price include' again with the new price

This change

  • pass param: handle_price_include=False because it was handle in super(), by default handle_price_include=True . Now, as we recalculate tax to apply global discount, there is no need to handle price included or not.

  • With above example, now it is:
    - but this time, Tax is included in price

Product Name Quantity Unit Price SubTotal
Example Product 2 $75 $130.43
Untaxed Amt
$104.34
Tax
$15.65
Total
$119.9900
  • Add a check to only recompute tax when global discount is applied on the sale order. Before this change, it results in rounding issue. It happens when products are configured as tax-included in price. For example:

sample_sale_global_discount

@trisdoan trisdoan force-pushed the 16.0-imp-sale_global_discount branch from 55e64dc to c232b83 Compare June 13, 2024 07:13
@ferran-S73 ferran-S73 force-pushed the 16.0-mig-sale_global_discount branch 2 times, most recently from 54cdf29 to ded6836 Compare June 20, 2024 06:55
OCA-git-bot and others added 22 commits June 20, 2024 10:09
Signed-off-by rafaelbn
Currently translated at 85.7% (6 of 7 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_force_invoiced
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_force_invoiced/hr/
Currently translated at 100.0% (3 of 3 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_order_price_recalculation
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_price_recalculation/hr/
Currently translated at 79.5% (35 of 44 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_advance_payment
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_advance_payment/hr/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_auto_remove_zero_quantity_lines
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_auto_remove_zero_quantity_lines/hr/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-product_form_sale_link
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-product_form_sale_link/hr/
Currently translated at 100.0% (4 of 4 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_automatic_workflow_payment_mode
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_automatic_workflow_payment_mode/hr/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_shipping_info_helper
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_shipping_info_helper/hr/
Currently translated at 100.0% (9 of 9 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_delivery_state
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_delivery_state/hr/
Currently translated at 100.0% (5 of 5 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_mrp_bom
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_mrp_bom/hr/
Currently translated at 100.0% (7 of 7 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_order_carrier_auto_assign
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_carrier_auto_assign/hr/
Currently translated at 100.0% (1 of 1 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_procurement_customer
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_procurement_customer/hr/
ChristianSantamaria and others added 27 commits August 13, 2024 10:20
Signed-off-by StefanRijnhart
Currently translated at 18.6% (11 of 59 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_automatic_workflow
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_automatic_workflow/hr/
Signed-off-by rousseldenis
Currently translated at 100.0% (26 of 26 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_product_set
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_product_set/it/
Currently translated at 100.0% (170 of 170 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_blanket_order
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_blanket_order/it/
Signed-off-by rousseldenis
Signed-off-by StefanRijnhart
If test is run at a certain date nearly midnight, the test that
evaluates invoice date from sale one was failing. So, freeze the date
at mid of day.
Signed-off-by pedrobaeza
Currently translated at 100.0% (6 of 6 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_force_invoiced_quantity
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_force_invoiced_quantity/it/
Currently translated at 100.0% (5 of 5 strings)

Translation: sale-workflow-16.0/sale-workflow-16.0-sale_order_partner_no_autofollow
Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_partner_no_autofollow/it/
@trisdoan trisdoan force-pushed the 16.0-imp-sale_global_discount branch from bfbd0f2 to 66e7eb4 Compare August 29, 2024 04:35
@trisdoan trisdoan force-pushed the 16.0-imp-sale_global_discount branch from 66e7eb4 to 751459b Compare August 29, 2024 10:46
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.