diff --git a/report_layout_config/README.rst b/report_layout_config/README.rst new file mode 100644 index 000000000..164a0b9ac --- /dev/null +++ b/report_layout_config/README.rst @@ -0,0 +1,82 @@ +=========================== +Report layout configuration +=========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github + :target: https://github.com/OCA/reporting-engine/tree/13.0/report_layout_config + :alt: OCA/reporting-engine +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-report_layout_config + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/143/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module provides new report template. +With possibility to add image to replace header and footer. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* In Setting/General Setting/Business Documents: + * Click on Configure Document Layout + * On the wizard choose Layout images + * Set the `Full header image` + `Full footer image` + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Thomas Nowicki + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/reporting-engine `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/report_layout_config/__init__.py b/report_layout_config/__init__.py new file mode 100644 index 000000000..9a14fd06d --- /dev/null +++ b/report_layout_config/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/report_layout_config/__manifest__.py b/report_layout_config/__manifest__.py new file mode 100644 index 000000000..3d5e7cc26 --- /dev/null +++ b/report_layout_config/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Report layout configuration", + "summary": "Add possibility to easily modify the global report layout", + "version": "13.0.1.0.0", + "category": "Reporting", + "website": "http://github.com/OCA/reporting-engine", + "author": "Camptocamp, " "Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["web", "base"], + "data": [ + "views/document_layout.xml", + "templates/report_templates.xml", + "data/report_layout.xml", + ], + "application": False, + "installable": True, +} diff --git a/report_layout_config/data/report_layout.xml b/report_layout_config/data/report_layout.xml new file mode 100644 index 000000000..480a10408 --- /dev/null +++ b/report_layout_config/data/report_layout.xml @@ -0,0 +1,14 @@ + + + + Layout images + + /report_layout_config/static/img/preview_standard.png + /report_layout_config/static/pdf/preview_standard.pdf + + diff --git a/report_layout_config/models/__init__.py b/report_layout_config/models/__init__.py new file mode 100644 index 000000000..290c7e138 --- /dev/null +++ b/report_layout_config/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_company +from . import base_document_layout diff --git a/report_layout_config/models/base_document_layout.py b/report_layout_config/models/base_document_layout.py new file mode 100644 index 000000000..f2579cc77 --- /dev/null +++ b/report_layout_config/models/base_document_layout.py @@ -0,0 +1,46 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class BaseDocumentLayout(models.TransientModel): + _inherit = "base.document.layout" + + full_header_img = fields.Binary( + related="company_id.full_header_img", readonly=False + ) + full_footer_img = fields.Binary( + related="company_id.full_footer_img", readonly=False + ) + + need_images_layout = fields.Boolean( + compute="_compute_need_images_layout", readonly=True + ) + + @api.depends("report_layout_id") + def _compute_need_images_layout(self): + self.ensure_one() + img_lay = self.env.ref("report_layout_config.external_layout_images").view_id + self.need_images_layout = self.external_report_layout_id == img_lay + + @api.depends( + "report_layout_id", + "logo", + "font", + "primary_color", + "secondary_color", + "full_footer_img", + "full_header_img", + ) + def _compute_preview(self): + self.ensure_one() + if not self.need_images_layout or not self.report_layout_id: + super()._compute_preview() + else: + ir_qweb = self.env["ir.qweb"] + qweb_ctx = self.env["ir.ui.view"]._prepare_qcontext() + qweb_ctx.update({"company": self}) + self.preview = ir_qweb.render( + "report_layout_config.layout_preview", qweb_ctx + ) diff --git a/report_layout_config/models/res_company.py b/report_layout_config/models/res_company.py new file mode 100644 index 000000000..f2ff4f40b --- /dev/null +++ b/report_layout_config/models/res_company.py @@ -0,0 +1,19 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + full_header_img = fields.Binary( + string="Full header image", + help="This image will replace all header.", + attachment=True, + ) + full_footer_img = fields.Binary( + string="Full footer image", + help="This image will replace all footer.", + attachment=True, + ) diff --git a/report_layout_config/readme/CONTRIBUTORS.rst b/report_layout_config/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0a9139f76 --- /dev/null +++ b/report_layout_config/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Thomas Nowicki diff --git a/report_layout_config/readme/DESCRIPTION.rst b/report_layout_config/readme/DESCRIPTION.rst new file mode 100644 index 000000000..1283e67d0 --- /dev/null +++ b/report_layout_config/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module provides new report template +with possibility to add image to replace header and footer. diff --git a/report_layout_config/readme/USAGE.rst b/report_layout_config/readme/USAGE.rst new file mode 100644 index 000000000..32584e7b9 --- /dev/null +++ b/report_layout_config/readme/USAGE.rst @@ -0,0 +1,4 @@ +* In Setting/General Setting/Business Documents: + * Click on Configure Document Layout + * On the wizard choose Layout images + * Set the `Full header image` + `Full footer image` diff --git a/report_layout_config/static/description/index.html b/report_layout_config/static/description/index.html new file mode 100644 index 000000000..3a8cf5d4b --- /dev/null +++ b/report_layout_config/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Report layout configuration + + + +
+

Report layout configuration

+ + +

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runbot

+

This module provides new report template. +With possibility to add image to replace header and footer.

+

Table of contents

+ +
+

Usage

+
    +
  • +
    In Setting/General Setting/Business Documents:
    +
      +
    • Click on Configure Document Layout
    • +
    • On the wizard choose Layout images
    • +
    • Set the Full header image + Full footer image
    • +
    +
    +
    +
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/reporting-engine project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/report_layout_config/static/img/preview_standard.png b/report_layout_config/static/img/preview_standard.png new file mode 100644 index 000000000..0bd596ed9 Binary files /dev/null and b/report_layout_config/static/img/preview_standard.png differ diff --git a/report_layout_config/static/pdf/preview_standard.pdf b/report_layout_config/static/pdf/preview_standard.pdf new file mode 100644 index 000000000..4d5373768 Binary files /dev/null and b/report_layout_config/static/pdf/preview_standard.pdf differ diff --git a/report_layout_config/templates/report_templates.xml b/report_layout_config/templates/report_templates.xml new file mode 100644 index 000000000..e3f142b63 --- /dev/null +++ b/report_layout_config/templates/report_templates.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + diff --git a/report_layout_config/views/document_layout.xml b/report_layout_config/views/document_layout.xml new file mode 100644 index 000000000..07e4609d9 --- /dev/null +++ b/report_layout_config/views/document_layout.xml @@ -0,0 +1,53 @@ + + + + base.document.layout + base.document.layout + + + + {'invisible': [('need_images_layout', '=', True)]} + + + {'invisible': [('need_images_layout', '=', True)]} + + + {'invisible': [('need_images_layout', '=', True)]} + + + {'invisible': [('need_images_layout', '=', True)]} + + + {'invisible': [('need_images_layout', '=', True)]} + + + + + + + + max-width: 450px; + + + +