-
-
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. - IMP : hook, to initialize 'Weight' UoM Category, and check 'to_weight' on all related product templates - REF : Rename 'to_weigh' field into 'to_weight' field, to match odoo nomenclature. - UPD : readme and screenshots
- Loading branch information
1 parent
cd346b2
commit 42d8196
Showing
31 changed files
with
233 additions
and
220 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 uom_category.to_weight = True; | ||
""" | ||
) |
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,60 +1,42 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * pos_to_weight_by_product_uom | ||
# * pos_to_weight_by_product_uom | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-11-13 12:19+0000\n" | ||
"PO-Revision-Date: 2017-11-13 12:19+0000\n" | ||
"Last-Translator: <>\n" | ||
"POT-Creation-Date: 2024-01-12 22:44+0000\n" | ||
"PO-Revision-Date: 2024-01-12 22:44+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:uom.category,name:pos_to_weight_by_product_uom.uom_category_to_weigh | ||
msgid "Demo - New Category To Weigh" | ||
msgstr "Demo - Nouvelle Catégorie à peser" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:uom.uom,name:pos_to_weight_by_product_uom.uom_uom_to_weigh | ||
msgid "Demo - New Uom To Weigh" | ||
msgstr "Demo - Nouvelle UdM à peser" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:ir.model,name:pos_to_weight_by_product_uom.model_product_product | ||
#, fuzzy | ||
msgid "Product" | ||
msgstr "Modèle d'article" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:ir.model,name:pos_to_weight_by_product_uom.model_product_template | ||
msgid "Product Template" | ||
msgstr "Modèle d'article" | ||
msgid "Product" | ||
msgstr "Produit" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:ir.model,name:pos_to_weight_by_product_uom.model_uom_uom | ||
msgid "Product Unit of Measure" | ||
msgstr "Unité de mesure d'article" | ||
msgstr "Unité de mesure du produit" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:ir.model,name:pos_to_weight_by_product_uom.model_uom_category | ||
#, fuzzy | ||
msgid "Product UoM Categories" | ||
msgstr "Catégorie d'UdM d'article" | ||
msgstr "Catégorie d'UdM" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model_terms:ir.ui.view,arch_db:pos_to_weight_by_product_uom.view_uom_category_form | ||
msgid "Set 'to weigh' in each product of this category" | ||
msgstr "" | ||
#: model:ir.model,name:pos_to_weight_by_product_uom.model_product_product | ||
msgid "Product Variant" | ||
msgstr "Variante de produit" | ||
|
||
#. module: pos_to_weight_by_product_uom | ||
#: model:ir.model.fields,field_description:pos_to_weight_by_product_uom.field_uom_category__to_weigh | ||
#: model:ir.model.fields,field_description:pos_to_weight_by_product_uom.field_uom_uom__to_weigh | ||
msgid "To weigh" | ||
msgstr "À peser" | ||
#: model:ir.model.fields,field_description:pos_to_weight_by_product_uom.field_uom_category__to_weight | ||
#: model:ir.model.fields,field_description:pos_to_weight_by_product_uom.field_uom_uom__to_weight | ||
msgid "To Weigh With Scale" | ||
msgstr "À peser avec une balance" |
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
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
Oops, something went wrong.