Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] report_alternative_layout #45

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions report_alternative_layout/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
=========================
Report Alternative Layout
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5a3fe7bbd54c21e4512d1ffef2b0a861be8d0e954303fcd276135bd8bc18a562
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fl10n--japan-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-japan/tree/16.0/report_alternative_layout
:alt: OCA/l10n-japan
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-japan-16-0/l10n-japan-16-0-report_alternative_layout
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-japan&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module introduces an alternative layout for QWeb reports with the following
adjustments to existing external layouts:

- Displays the partner's address on the left side first, followed by the company's
address on the right side.
- Uses the commercial partner's address in place of the partner's address.

Currently, these adjustments are only supported for the standard external layout
(`external_layout_standard`).

**Table of contents**

.. contents::
:local:

Configuration
=============

Go to *Settings > Technical > Reporting > Reports*, and open a report of your choice, and
update the following fields as necessary.

- Apply Alternative Layout: If selected, the alternative layout will be applied in the
printed report.
- Paper Format: Select 'A4 - no company address in header' if 'Apply Alternative Layout' is selected.
- Show Commercial Partner: If selected, the commercial partner of the document partner
will show in the report output (instead of the document partner).

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-japan/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-japan/issues/new?body=module:%20report_alternative_layout%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Quartile

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/l10n-japan <https://github.com/OCA/l10n-japan/tree/16.0/report_alternative_layout>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions report_alternative_layout/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions report_alternative_layout/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Quartile
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Report Alternative Layout",
"version": "16.0.1.0.0",
"category": "Reporting",
"license": "AGPL-3",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-japan",
"depends": ["base"],
"data": [
"data/report_paperformat_data.xml",
"report/report_template.xml",
"views/ir_actions_report_views.xml",
],
"installable": True,
}
17 changes: 17 additions & 0 deletions report_alternative_layout/data/report_paperformat_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="report_paperformat_a4_alt" model="report.paperformat">
<field name="name">A4 - no company address in header</field>
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">15</field>
<field name="margin_bottom">28</field>
<field name="margin_left">7</field>
<field name="margin_right">7</field>
<field name="header_line" eval="False" />
<field name="header_spacing">12</field>
<field name="dpi">100</field>
</record>
</odoo>
44 changes: 44 additions & 0 deletions report_alternative_layout/i18n/ja.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_alternative_layout
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-24 04:09+0000\n"
"PO-Revision-Date: 2024-10-24 04:09+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: report_alternative_layout
#: model:ir.model.fields,field_description:report_alternative_layout.field_ir_actions_report__apply_alternative_layout
msgid "Apply Alternative Layout"
msgstr "代替レイアウトを適用"

#. module: report_alternative_layout
#: model:ir.model.fields,help:report_alternative_layout.field_ir_actions_report__apply_alternative_layout
msgid ""
"If selected, the alternative layout will be applied in the printed report."
msgstr "選択すると、印刷帳票に代替レイアウトが適用されます。"

#. module: report_alternative_layout
#: model:ir.model.fields,help:report_alternative_layout.field_ir_actions_report__show_commercial_partner
msgid ""
"If selected, the commercial partner of the document partner will show in the"
" report output (instead of the document partner)."
msgstr "選択すると、ドキュメントの取引先の代わりに商業取引先(親)がレポートで出力されます。"

#. module: report_alternative_layout
#: model:ir.model,name:report_alternative_layout.model_ir_actions_report
msgid "Report Action"
msgstr "レポートアクション"

#. module: report_alternative_layout
#: model:ir.model.fields,field_description:report_alternative_layout.field_ir_actions_report__show_commercial_partner
msgid "Show Commercial Partner"
msgstr "商業取引先(親)を表示"
1 change: 1 addition & 0 deletions report_alternative_layout/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ir_actions_report
29 changes: 29 additions & 0 deletions report_alternative_layout/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Quartile
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class Report(models.Model):
_inherit = "ir.actions.report"

apply_alternative_layout = fields.Boolean(
help="If selected, the alternative layout will be applied in the printed "
"report.",
)
show_commercial_partner = fields.Boolean(
help="If selected, the commercial partner of the document partner will show "
"in the report output (instead of the document partner)."
)

def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
report = self._get_report(report_ref)

Check warning on line 20 in report_alternative_layout/models/ir_actions_report.py

View check run for this annotation

Codecov / codecov/patch

report_alternative_layout/models/ir_actions_report.py#L20

Added line #L20 was not covered by tests
if report.apply_alternative_layout:
self = self.with_context(apply_alternative_layout=True)
return super()._render_qweb_pdf(report_ref, res_ids, data)

Check warning on line 23 in report_alternative_layout/models/ir_actions_report.py

View check run for this annotation

Codecov / codecov/patch

report_alternative_layout/models/ir_actions_report.py#L22-L23

Added lines #L22 - L23 were not covered by tests

def _get_partner(self, xmlid, partner):
report = self._get_report_from_name(xmlid)

Check warning on line 26 in report_alternative_layout/models/ir_actions_report.py

View check run for this annotation

Codecov / codecov/patch

report_alternative_layout/models/ir_actions_report.py#L26

Added line #L26 was not covered by tests
if report.show_commercial_partner:
return partner.commercial_partner_id
return partner

Check warning on line 29 in report_alternative_layout/models/ir_actions_report.py

View check run for this annotation

Codecov / codecov/patch

report_alternative_layout/models/ir_actions_report.py#L28-L29

Added lines #L28 - L29 were not covered by tests
8 changes: 8 additions & 0 deletions report_alternative_layout/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Go to *Settings > Technical > Reporting > Reports*, and open a report of your choice, and
update the following fields as necessary.

- Apply Alternative Layout: If selected, the alternative layout will be applied in the
printed report.
- Paper Format: Select 'A4 - no company address in header' if 'Apply Alternative Layout' is selected.
- Show Commercial Partner: If selected, the commercial partner of the document partner
will show in the report output (instead of the document partner).
9 changes: 9 additions & 0 deletions report_alternative_layout/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This module introduces an alternative layout for QWeb reports with the following
adjustments to existing external layouts:

- Displays the partner's address on the left side first, followed by the company's
address on the right side.
- Uses the commercial partner's address in place of the partner's address.

Currently, these adjustments are only supported for the standard external layout
(`external_layout_standard`).
37 changes: 37 additions & 0 deletions report_alternative_layout/report/report_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="external_layout_standard" inherit_id="web.external_layout_standard">
<!-- Hide company address in the header if alternative layout is selected -->
<xpath expr="//div[@name='company_address']/ul" position="attributes">
<attribute
name="t-if"
>not env.context.get('apply_alternative_layout')</attribute>
</xpath>
<!-- Show company address in the body if alternative layout is selected -->
<xpath expr="//t[@t-call='web.address_layout']" position="attributes">
<attribute
name="t-if"
>not env.context.get('apply_alternative_layout')</attribute>
</xpath>
<xpath expr="//t[@t-call='web.address_layout']" position="after">
<div t-else="" class="row" name="address_layout">
<div class="col-7" name="partner_address">
<t
t-set="partner_name"
t-value="o.env['ir.actions.report']._get_partner(xmlid, o.partner_id)"
/>
<div
t-esc="partner_name"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
/>
</div>
<div class="col-5" name="company_address">
<div
t-field="o.company_id.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
/>
</div>
</div>
</xpath>
</template>
</odoo>
Loading
Loading