diff --git a/partner_contact_address_default/README.rst b/partner_contact_address_default/README.rst new file mode 100644 index 000000000..f37ea0ace --- /dev/null +++ b/partner_contact_address_default/README.rst @@ -0,0 +1,87 @@ +=============================== +Partner Contact address default +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/13.0/partner_contact_address_default + :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-13-0/partner-contact-13-0-partner_contact_address_default + :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/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of base partner module to allow to set a +default delivery and invoice address for contacts. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *Contacts*. +#. Select default delivery address or invoice address for partner. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Carlos Dauden + * Sergio Teruel + +* `Sygel `_: + + * Manuel Regidor + +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_contact_address_default/__init__.py b/partner_contact_address_default/__init__.py new file mode 100644 index 000000000..3275ac2ad --- /dev/null +++ b/partner_contact_address_default/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/partner_contact_address_default/__manifest__.py b/partner_contact_address_default/__manifest__.py new file mode 100644 index 000000000..75c49de70 --- /dev/null +++ b/partner_contact_address_default/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020 Tecnativa - Carlos Dauden +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Partner Contact address default", + "summary": "Set a default delivery and invoice address for contacts", + "version": "14.0.1.0.0", + "development_status": "Beta", + "category": "Generic Modules/Base", + "website": "https://github.com/OCA/partner-contact", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["base"], + "data": ["views/res_partner_views.xml"], +} diff --git a/partner_contact_address_default/i18n/es.po b/partner_contact_address_default/i18n/es.po new file mode 100644 index 000000000..e5e40ccf8 --- /dev/null +++ b/partner_contact_address_default/i18n/es.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_contact_address_default +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-05-15 18:08+0000\n" +"PO-Revision-Date: 2020-05-15 20:09+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: partner_contact_address_default +#: model:ir.model,name:partner_contact_address_default.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +#, fuzzy +msgid "Force addresses" +msgstr "Dirección de facturación" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "If you keep empty this fields the Odoo's behavior will be normal" +msgstr "" + +#. module: partner_contact_address_default +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_partner__partner_invoice_id +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_users__partner_invoice_id +msgid "Invoice address" +msgstr "Dirección de facturación" + +#. module: partner_contact_address_default +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_partner__partner_delivery_id +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_users__partner_delivery_id +msgid "Shipping address" +msgstr "Dirección de envío" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "You can force and delivery and invoice address for this contacts." +msgstr "" diff --git a/partner_contact_address_default/i18n/partner_contact_address_default.pot b/partner_contact_address_default/i18n/partner_contact_address_default.pot new file mode 100644 index 000000000..447700d99 --- /dev/null +++ b/partner_contact_address_default/i18n/partner_contact_address_default.pot @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_contact_address_default +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \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: partner_contact_address_default +#: model:ir.model,name:partner_contact_address_default.model_res_partner +msgid "Contact" +msgstr "" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "Force addresses" +msgstr "" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "If you keep empty this fields the Odoo's behavior will be normal" +msgstr "" + +#. module: partner_contact_address_default +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_partner__partner_invoice_id +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_users__partner_invoice_id +msgid "Invoice address" +msgstr "" + +#. module: partner_contact_address_default +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_partner__partner_delivery_id +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_users__partner_delivery_id +msgid "Shipping address" +msgstr "" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "You can force and delivery and invoice address for this contacts." +msgstr "" diff --git a/partner_contact_address_default/i18n/pt.po b/partner_contact_address_default/i18n/pt.po new file mode 100644 index 000000000..e4f746854 --- /dev/null +++ b/partner_contact_address_default/i18n/pt.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_contact_address_default +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-09-15 21:00+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: partner_contact_address_default +#: model:ir.model,name:partner_contact_address_default.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "Force addresses" +msgstr "Forçar endereços" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "If you keep empty this fields the Odoo's behavior will be normal" +msgstr "Se mantiver estes valores vazios, o comportamento do Odoo será o normal" + +#. module: partner_contact_address_default +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_partner__partner_invoice_id +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_users__partner_invoice_id +msgid "Invoice address" +msgstr "Endereço de faturação" + +#. module: partner_contact_address_default +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_partner__partner_delivery_id +#: model:ir.model.fields,field_description:partner_contact_address_default.field_res_users__partner_delivery_id +msgid "Shipping address" +msgstr "Endereço de envio" + +#. module: partner_contact_address_default +#: model_terms:ir.ui.view,arch_db:partner_contact_address_default.view_partner_form +msgid "You can force and delivery and invoice address for this contacts." +msgstr "Pode forçar um endereço de envio e faturação para este contacto." diff --git a/partner_contact_address_default/models/__init__.py b/partner_contact_address_default/models/__init__.py new file mode 100644 index 000000000..3d2c983c6 --- /dev/null +++ b/partner_contact_address_default/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import res_partner diff --git a/partner_contact_address_default/models/res_partner.py b/partner_contact_address_default/models/res_partner.py new file mode 100644 index 000000000..8da4e0423 --- /dev/null +++ b/partner_contact_address_default/models/res_partner.py @@ -0,0 +1,30 @@ +# Copyright 2020 Tecnativa - Carlos Dauden +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + partner_delivery_id = fields.Many2one( + comodel_name="res.partner", + string="Shipping address", + ) + partner_invoice_id = fields.Many2one( + comodel_name="res.partner", + string="Invoice address", + ) + + def get_address_default_type(self): + return ["delivery", "invoice"] + + def address_get(self, adr_pref=None): + res = super().address_get(adr_pref) + default_address_type_list = self.get_address_default_type() + for partner in self: + for addr_type in default_address_type_list: + default_address_id = partner["partner_{}_id".format(addr_type)] + if default_address_id: + res[addr_type] = default_address_id + return res diff --git a/partner_contact_address_default/readme/CONTRIBUTORS.rst b/partner_contact_address_default/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..816d0c593 --- /dev/null +++ b/partner_contact_address_default/readme/CONTRIBUTORS.rst @@ -0,0 +1,8 @@ +* `Tecnativa `_: + + * Carlos Dauden + * Sergio Teruel + +* `Sygel `_: + + * Manuel Regidor diff --git a/partner_contact_address_default/readme/DESCRIPTION.rst b/partner_contact_address_default/readme/DESCRIPTION.rst new file mode 100644 index 000000000..479496ecc --- /dev/null +++ b/partner_contact_address_default/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends the functionality of base partner module to allow to set a +default delivery and invoice address for contacts. diff --git a/partner_contact_address_default/readme/USAGE.rst b/partner_contact_address_default/readme/USAGE.rst new file mode 100644 index 000000000..3673953be --- /dev/null +++ b/partner_contact_address_default/readme/USAGE.rst @@ -0,0 +1,2 @@ +#. Go to *Contacts*. +#. Select default delivery address or invoice address for partner. diff --git a/partner_contact_address_default/static/description/icon.png b/partner_contact_address_default/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_contact_address_default/static/description/icon.png differ diff --git a/partner_contact_address_default/static/description/index.html b/partner_contact_address_default/static/description/index.html new file mode 100644 index 000000000..c5cb09d44 --- /dev/null +++ b/partner_contact_address_default/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Partner Contact address default + + + +
+

Partner Contact address default

+ + +

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

+

This module extends the functionality of base partner module to allow to set a +default delivery and invoice address for contacts.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Contacts.
  2. +
  3. Select default delivery address or invoice address for partner.
  4. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Carlos Dauden
    • +
    • Sergio Teruel
    • +
    +
  • +
  • Sygel:
      +
    • Manuel Regidor
    • +
    +
  • +
+
+
+

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.

+
+
+
+ + diff --git a/partner_contact_address_default/tests/__init__.py b/partner_contact_address_default/tests/__init__.py new file mode 100644 index 000000000..b2fbacbb4 --- /dev/null +++ b/partner_contact_address_default/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2019 Sergio Teruel - Tecnativa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import test_partner_contact_address_default diff --git a/partner_contact_address_default/tests/test_partner_contact_address_default.py b/partner_contact_address_default/tests/test_partner_contact_address_default.py new file mode 100644 index 000000000..6d8d52286 --- /dev/null +++ b/partner_contact_address_default/tests/test_partner_contact_address_default.py @@ -0,0 +1,41 @@ +# Copyright 2020 Tecnativa - Carlos Dauden +# Copyright 2020 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.tests import common + + +class TestPartnerContactAddressDefault(common.TransactionCase): + def setUp(self): + super().setUp() + self.Partner = self.env["res.partner"] + self.partner = self.Partner.create({"name": "Parent partner"}) + self.partner_child_delivery1 = self.Partner.create( + { + "name": "Child delivery 1", + "type": "delivery", + "parent_id": self.partner.id, + } + ) + self.partner_child_delivery2 = self.Partner.create( + { + "name": "Child delivery 2", + "type": "delivery", + "parent_id": self.partner.id, + } + ) + self.partner_child_invoice = self.Partner.create( + {"name": "Child invoice", "type": "invoice", "parent_id": self.partner.id} + ) + + def test_contact_address_default(self): + self.partner.partner_delivery_id = self.partner + self.partner.partner_invoice_id = self.partner + res = self.partner.address_get() + self.assertEqual(res["delivery"], self.partner) + self.assertEqual(res["invoice"], self.partner) + + self.partner_child_delivery2.partner_delivery_id = self.partner_child_delivery2 + self.partner_child_delivery2.partner_invoice_id = self.partner_child_delivery2 + res = self.partner_child_delivery2.address_get() + self.assertEqual(res["delivery"], self.partner_child_delivery2) + self.assertEqual(res["invoice"], self.partner_child_delivery2) diff --git a/partner_contact_address_default/views/res_partner_views.xml b/partner_contact_address_default/views/res_partner_views.xml new file mode 100644 index 000000000..5330fdb07 --- /dev/null +++ b/partner_contact_address_default/views/res_partner_views.xml @@ -0,0 +1,55 @@ + + + + res.partner + + + + + + + + + + + + + + + + +
+
You can force and delivery and invoice address for this contacts.
+
If you keep empty this fields the Odoo's behavior will be normal
+
+
+ + + + + + + + +
+
+
+
+
diff --git a/setup/partner_contact_address_default/odoo/addons/partner_contact_address_default b/setup/partner_contact_address_default/odoo/addons/partner_contact_address_default new file mode 120000 index 000000000..716d652d1 --- /dev/null +++ b/setup/partner_contact_address_default/odoo/addons/partner_contact_address_default @@ -0,0 +1 @@ +../../../../partner_contact_address_default \ No newline at end of file diff --git a/setup/partner_contact_address_default/setup.py b/setup/partner_contact_address_default/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_contact_address_default/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)