From 5e25dc11fae6efcc2651f8b8cd6db29c6676e698 Mon Sep 17 00:00:00 2001 From: Tonow-c2c Date: Mon, 20 Jan 2020 14:34:30 +0100 Subject: [PATCH] [ADD][12.0] add partner_address_two_lines module --- partner_address_two_lines/README.rst | 75 ++++ partner_address_two_lines/__init__.py | 1 + partner_address_two_lines/__manifest__.py | 14 + partner_address_two_lines/models/__init__.py | 2 + .../models/ir_actions_report.py | 17 + .../models/res_partner.py | 16 + .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 2 + .../static/description/index.html | 421 ++++++++++++++++++ 9 files changed, 550 insertions(+) create mode 100644 partner_address_two_lines/README.rst create mode 100644 partner_address_two_lines/__init__.py create mode 100644 partner_address_two_lines/__manifest__.py create mode 100644 partner_address_two_lines/models/__init__.py create mode 100644 partner_address_two_lines/models/ir_actions_report.py create mode 100644 partner_address_two_lines/models/res_partner.py create mode 100644 partner_address_two_lines/readme/CONTRIBUTORS.rst create mode 100644 partner_address_two_lines/readme/DESCRIPTION.rst create mode 100644 partner_address_two_lines/static/description/index.html diff --git a/partner_address_two_lines/README.rst b/partner_address_two_lines/README.rst new file mode 100644 index 000000000..9e07be5be --- /dev/null +++ b/partner_address_two_lines/README.rst @@ -0,0 +1,75 @@ +============================ +Partner address in two lines +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/12.0/partner_address_two_lines + :alt: OCA/partner-contact +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_address_two_lines + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module changes the reports layout. +The company partner and the partner name are on two different lines. + +**Table of contents** + +.. contents:: + :local: + +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 +* Akim Juillerat + +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/partner-contact `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_address_two_lines/__init__.py b/partner_address_two_lines/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_address_two_lines/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_address_two_lines/__manifest__.py b/partner_address_two_lines/__manifest__.py new file mode 100644 index 000000000..c5278b6a2 --- /dev/null +++ b/partner_address_two_lines/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Partner address in two lines", + "version": "12.0.1.0.0", + "summary": "The company and the partner name are on two different lines", + "author": "Camptocamp," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Partner", + "website": "http://github.com/OCA/partner-contact", + "depends": ["base"], + "installable": True, + "auto_install": False, +} diff --git a/partner_address_two_lines/models/__init__.py b/partner_address_two_lines/models/__init__.py new file mode 100644 index 000000000..1c336cfc2 --- /dev/null +++ b/partner_address_two_lines/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_partner +from . import ir_actions_report diff --git a/partner_address_two_lines/models/ir_actions_report.py b/partner_address_two_lines/models/ir_actions_report.py new file mode 100644 index 000000000..d279da25f --- /dev/null +++ b/partner_address_two_lines/models/ir_actions_report.py @@ -0,0 +1,17 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class IrActionsReport(models.Model): + _inherit = "ir.actions.report" + + @api.model + def _get_rendering_context(self, docids, data): + """ Set context key to split partner address on two line only on report + """ + res = super()._get_rendering_context(docids, data) + docs = res.get("docs") + res["docs"] = docs.with_context(_two_lines_partner_address=True) + return res diff --git a/partner_address_two_lines/models/res_partner.py b/partner_address_two_lines/models/res_partner.py new file mode 100644 index 000000000..4548ff132 --- /dev/null +++ b/partner_address_two_lines/models/res_partner.py @@ -0,0 +1,16 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + def _get_contact_name(self, partner, name): + if self.env.context.get("_two_lines_partner_address"): + return "{}\n {}".format( + partner.commercial_company_name or partner.parent_id.name, name + ) + else: + return super()._get_contact_name(partner, name) diff --git a/partner_address_two_lines/readme/CONTRIBUTORS.rst b/partner_address_two_lines/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..26b8c9131 --- /dev/null +++ b/partner_address_two_lines/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Thomas Nowicki +* Akim Juillerat diff --git a/partner_address_two_lines/readme/DESCRIPTION.rst b/partner_address_two_lines/readme/DESCRIPTION.rst new file mode 100644 index 000000000..78f3a8c98 --- /dev/null +++ b/partner_address_two_lines/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module changes the reports layout. +The company partner and the partner name are on two different lines. diff --git a/partner_address_two_lines/static/description/index.html b/partner_address_two_lines/static/description/index.html new file mode 100644 index 000000000..3caf6fdd6 --- /dev/null +++ b/partner_address_two_lines/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Partner address in two lines + + + +
+

Partner address in two lines

+ + +

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

+

This module changes the reports layout. +The company partner and the partner name are on two different lines.

+

Table of contents

+ +
+

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/partner-contact project on GitHub.

+

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

+
+
+
+ +