Skip to content

Commit

Permalink
[MIG] report_qweb_operating_unit: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdidderen-nsi committed Jul 8, 2024
1 parent 3711010 commit 5708d4f
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 269 deletions.
1 change: 1 addition & 0 deletions report_qweb_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
4 changes: 2 additions & 2 deletions report_qweb_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

{
"name": "Qweb Report With Operating Unit",
"version": "14.0.1.1.0",
"version": "17.0.1.0.0",
"category": "Reports/Qweb",
"license": "LGPL-3",
"author": "ForgeFlow S.L., "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/operating-unit",
"depends": ["operating_unit"],
"data": ["views/report_qweb_operating_unit.xml"],
"data": ["views/operating_unit_view.xml", "views/report_qweb_operating_unit.xml"],
"installable": True,
}
1 change: 1 addition & 0 deletions report_qweb_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import operating_unit
67 changes: 67 additions & 0 deletions report_qweb_operating_unit/models/operating_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright 2024 NSI-SA
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, fields, models
from odoo.tools import html2plaintext


class OperatingUnit(models.Model):
_inherit = "operating.unit"

report_header = fields.Html(
string="Operating Unit Tagline",
translate=True,
compute="_compute_report_header",
store=True,
readonly=False,
help="Operating Unit tagline, which is included "
"in a printed document's header or footer "
"(depending on the selected layout).",
)
report_footer = fields.Html(
translate=True,
compute="_compute_report_footer",
store=True,
readonly=False,
help="Footer text displayed at the bottom of all reports.",
)
operating_unit_details = fields.Html(
translate=True,
compute="_compute_operating_unit_details",
store=True,
readonly=False,
help="Header text displayed at the top of all reports.",
)
is_operating_unit_details_empty = fields.Boolean(
compute="_compute_empty_operating_unit_details"
)

@api.depends("company_id")
def _compute_report_header(self):
for operating_unit in self:
if operating_unit.company_id:
operating_unit.report_header = operating_unit.company_id.report_header

@api.depends("company_id")
def _compute_report_footer(self):
for operating_unit in self:
if operating_unit.company_id:
operating_unit.report_footer = operating_unit.company_id.report_footer

@api.depends("company_id")
def _compute_operating_unit_details(self):
for operating_unit in self:
if operating_unit.company_id:
operating_unit.operating_unit_details = (
operating_unit.company_id.company_details
)

@api.depends("operating_unit_details")
def _compute_empty_operating_unit_details(self):
# In recent change when an html field is
# empty a <p> balise remains with a <br> in it,
# but when operating unit details is empty
# we want to put the info of the operating unit
for operating_unit in self:
operating_unit.is_operating_unit_details_empty = not html2plaintext(

Check warning on line 65 in report_qweb_operating_unit/models/operating_unit.py

View check run for this annotation

Codecov / codecov/patch

report_qweb_operating_unit/models/operating_unit.py#L65

Added line #L65 was not covered by tests
operating_unit.operating_unit_details or ""
)
21 changes: 21 additions & 0 deletions report_qweb_operating_unit/views/operating_unit_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_operating_unit_form" model="ir.ui.view">
<field name="name">operating.unit.form</field>
<field name="model">operating.unit</field>
<field name="inherit_id" ref="operating_unit.view_operating_unit_form" />
<field name="arch" type="xml">
<form position="inside">
<notebook>
<page string="Report Layout">
<group>
<field name="report_header" />
<field name="report_footer" />
<field name="operating_unit_details" />
</group>
</page>
</notebook>
</form>
</field>
</record>
</odoo>
Loading

0 comments on commit 5708d4f

Please sign in to comment.