-
-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_to_weight_by_product_uom: Migration to 16.0
- REM : remove various useless code (demo group, development status, etc...) - IMP : Handle create and write use cases. - ADD : Tests.
- Loading branch information
1 parent
cd346b2
commit 4227404
Showing
29 changed files
with
204 additions
and
160 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,2 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from .hooks import post_init_hook |
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 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,23 @@ | ||
def post_init_hook(cr, registry): | ||
cr.execute( | ||
""" | ||
UPDATE uom_category | ||
SET to_weight = true | ||
WHERE id = ( | ||
SELECT res_id | ||
FROM ir_model_data | ||
WHERE module = 'uom' | ||
AND name = 'product_uom_categ_kgm' | ||
);""" | ||
) | ||
|
||
cr.execute( | ||
""" | ||
UPDATE product_template | ||
SET to_weight = true | ||
FROM uom_uom, uom_category | ||
WHERE uom_uom.id = product_template.uom_id | ||
AND uom_category.id = uom_uom.category_id | ||
AND categ.to_weight = True; | ||
""" | ||
) |
24 changes: 24 additions & 0 deletions
24
pos_to_weight_by_product_uom/migrations/16.0.1.0.0/pre-migration.py
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,24 @@ | ||
# Copyright 2024, Grap | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_field_renames = [ | ||
( | ||
"uom.uom", | ||
"uom_uom", | ||
"to_weigh", | ||
"to_weight", | ||
), | ||
( | ||
"uom.category", | ||
"uom_category", | ||
"to_weigh", | ||
"to_weight", | ||
), | ||
] | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_fields(env, _field_renames) |
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 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,17 +1,10 @@ | ||
# Copyright 2017, Grap | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo import fields, models | ||
|
||
|
||
class UomCategory(models.Model): | ||
_inherit = "uom.category" | ||
|
||
to_weigh = fields.Boolean("To weigh", default=False) | ||
|
||
@api.multi | ||
def action_recompute_to_weigh(self): | ||
for categ in self: | ||
domain = [("uom_id.category_id", "=", categ.id)] | ||
products = self.env["product.template"].search(domain) | ||
products.write({"to_weight": categ.to_weigh}) | ||
to_weight = fields.Boolean(string="To Weigh With Scale") |
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,14 +1,10 @@ | ||
* active settings "Allow using different units of measure" in Settings > Configuration > Sales > Quotations and Sales Orders > Product Features | ||
|
||
|
||
* During the creation of a category, tick the box 'To weigh'. | ||
* During the creation of a category, tick the box 'To Weigh With Scale'. | ||
|
||
.. image:: ../static/description/uom_categ_change_toweigh.png | ||
:alt: Change the field 'To weigh' for every category | ||
.. image:: ../static/description/uom_category_form.png | ||
:alt: Change the field 'To Weigh With Scale' for every weighable category | ||
:width: 400 | ||
|
||
* You can set every product existing with the new 'To weigh' parameter | ||
|
||
.. image:: ../static/description/uom_categ_button_toweigh.png | ||
:alt: Set 'to weigh' in each product of this category | ||
:width: 900 | ||
Note: During the installation, the UoM Category 'Weight' is checked. |
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,5 +1,5 @@ | ||
You're able to change this field for a specific product (in tab Sales). | ||
|
||
.. image:: ../static/description/uom_pos_change_toweigh.png | ||
:alt: Change the field 'to weigh' for a specific | ||
.. image:: ../static/description/product_form.png | ||
:alt: Change the field 'To Weigh With Scale' for a specific | ||
:width: 300 |
Binary file not shown.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-16.7 KB
pos_to_weight_by_product_uom/static/description/uom_categ_button_toweigh.png
Binary file not shown.
Binary file removed
BIN
-13.3 KB
pos_to_weight_by_product_uom/static/description/uom_categ_change_toweigh.png
Binary file not shown.
Binary file removed
BIN
-19.4 KB
pos_to_weight_by_product_uom/static/description/uom_categ_toweigh.png
Binary file not shown.
Binary file added
BIN
+54.7 KB
pos_to_weight_by_product_uom/static/description/uom_category_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-22.2 KB
pos_to_weight_by_product_uom/static/description/uom_change_toweigh.png
Binary file not shown.
Binary file removed
BIN
-9.89 KB
pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh.png
Binary file not shown.
Binary file removed
BIN
-10.1 KB
pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh_checked.png
Binary file not shown.
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 @@ | ||
from . import test_module |
Oops, something went wrong.