forked from OCA/product-attribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] product_print_category : Add product print category rule to hav…
…e better default print category values. [REM] remove default_print_category on res.company model
- Loading branch information
1 parent
b551918
commit 897fd4c
Showing
20 changed files
with
331 additions
and
87 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
31 changes: 31 additions & 0 deletions
31
product_print_category/demo/product_print_category_rule.xml
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,31 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
Copyright (C) 2023-Today: GRAP (<http://www.grap.coop>) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
<record model="product.print.category.rule" id="demo_rule_1"> | ||
<field name="sequence">1</field> | ||
<field name="company_id" eval="False" /> | ||
<field name="main_category_id" ref="product.product_category_1" /> | ||
<field name="print_category_id" ref="demo_category_1" /> | ||
</record> | ||
|
||
<record model="product.print.category.rule" id="demo_rule_2"> | ||
<field name="sequence">2</field> | ||
<field name="company_id" eval="False" /> | ||
<field name="main_category_id" ref="product.product_category_consumable" /> | ||
<field name="print_category_id" ref="demo_category_2" /> | ||
</record> | ||
|
||
<record model="product.print.category.rule" id="demo_rule_general"> | ||
<field name="sequence">100</field> | ||
<field name="company_id" eval="False" /> | ||
<field name="main_category_id" ref="product.product_category_all" /> | ||
<field name="print_category_id" eval="False" /> | ||
</record> | ||
|
||
|
||
</odoo> |
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
37 changes: 37 additions & 0 deletions
37
product_print_category/migrations/16.0.1.0.2/post-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,37 @@ | ||
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
|
||
from openupgradelib import openupgrade | ||
from psycopg2.extensions import AsIs | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
logger.info( | ||
"Create product.print.category.rule based on " | ||
"print_category_id on res.company field ..." | ||
) | ||
old_column = AsIs(openupgrade.get_legacy_name("print_category_id")) | ||
env.cr.execute( | ||
""" | ||
SELECT id, %s | ||
FROM res_company | ||
WHERE %s is not null; | ||
""", | ||
(old_column, old_column), | ||
) | ||
i = 0 | ||
for row in env.cr.fetchall(): | ||
i += 1 | ||
vals = { | ||
"sequence": i, | ||
"main_category_id": False, | ||
"print_category_id": row[1], | ||
"company_id": row[0], | ||
} | ||
env["product.print.category.rule"].create(vals) |
22 changes: 22 additions & 0 deletions
22
product_print_category/migrations/16.0.1.0.2/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,22 @@ | ||
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
|
||
from openupgradelib import openupgrade | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
column_renames = { | ||
"res_company": [ | ||
("print_category_id", None), | ||
], | ||
} | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
logger.info("Preserve default print_category_id on res.company field ...") | ||
openupgrade.rename_columns(env.cr, column_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from . import res_company | ||
from . import product_print_category | ||
from . import product_print_category_mixin | ||
from . import product_print_category_rule | ||
from . import product_product | ||
from . import product_template |
Oops, something went wrong.