Skip to content

[MIG] sale_margin_percentage: Migration to 19.0 T#98917#1728

Open
JesusValdez96 wants to merge 17 commits intoVauxoo:19.0from
vauxoo-dev:19.0-mig-sale-margin-percentage-jesusvaldez96
Open

[MIG] sale_margin_percentage: Migration to 19.0 T#98917#1728
JesusValdez96 wants to merge 17 commits intoVauxoo:19.0from
vauxoo-dev:19.0-mig-sale-margin-percentage-jesusvaldez96

Conversation

@JesusValdez96
Copy link
Copy Markdown

This commit migrates the sale_margin_percentage module to version 19.0 with the following changes:

  • Adapt settings and sales views to the 19.0 architecture, replacing deprecated settings markup and updating order line list.
  • Add a stored margin alert helper to keep line decorations without relying on the restricted margin percent field in the view.
  • Update security and test definitions to match the newer API changes.
  • Remove the obsolete post-migration script and bump the module
    version to 19.0.1.0.0.

Related to T#98917

Jose Suniaga [Vauxoo] and others added 17 commits April 16, 2026 22:48
By this way, the sale order gross margin percentage is calculated
by the sum all the margin lines between the inverse sum of all
subtotals.

Module features:
- Field to configure Margin Threshold on sale settings.
- Colors in sale order lines to point the margin threshold.
- Fix to 100 margin percentage when purchase price is not set.
- Fix to -100 margin percentage when price unit is not set.
Fix to 0 margin percentage when product quatity is 0.
The sale.config.settings view was changed completely after v10.0,
in this fix we have moved margin_threshold field from old sale
settings view to the new one.
The following is performed:
- Added group for managing sales percentages.
- Updated translations and test modifications.
- Modifications made for test execution.
- Added the 'for' attribute inside the labels.
Migration process from v12.0 to v15.0
To follow our good practices each model should be in its own file with
the same name as the model.
… of native one

The field margin_percentage is no longer needed since native module
sale_margin have the field margin_percent that serve the same propose.
Also the field margin_threshold must be updated since it was used as a
percentage but the native field margin_percent is a ration so we must
follow the same pattern.
There's a migration script to recompute sales marging on sale order
lines, which was raising memory errors with databases that contain many
lines.

The following optimizations are applied:
- Don't call compute method directly but mark the field to be computed.
  This avoids one write per record and makes the ORM to take care of
  batches.
- Read currency directly from the line, instead of from the pricelist
  which in turn requires reading the order.
- Don't read currency if quantity is zero as it won't be used anyway
This module was originally created in v11 for a specific customer, and
the purchase price needed to be non-editable for some reason. Now the
purchase price does not need to be non-editable. If it is needed, it
should be managed in the view because the field is natively editable.
This commit migrates the sale_margin_percentage module to Odoo 19.0 with
the following changes:

- Adapt settings and sales views to the 19.0 architecture, replacing
deprecated settings markup and updating order line list.
- Add a stored margin alert helper to keep line decorations without
relying on the restricted margin percent field in the view.
- Update security and test definitions to match the newer API changes.
- Remove the obsolete post-migration script and bump the module
version to 19.0.1.0.0.

Related to T#98917
@JesusValdez96 JesusValdez96 force-pushed the 19.0-mig-sale-margin-percentage-jesusvaldez96 branch from f1302a3 to 2f72027 Compare April 16, 2026 22:48
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.

6 participants