-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] sale_order_qty_change_no_recompute: Migration to 16.0
- Standard procedure - Change the strategy, as now the change is done through a computed field. - Improved README
- Loading branch information
1 parent
fcbdb40
commit bfc0c03
Showing
12 changed files
with
88 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from . import monkeypatching |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2023 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.fields import Field | ||
|
||
get_depends_original = Field.get_depends | ||
|
||
|
||
def get_depends(self, model): | ||
"""Override of the Python method to remove the dependency of the unit fields.""" | ||
depends, depends_context = get_depends_original(self, model) | ||
if model._name == "sale.order.line" and self.name in { | ||
"price_unit", | ||
"discount", | ||
"pricelist_item_id", | ||
}: | ||
if "product_uom_qty" in depends: | ||
depends.remove("product_uom_qty") | ||
if "product_uom" in depends: | ||
depends.remove("product_uom") | ||
return depends, depends_context | ||
|
||
|
||
# Monkey-patching of the method | ||
Field.get_depends = get_depends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
This module prevent recompute if only quantity has changed in sale order line. | ||
A lot of business don't set different prices according the quantity of the product to | ||
sell, and they see very annoying to set a manual price after the negotiation with the | ||
customer, and see it changed when they vary the demanded quantity. | ||
|
||
This module prevents this avoiding the recomputation of the price unit, discount and | ||
pricelist item fields if only the quantity has been changed in the sales order line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Having this module installed may alter test results of other modules | ||
expecting to have the price fields recomputed when changing quantities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
setup/sale_order_qty_change_no_recompute/odoo/addons/sale_order_qty_change_no_recompute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../sale_order_qty_change_no_recompute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |