Skip to content

Commit

Permalink
[IMP] product_print_category : Add product print category rule to hav…
Browse files Browse the repository at this point in the history
…e better default print category values.

[REM] remove default_print_category on res.company model
  • Loading branch information
legalsylvain committed Jan 18, 2023
1 parent b551918 commit 897fd4c
Show file tree
Hide file tree
Showing 20 changed files with 331 additions and 87 deletions.
6 changes: 4 additions & 2 deletions product_print_category/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "Product - Print Categories",
"summary": "Define print categories for products"
"and automate products print, when data has changed",
"version": "16.0.1.0.1",
"version": "16.0.1.0.2",
"category": "Product",
"license": "AGPL-3",
"website": "https://github.com/OCA/product-attribute",
Expand All @@ -26,20 +26,22 @@
"demo/res_groups.xml",
"demo/qweb_template.xml",
"demo/product_print_category.xml",
"demo/product_print_category_rule.xml",
"demo/product_product.xml",
],
"data": [
"security/ir_module_category.xml",
"security/res_groups.xml",
"security/ir_rule.xml",
"security/ir.model.access.csv",
"data/report_paperformat.xml",
"report/report_pricetag.xml",
"report/ir_actions_report.xml",
"wizard/view_product_print_wizard.xml",
"views/view_product_product.xml",
"views/view_product_template.xml",
"views/view_res_company.xml",
"views/view_product_print_category.xml",
"views/view_product_print_category_rule.xml",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions product_print_category/demo/product_print_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

<record model="product.print.category" id="demo_category_1">
<field name="name">Demo Category 1</field>
<field name="company_id" eval="False" />
<field
name="product_ids"
eval="[(4, ref('product.product_product_4')),(4, ref('product.product_product_5'))]"
Expand All @@ -21,6 +22,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

<record model="product.print.category" id="demo_category_2">
<field name="name">Demo Category 2</field>
<field name="company_id" eval="False" />
<field name="product_ids" eval="[(4, ref('product.product_product_3'))]" />
<field name="qweb_view_id" ref="qweb_template_demo_2" />
<field
Expand Down
31 changes: 31 additions & 0 deletions product_print_category/demo/product_print_category_rule.xml
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>
79 changes: 49 additions & 30 deletions product_print_category/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-24 20:15+0000\n"
"PO-Revision-Date: 2022-10-24 20:15+0000\n"
"POT-Creation-Date: 2023-01-18 16:49+0000\n"
"PO-Revision-Date: 2023-01-18 16:49+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -57,35 +57,28 @@ msgstr "Actif"
msgid "Cancel"
msgstr "Annuler"

#. module: product_print_category
#: model:ir.model,name:product_print_category.model_res_company
msgid "Companies"
msgstr "Sociétés"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__company_id
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__company_id
msgid "Company"
msgstr "Société"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__create_uid
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__create_uid
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard__create_uid
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__create_uid
msgid "Created by"
msgstr "Créé par"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__create_date
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__create_date
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard__create_date
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__create_date
msgid "Created on"
msgstr "Créé le"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_res_company__print_category_id
msgid "Default Print Category"
msgstr "Catégorie d'impression par défaut"

#. module: product_print_category
#: model:product.print.category,name:product_print_category.demo_category_1
msgid "Demo Category 1"
Expand All @@ -97,19 +90,18 @@ msgid "Demo Category 2"
msgstr "Catégorie 2"

#. module: product_print_category
#: model:product.product,name:product_print_category.demo_product_1
#: model:product.template,name:product_print_category.demo_product_1_product_template
msgid "Demo Product With Print category 1"
msgstr "Article de démo avec catégorie 1"

#. module: product_print_category
#: model:product.product,name:product_print_category.demo_product_2
#: model:product.template,name:product_print_category.demo_product_2_product_template
msgid "Demo Product With Print category 2"
msgstr "Article de démo avec catégorie 2"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__display_name
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__display_name
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard__display_name
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__display_name
msgid "Display Name"
Expand All @@ -122,27 +114,31 @@ msgstr "Champs déclenchant l'impression"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__id
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__id
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard__id
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__id
msgid "ID"
msgstr ""

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category____last_update
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule____last_update
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard____last_update
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__write_uid
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__write_uid
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard__write_uid
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__write_date
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__write_date
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard__write_date
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__write_date
msgid "Last Updated on"
Expand All @@ -153,13 +149,19 @@ msgstr "Dernière mise à jour le"
msgid "Lines"
msgstr "Lignes"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__main_category_id
msgid "Main Category"
msgstr "Catégorie principale"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__name
#: model_terms:ir.ui.view,arch_db:product_print_category.view_product_print_category_form_2
msgid "Name"
msgstr "Nom"

#. module: product_print_category
#. odoo-python
#: code:addons/product_print_category/wizard/product_print_wizard.py:0
#, python-format
msgid ""
Expand Down Expand Up @@ -199,6 +201,7 @@ msgid "Print Categories"
msgstr "Catégories d'impression"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__print_category_id
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__print_category_id
#: model:ir.model.fields,field_description:product_print_category.field_product_product__print_category_id
#: model:ir.model.fields,field_description:product_print_category.field_product_template__print_category_id
Expand All @@ -210,6 +213,17 @@ msgstr "Catégorie d'impression"
msgid "Print Category Manager"
msgstr "Responsable de catégorie d'impression"

#. module: product_print_category
#: model:ir.actions.act_window,name:product_print_category.action_product_print_category_rule
#: model:ir.ui.menu,name:product_print_category.menu_product_print_category_rule
msgid "Print Category Rules"
msgstr "Règles de catégorie d'impression"

#. module: product_print_category
#: model:ir.model,name:product_print_category.model_product_print_category_rule
msgid "Print Category Rules for Product"
msgstr "Règles de catégorie d'impression pour les produits"

#. module: product_print_category
#: model:res.groups,name:product_print_category.user
msgid "Print Category User"
Expand Down Expand Up @@ -237,25 +251,24 @@ msgstr "Imprimer les articles"
msgid "Print category name"
msgstr "Nom de la catégorie d'impression"

#. module: product_print_category
#: model_terms:ir.ui.view,arch_db:product_print_category.view_product_product_form
#: model_terms:ir.ui.view,arch_db:product_print_category.view_product_template_only_form
msgid "Print options"
msgstr "Options d'impression"

#. module: product_print_category
#: model_terms:ir.ui.view,arch_db:product_print_category.view_product_template_only_form
msgid "Print options should be configured on Product Variants"
msgstr ""
"Les options d'impression doivent être configurées au niveau de la variante "
"d'article"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category_rule__sequence
msgid "Priority"
msgstr "Priorité"

#. module: product_print_category
#: model:ir.model,name:product_print_category.model_product_template
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__product_ids
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__product_id
msgid "Product"
msgstr "Article"
msgstr "Produit"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__product_to_print_ids
Expand All @@ -265,7 +278,7 @@ msgstr "Article à réimprimer"
#. module: product_print_category
#: model:ir.model,name:product_print_category.model_product_product
msgid "Product Variant"
msgstr "Variante d'article"
msgstr "Variante de produit"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_category__product_qty
Expand All @@ -287,20 +300,26 @@ msgstr "Quantité"
msgid "Qweb View"
msgstr "Vue Qweb"

#. module: product_print_category
#: model:ir.model.fields,help:product_print_category.field_product_print_category_rule__company_id
msgid "Restrict the access of this rule to the given company"
msgstr "Restreindre l'accès à cette règle à la société définie."

#. module: product_print_category
#: model:ir.model.fields,help:product_print_category.field_product_print_category_rule__main_category_id
msgid ""
"This rule will be applied only to products that belong to the given "
"category, or to its children."
msgstr ""
"Cette règle sera appliqué seulement aux articles qui appartiennent"
" à la catégorie définie, ou aux catégories enfants."

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_product__to_print
#: model:ir.model.fields,field_description:product_print_category.field_product_template__to_print
msgid "To Print"
msgstr "À imprimer"

#. module: product_print_category
#: model:product.product,uom_name:product_print_category.demo_product_1
#: model:product.product,uom_name:product_print_category.demo_product_2
#: model:product.template,uom_name:product_print_category.demo_product_1_product_template
#: model:product.template,uom_name:product_print_category.demo_product_2_product_template
msgid "Units"
msgstr "Unités"

#. module: product_print_category
#: model:ir.model.fields,field_description:product_print_category.field_product_print_wizard_line__wizard_id
msgid "Wizard"
Expand Down
37 changes: 37 additions & 0 deletions product_print_category/migrations/16.0.1.0.2/post-migration.py
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 product_print_category/migrations/16.0.1.0.2/pre-migration.py
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)
2 changes: 1 addition & 1 deletion product_print_category/models/__init__.py
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
Loading

0 comments on commit 897fd4c

Please sign in to comment.