Skip to content

Commit ab17d35

Browse files
authored
Merge pull request #4095 from Tecnativa/15.0-ou-imp-web-TT44012
[15.0][OU-IMP] web: Auto-define company fields used in reports (report_footer + company_details)
2 parents aea370e + b2bbd22 commit ab17d35

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2023-2024 Tecnativa - Víctor Martínez
2+
from openupgradelib import openupgrade
3+
4+
5+
@openupgrade.migrate()
6+
def migrate(env, version):
7+
"""It is important to set the appropriate report_footer and company_details values.
8+
The report_footer field already existed before, but it only represented the 'extra'
9+
text that was added after the company data (https://github.com/odoo/odoo/blob/cc0060e889603eb2e47fa44a8a22a70d7d784185/addons/web/views/report_templates.xml#L367).
10+
Now in v15 this data https://github.com/odoo/odoo/blob/3a28e5b0adbb36bdb1155a6854cdfbe4e7f9b187/addons/web/views/report_templates.xml#L338
11+
is not shown unless it is defined; therefore, we must apply the corresponding
12+
default that would be defined from the base.document.layout wizard and then add the
13+
old report_footer data (if it was defined).
14+
There is now a company_details field that does not have a default value, so it will
15+
be created empty.
16+
It is important to define the corresponding value that would be defined from the
17+
base.document.layout wizard because in the report now only the content of that
18+
field is shown, while in v14 it was not necessary since the address was shown
19+
according to the partner_id field.
20+
v14 https://github.com/odoo/odoo/blob/cc0060e889603eb2e47fa44a8a22a70d7d784185/addons/web/views/report_templates.xml#L343
21+
vs v15 https://github.com/odoo/odoo/blob/3a28e5b0adbb36bdb1155a6854cdfbe4e7f9b187/addons/web/views/report_templates.xml#L319
22+
""" # noqa: B950
23+
for company in env["res.company"].search([]):
24+
wizard = env["base.document.layout"].with_company(company).create({})
25+
report_footer = wizard.report_footer
26+
if company.report_footer:
27+
report_footer += company.report_footer
28+
company.write(
29+
{
30+
"report_footer": report_footer,
31+
"company_details": wizard.company_details,
32+
}
33+
)

0 commit comments

Comments
 (0)