diff --git a/partner_contact_address_default/README.rst b/partner_contact_address_default/README.rst new file mode 100644 index 000000000..9bb869a66 --- /dev/null +++ b/partner_contact_address_default/README.rst @@ -0,0 +1,83 @@ +=============================== +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/12.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-12-0/partner-contact-12-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/12.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 + +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..20af23ce1 --- /dev/null +++ b/partner_contact_address_default/__manifest__.py @@ -0,0 +1,21 @@ +# 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': '12.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..51fc42e6d --- /dev/null +++ b/partner_contact_address_default/i18n/es.po @@ -0,0 +1,35 @@ +# 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" +"Language-Team: \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" +"Last-Translator: \n" +"Language: es\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: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" 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..a69ab18fd --- /dev/null +++ b/partner_contact_address_default/i18n/partner_contact_address_default.pot @@ -0,0 +1,34 @@ +# 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 18:08+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: partner_contact_address_default +#: model:ir.model,name:partner_contact_address_default.model_res_partner +msgid "Contact" +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 "" + 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..e0aa5ec95 --- /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..0763b4b67 --- /dev/null +++ b/partner_contact_address_default/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Carlos Dauden + * Sergio Teruel 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..b5d57e820 --- /dev/null +++ b/partner_contact_address_default/static/description/index.html @@ -0,0 +1,432 @@ + + + + + + +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
    • +
    +
  • +
+
+
+

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..633ead11e --- /dev/null +++ b/partner_contact_address_default/tests/test_partner_contact_address_default.py @@ -0,0 +1,44 @@ +# 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..7247a9ca5 --- /dev/null +++ b/partner_contact_address_default/views/res_partner_views.xml @@ -0,0 +1,40 @@ + + + + + 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
+
+
+ + + + + + + + +
+
+
+
+ +