diff --git a/report_label/__manifest__.py b/report_label/__manifest__.py
index 2bc2229cc..c844760d9 100644
--- a/report_label/__manifest__.py
+++ b/report_label/__manifest__.py
@@ -1,7 +1,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Report Labels",
- "version": "14.0.1.0.0",
+ "version": "16.0.1.0.0",
"summary": "Print configurable self-adhesive labels reports",
"author": "Iván Todorovich, Moka Tourisme, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
@@ -13,7 +13,6 @@
],
"data": [
"security/ir.model.access.csv",
- "data/paperformat_label.xml",
"views/ir_actions_server.xml",
"views/report_paperformat_label.xml",
"reports/report_label.xml",
diff --git a/report_label/data/paperformat_label.xml b/report_label/data/paperformat_label.xml
deleted file mode 100644
index 7da0a7058..000000000
--- a/report_label/data/paperformat_label.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
- Label: Agipa 114016
- A5
- Portrait
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/report_label/demo/demo.xml b/report_label/demo/demo.xml
index ea2263707..4ee42635c 100644
--- a/report_label/demo/demo.xml
+++ b/report_label/demo/demo.xml
@@ -8,18 +8,36 @@
/>
+
+ Paperformat for labels (A4: 210mm x 297mm)
+ A4
+ 96
+ Portrait
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+
- Partner Label
- A4
-
-
+ Partner Labels (3 x 6 = 18 labels per sheet)
+
+
+
+
+
+
+
+ #729fcf
@@ -30,7 +48,10 @@
name="label_paperformat_id"
ref="report_paperformat_label_partner_address"
/>
- report_label.label_template_partner_address
+
diff --git a/report_label/i18n/report_label.pot b/report_label/i18n/report_label.pot
index 18f6e6279..38bd2f833 100644
--- a/report_label/i18n/report_label.pot
+++ b/report_label/i18n/report_label.pot
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * report_label
+# * report_label
#
msgid ""
msgstr ""
diff --git a/report_label/migrations/16.0.1.0.0/pre-migration.py b/report_label/migrations/16.0.1.0.0/pre-migration.py
new file mode 100644
index 000000000..9798d530c
--- /dev/null
+++ b/report_label/migrations/16.0.1.0.0/pre-migration.py
@@ -0,0 +1,40 @@
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from openupgradelib import openupgrade
+
+from odoo.tools.sql import column_exists
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ if not column_exists(env.cr, "base_comment_template", "models"):
+ openupgrade.logged_query(
+ env.cr,
+ "ALTER TABLE report_paperformat_label ADD COLUMN name char",
+ )
+ openupgrade.logged_query(
+ env.cr,
+ """
+ UPDATE report_paperformat_label rpfl
+ SET name = rpf.name
+ FROM report_paperformat rpf
+ WHERE rpfl.name is null
+ AND rpfl.paperformat_id = rpf.id;
+ """,
+ )
+
+ if not column_exists(env.cr, "ir_act_server", "label_template_view_id"):
+ openupgrade.logged_query(
+ env.cr,
+ "ALTER TABLE ir_act_server ADD COLUMN label_template_view_id integer;",
+ )
+ openupgrade.logged_query(
+ env.cr,
+ """
+ UPDATE ir_act_server ias
+ SET label_template_view_id = iuv.id
+ FROM ir_ui_view iuv
+ WHERE ias.label_template is not null
+ AND iuv.key = ias.label_template;
+ """,
+ )
diff --git a/report_label/models/ir_actions_server.py b/report_label/models/ir_actions_server.py
index ff030fa98..cd586ffb3 100644
--- a/report_label/models/ir_actions_server.py
+++ b/report_label/models/ir_actions_server.py
@@ -9,8 +9,10 @@ class IrActionsServer(models.Model):
selection_add=[("report_label", "Print self-adhesive labels")],
ondelete={"report_label": "cascade"},
)
- label_template = fields.Char(
- "Label QWeb Template",
+ label_template_view_id = fields.Many2one(
+ string="Label QWeb Template",
+ comodel_name="ir.ui.view",
+ domain=[("type", "=", "qweb")],
help="The QWeb template key to render the labels",
states={"report_label": [("required", True)]},
)
@@ -20,27 +22,12 @@ class IrActionsServer(models.Model):
states={"report_label": [("required", True)]},
)
- def report_label_associated_view(self):
- """View the associated qweb templates"""
- self.ensure_one()
- action = self.env.ref("base.action_ui_view", raise_if_not_found=False)
- if not action or len(self.label_template.split(".")) < 2:
- return False
- res = action.read()[0]
- res["domain"] = [
- ("type", "=", "qweb"),
- "|",
- ("name", "ilike", self.label_template.split(".")[1]),
- ("key", "=", self.label_template),
- ]
- return res
-
def _run_action_report_label_multi(self, eval_context=None):
"""Show report label wizard"""
context = dict(self.env.context)
context.update(
{
- "label_template": self.label_template,
+ "label_template_view_id": self.label_template_view_id.id,
"label_paperformat_id": self.label_paperformat_id.id,
"res_model_id": self.model_id.id,
}
diff --git a/report_label/models/report_paperformat_label.py b/report_label/models/report_paperformat_label.py
index 7c2afb19a..f5c118d1b 100644
--- a/report_label/models/report_paperformat_label.py
+++ b/report_label/models/report_paperformat_label.py
@@ -3,9 +3,10 @@ from odoo import fields, models
class ReportPaperformatLabel(models.Model):
_name = "report.paperformat.label"
- _inherits = {"report.paperformat": "paperformat_id"}
_description = "Label Paper Format"
+ name = fields.Char(required=True)
+
paperformat_id = fields.Many2one(
"report.paperformat",
string="Paper Format",
@@ -22,6 +23,7 @@ class ReportPaperformatLabel(models.Model):
default=42.3,
required=True,
)
+ label_background_color = fields.Char(default="#FFFFFF")
label_padding_top = fields.Float("Label Padding Top (mm)", default=2)
label_padding_right = fields.Float("Label Padding Right (mm)", default=2)
label_padding_bottom = fields.Float("Label Padding Bottom (mm)", default=2)
@@ -30,9 +32,3 @@ class ReportPaperformatLabel(models.Model):
label_margin_right = fields.Float("Label Margin Right (mm)", default=2)
label_margin_bottom = fields.Float("Label Margin Bottom (mm)", default=2)
label_margin_left = fields.Float("Label Margin Left (mm)", default=2)
-
- # Overload inherits defaults
- orientation = fields.Selection(inherited=True, default="Portrait")
- header_spacing = fields.Integer(inherited=True, default=0)
- margin_top = fields.Float(inherited=True, default=7)
- margin_bottom = fields.Float(inherited=True, default=7)
diff --git a/report_label/readme/CONFIGURE.rst b/report_label/readme/CONFIGURE.rst
index 2d61181f4..2bdf357ba 100644
--- a/report_label/readme/CONFIGURE.rst
+++ b/report_label/readme/CONFIGURE.rst
@@ -1,10 +1,27 @@
-Go to **Settings > Technical > Analysis > Label Paper Format** and create
-your self-adhesive label paper formats.
+**Configure your Report Label Paperformat**
-.. image:: ../static/description/configure_paperformat.png
+* Go to "Settings > Technical > Reporting > Label Paper Format"
-Go to **Settings > Technical > Analysis > Label Report** and create your label
-report, and its context action. You'll also need to create or reuse a
-QWeb template for you label.
+* Create your self-adhesive label paper formats.
-.. image:: ../static/description/configure_report_label.png
+You should reuse or create a Paperformat.
+
+.. image:: ../static/description/report_paperformat_label_form.png
+
+**Configure your Server action**
+
+* Go to "Settings > Technical > Actions > Server Actions"
+
+Create your label report :
+
+* In the 'Action to do' field, select 'Print Self-adhesive Labels'
+
+* In the 'Label Paper Format' field, select your label paper format previously created
+
+* In the 'Label Qweb Template' create or reuse a QWeb template for your label.
+
+.. image:: ../static/description/ir_actions_server.png
+
+**Importante Note**
+
+`By design `_, the variable used in this QWeb template must be named `record`.
diff --git a/report_label/readme/ROADMAP.rst b/report_label/readme/ROADMAP.rst
index 893687abe..d504aaac0 100644
--- a/report_label/readme/ROADMAP.rst
+++ b/report_label/readme/ROADMAP.rst
@@ -1,10 +1,12 @@
Known issues:
-* `wkhtmltopdf` doesn't always respect dpi, and mm measures don't match. For
- this matter, it's recommended to use this module along with
- `report_wkhtmltopdf_param` and enable `--disable-smart-shrinking`.
-
* This module depends on `base_automation` only because this module extends
`ir.actions.server` with a new kind of action, and `base.automation` inherits
from `ir.actions.server` by delegation in such a way that the modules cannot
be loaded in another order.
+ To do when migrating in version > 16 :
+ 1. remove ``base_automation`` dependency
+ 2. install ``report_label``
+ 3. install then ``base_automation``.
+ If the installation of ``base_automation`` works, the dependency can be
+ replaced by ``base``.
diff --git a/report_label/readme/USAGE.rst b/report_label/readme/USAGE.rst
index 72b0c113a..91f9ca7ff 100644
--- a/report_label/readme/USAGE.rst
+++ b/report_label/readme/USAGE.rst
@@ -1,5 +1,11 @@
-1. In the target model's tree view, select the records to print.
-2. Click *Action* and your label report action name.
-3. Select the number of labels per record to print, and click Print.
+* In the target model's tree view, select the records to print.
+* Click *Action* and your label report action name.
+* Select the number of labels per record to print, and click Print.
-.. image:: ../static/description/label_wizard.png
+you can optionaly define an offset
+
+.. image:: ../static/description/report_label_wizard_form.png
+
+The items will be printed in a pdf document.
+
+.. image:: ../static/description/report_result.png
diff --git a/report_label/reports/report_label.xml b/report_label/reports/report_label.xml
index 5c62bdb79..bd7231fb5 100644
--- a/report_label/reports/report_label.xml
+++ b/report_label/reports/report_label.xml
@@ -2,33 +2,41 @@
-
-
-
- height: mm;
- width: mm;
- padding-top: mm;
- padding-right: mm;
- padding-bottom: mm;
- padding-left: mm;
- margin-top: mm;
- margin-right: mm;
- margin-bottom: mm;
- margin-left: mm;
- display: inline-block;
- overflow: hidden;
- float: left;
- position: relative;
- page-break-inside: avoid;
- box-sizing: border-box;
-
+
+
+
+
-
+
-
+
ir.actions.server
-
-
- Label Reports
- ir.actions.server
- tree,form
- [("state", "=", "report_label")]
- {"default_state": "report_label"}
-
-
-
-
diff --git a/report_label/views/report_paperformat_label.xml b/report_label/views/report_paperformat_label.xml
index e31d4391c..55d2d69c4 100644
--- a/report_label/views/report_paperformat_label.xml
+++ b/report_label/views/report_paperformat_label.xml
@@ -1,50 +1,49 @@
-
+
report.paperformat.label
-
- primary
-
-
- 1
-
-
- 1
-
-
- 1
-
-
-
-
-
-
-
+
+
report.paperformat.label
-
+
+
diff --git a/report_label/wizards/__init__.py b/report_label/wizards/__init__.py
index c7b605c91..622f18814 100644
--- a/report_label/wizards/__init__.py
+++ b/report_label/wizards/__init__.py
@@ -1 +1,2 @@
from . import report_label_wizard
+from . import report_label_wizard_line
diff --git a/report_label/wizards/report_label_wizard.py b/report_label/wizards/report_label_wizard.py
index 9e4a371c3..0f96a4008 100644
--- a/report_label/wizards/report_label_wizard.py
+++ b/report_label/wizards/report_label_wizard.py
@@ -38,11 +38,13 @@ class ReportLabelWizard(models.TransientModel):
required=True,
default=lambda self: self.env.context.get("label_paperformat_id"),
)
- label_template = fields.Char(
- "Label QWeb Template",
+
+ label_template_view_id = fields.Many2one(
+ string="Label QWeb Template",
+ comodel_name="ir.ui.view",
readonly=True,
required=True,
- default=lambda self: self.env.context.get("label_template"),
+ default=lambda self: self.env.context.get("label_template_view_id"),
)
offset = fields.Integer(
help="Number of labels to skip when printing",
@@ -59,7 +61,7 @@ class ReportLabelWizard(models.TransientModel):
self.ensure_one()
return {
"label_format": self.label_paperformat_id.read()[0],
- "label_template": self.label_template,
+ "label_template": self.label_template_view_id.key,
"offset": self.offset,
"res_model": self.model_id.model,
"lines": [
@@ -79,30 +81,3 @@ class ReportLabelWizard(models.TransientModel):
"paperformat_id": self.label_paperformat_id.paperformat_id.id,
}
return action
-
-
-class ReportLabelWizardLine(models.TransientModel):
- _name = "report.label.wizard.line"
- _description = "Report Label Wizard Line"
- _order = "sequence"
-
- wizard_id = fields.Many2one(
- "report.label.wizard",
- "Wizard",
- required=True,
- ondelete="cascade",
- )
- sequence = fields.Integer(default=10)
- res_id = fields.Integer("Resource ID", required=True)
- res_name = fields.Char(compute="_compute_res_name")
- quantity = fields.Integer(default=1, required=True)
-
- @api.depends("wizard_id.model_id", "res_id")
- def _compute_res_name(self):
- wizard = self.mapped("wizard_id")
- wizard.ensure_one()
- res_model = wizard.model_id.model
- res_ids = self.mapped("res_id")
- names_map = dict(self.env[res_model].browse(res_ids).name_get())
- for rec in self:
- rec.res_name = names_map.get(rec.res_id)
diff --git a/report_label/wizards/report_label_wizard.xml b/report_label/wizards/report_label_wizard.xml
index c6db5895b..f4acb1f00 100644
--- a/report_label/wizards/report_label_wizard.xml
+++ b/report_label/wizards/report_label_wizard.xml
@@ -21,7 +21,7 @@
-
+
diff --git a/report_label/wizards/report_label_wizard_line.py b/report_label/wizards/report_label_wizard_line.py
new file mode 100644
index 000000000..aad39f9fe
--- /dev/null
+++ b/report_label/wizards/report_label_wizard_line.py
@@ -0,0 +1,29 @@
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from odoo import api, fields, models
+
+
+class ReportLabelWizardLine(models.TransientModel):
+ _name = "report.label.wizard.line"
+ _description = "Report Label Wizard Line"
+ _order = "sequence"
+
+ wizard_id = fields.Many2one(
+ "report.label.wizard",
+ "Wizard",
+ required=True,
+ ondelete="cascade",
+ )
+ sequence = fields.Integer(default=10)
+ res_id = fields.Integer("Resource ID", required=True)
+ res_name = fields.Char(compute="_compute_res_name")
+ quantity = fields.Integer(default=1, required=True)
+
+ @api.depends("wizard_id.model_id", "res_id")
+ def _compute_res_name(self):
+ wizard = self.mapped("wizard_id")
+ wizard.ensure_one()
+ res_model = wizard.model_id.model
+ res_ids = self.mapped("res_id")
+ names_map = dict(self.env[res_model].browse(res_ids).name_get())
+ for rec in self:
+ rec.res_name = names_map.get(rec.res_id)