From 10691078b7be593597d6ea987b42dc9761f1cdd9 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 20 May 2015 11:30:59 +0200 Subject: [PATCH] Deprecate base_contact. - Remove nationality and birthday features. - Move the remaining features to partner_contact_in_several_companies. - Make base_contact a dummy module. - Warn deprecation everywhere possible. --- .../README.rst | 68 +++++ .../__init__.py | 19 ++ .../__openerp__.py | 35 +++ .../demo/res_partner.xml | 29 +++ .../i18n/de.po | 171 +++++++++++++ .../i18n/es.po | 170 +++++++++++++ .../i18n/fr.po | 170 +++++++++++++ .../partner_contact_in_several_companies.pot | 165 +++++++++++++ .../i18n/sl.po | 169 +++++++++++++ .../models.py | 232 ++++++++++++++++++ .../tests/__init__.py | 22 ++ ...st_partner_contact_in_several_companies.py | 205 ++++++++++++++++ .../views/res_partner.xml | 216 ++++++++++++++++ 13 files changed, 1671 insertions(+) create mode 100644 partner_contact_in_several_companies/README.rst create mode 100644 partner_contact_in_several_companies/__init__.py create mode 100644 partner_contact_in_several_companies/__openerp__.py create mode 100644 partner_contact_in_several_companies/demo/res_partner.xml create mode 100644 partner_contact_in_several_companies/i18n/de.po create mode 100644 partner_contact_in_several_companies/i18n/es.po create mode 100644 partner_contact_in_several_companies/i18n/fr.po create mode 100644 partner_contact_in_several_companies/i18n/partner_contact_in_several_companies.pot create mode 100644 partner_contact_in_several_companies/i18n/sl.po create mode 100644 partner_contact_in_several_companies/models.py create mode 100644 partner_contact_in_several_companies/tests/__init__.py create mode 100644 partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py create mode 100644 partner_contact_in_several_companies/views/res_partner.xml diff --git a/partner_contact_in_several_companies/README.rst b/partner_contact_in_several_companies/README.rst new file mode 100644 index 000000000..2c9d9dc91 --- /dev/null +++ b/partner_contact_in_several_companies/README.rst @@ -0,0 +1,68 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Module name +=========== + +This module was written to extend the contact management functionality. It +allows you to set several job positions in different companies per contact. + +Installation +============ + +To install this module, you need to: + +* Install the OCA repository `partner-contact`_. + +Configuration +============= + +No configuration is needed. + +Usage +===== + +New tabs 'Other Positions' and 'Personal Information' are available on the +contact form. + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 +* https://github.com/OCA/partner-contact/ + +Known issues / Roadmap +====================== + +* Update to v8 API. + +Credits +======= + +Contributors +------------ + +* Xavier ALT (original author) +* EL HADJI DEM +* TheCloneMaster +* Sandy Carter +* Rudolf Schnapka +* Sebastien Alix +* Jairo Llopis + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. + + +.. _partner-contact: https://github.com/OCA/partner-contact/ diff --git a/partner_contact_in_several_companies/__init__.py b/partner_contact_in_several_companies/__init__.py new file mode 100644 index 000000000..3b3430c28 --- /dev/null +++ b/partner_contact_in_several_companies/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import models diff --git a/partner_contact_in_several_companies/__openerp__.py b/partner_contact_in_several_companies/__openerp__.py new file mode 100644 index 000000000..7685dbc2a --- /dev/null +++ b/partner_contact_in_several_companies/__openerp__.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +{ + "name": "Contacts in several partners", + "summary": "Allow to have one contact in several partners", + "version": "1.0.0", + "author": "Odoo Community Association (OCA)", + "category": "Customer Relationship Management", + "website": "https://odoo-community.org/", + "depends": [ + "partner_contact_personal_information_page", + ], + "data": [ + "views/res_partner.xml", + ], + "demo": [ + "demo/res_partner.xml", + ], +} diff --git a/partner_contact_in_several_companies/demo/res_partner.xml b/partner_contact_in_several_companies/demo/res_partner.xml new file mode 100644 index 000000000..a7af9373f --- /dev/null +++ b/partner_contact_in_several_companies/demo/res_partner.xml @@ -0,0 +1,29 @@ + + + + + + Roger Scott + Consultant + + + + + + + Bob Egnops + 1984-01-01 + bob@hillenburg-oceaninstitute.com + + + + Bob Egnops + Technician + bob@yourcompany.com + + + + + + + \ No newline at end of file diff --git a/partner_contact_in_several_companies/i18n/de.po b/partner_contact_in_several_companies/i18n/de.po new file mode 100644 index 000000000..ef513dde0 --- /dev/null +++ b/partner_contact_in_several_companies/i18n/de.po @@ -0,0 +1,171 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +# Rudolf Schnapka , 2014. +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-20 09:26+0000\n" +"PO-Revision-Date: 2015-05-20 11:27+0100\n" +"Last-Translator: Rudolf Schnapka \n" +"Language-Team: German \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.7.6\n" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Address" +msgstr "Anschrift" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All partner positions" +msgstr "Alle Positionen des Partners" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All positions" +msgstr "Alle Positionen" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Mit bestehendem Kontakt verknüpft" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "City" +msgstr "Stadt" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Company" +msgstr "Unternehmen" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contact" +msgstr "Kontakt" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Kontaktart" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contacts" +msgstr "Kontakte" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Country" +msgstr "Land" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Fax:" +msgstr "Fax:" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Hauptkontakt" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Mobile:" +msgstr "Mobil:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Other Positions" +msgstr "Andere Positionen" + +#. module: partner_contact_in_several_companies +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Andere Positionen" + +#. module: partner_contact_in_several_companies +#: model:ir.model,name:partner_contact_in_several_companies.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "Person" +msgstr "Person" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Phone:" +msgstr "Telefon:" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Alleinstehender Kontakt" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "State" +msgstr "Bundesland" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Street..." +msgstr "Straße..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Tags..." +msgstr "Schlagworte..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_personal_information +#, fuzzy +msgid "" +"To see personal information about this contact, please\n" +" go to to the his person form:" +msgstr "" +"Um persönliche Auskunft zu diesem Kontakt zu erhalten, gehen Sie bitte auf " +"die Seite persönlich:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "ZIP" +msgstr "PLZ" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "at" +msgstr "bei" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "e.g. Sales Director" +msgstr "z. B. Verkaufsleiter" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other position" +msgstr "andere Position" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other positions" +msgstr "andere Positionen" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "{'invisible': [('contact_type','=','attached')]}" +msgstr "" diff --git a/partner_contact_in_several_companies/i18n/es.po b/partner_contact_in_several_companies/i18n/es.po new file mode 100644 index 000000000..55cfe0228 --- /dev/null +++ b/partner_contact_in_several_companies/i18n/es.po @@ -0,0 +1,170 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-20 09:26+0000\n" +"PO-Revision-Date: 2015-05-20 11:33+0100\n" +"Last-Translator: Jairo Llopis \n" +"Language-Team: \n" +"Language: es_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 1.7.6\n" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Address" +msgstr "Dirección" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All partner positions" +msgstr "Todas las posiciones de empresa" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All positions" +msgstr "Todas las posiciones" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Anexado a un contacto existente" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "City" +msgstr "Ciudad" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Company" +msgstr "Compañía" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contact" +msgstr "Contacto" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Tipo de contacto" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contacts" +msgstr "Contactos" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Country" +msgstr "País" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Fax:" +msgstr "Fax:" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Contacto principal" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Mobile:" +msgstr "Teléfono móvil:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Other Positions" +msgstr "Otras posiciones" + +#. module: partner_contact_in_several_companies +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Otras posiciones" + +#. module: partner_contact_in_several_companies +#: model:ir.model,name:partner_contact_in_several_companies.model_res_partner +msgid "Partner" +msgstr "Empresa" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "Person" +msgstr "Persona" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Phone:" +msgstr "Teléfono:" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Contacto independiente" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "State" +msgstr "Provincia" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Street..." +msgstr "Calle..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Tags..." +msgstr "Etiquetas..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_personal_information +#, fuzzy +msgid "" +"To see personal information about this contact, please\n" +" go to to the his person form:" +msgstr "" +"Para ver la información personal de este contacto, por favor vaya a su " +"formulario personal:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "ZIP" +msgstr "C.P." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "at" +msgstr "en" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "e.g. Sales Director" +msgstr "ej.: Director de ventas" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other position" +msgstr "otra posición" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other positions" +msgstr "otras posiciones" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "{'invisible': [('contact_type','=','attached')]}" +msgstr "" diff --git a/partner_contact_in_several_companies/i18n/fr.po b/partner_contact_in_several_companies/i18n/fr.po new file mode 100644 index 000000000..811c3c8ca --- /dev/null +++ b/partner_contact_in_several_companies/i18n/fr.po @@ -0,0 +1,170 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-20 09:26+0000\n" +"PO-Revision-Date: 2015-05-20 11:28+0100\n" +"Last-Translator: EL Hadji DEM \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.7.6\n" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Address" +msgstr "Adresse" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All partner positions" +msgstr "Tous les contacts" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All positions" +msgstr "Tous les contacts" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Contact rattaché à un contact existant" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "City" +msgstr "Ville" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Company" +msgstr "Organisme" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contact" +msgstr "Contact" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Type de contact" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contacts" +msgstr "Contacts" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Country" +msgstr "Pays" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Fax:" +msgstr "Fax :" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Principal contact" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Mobile:" +msgstr "Portable :" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Other Positions" +msgstr "Fonctions" + +#. module: partner_contact_in_several_companies +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Fonctions" + +#. module: partner_contact_in_several_companies +#: model:ir.model,name:partner_contact_in_several_companies.model_res_partner +msgid "Partner" +msgstr "Partenaire" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "Person" +msgstr "Personne" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Phone:" +msgstr "Téléphone:" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Contact autonome" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "State" +msgstr "État" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Street..." +msgstr "Rue..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Tags..." +msgstr "Étiquettes..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_personal_information +#, fuzzy +msgid "" +"To see personal information about this contact, please\n" +" go to to the his person form:" +msgstr "" +"Pour voir des informations personnelles sur ce contact, s'il vous plaît " +"aller au formulaire de la personne:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "ZIP" +msgstr "Code postal" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "at" +msgstr "à" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "e.g. Sales Director" +msgstr "ex: Directeur des ventes" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other position" +msgstr "fonction" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other positions" +msgstr "fonctions" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "{'invisible': [('contact_type','=','attached')]}" +msgstr "" diff --git a/partner_contact_in_several_companies/i18n/partner_contact_in_several_companies.pot b/partner_contact_in_several_companies/i18n/partner_contact_in_several_companies.pot new file mode 100644 index 000000000..4d75f72b7 --- /dev/null +++ b/partner_contact_in_several_companies/i18n/partner_contact_in_several_companies.pot @@ -0,0 +1,165 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_contact_in_several_companies +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0-20150514\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-20 09:26+0000\n" +"PO-Revision-Date: 2015-05-20 09:26+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_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Address" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All partner positions" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All positions" +msgstr "" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "City" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Company" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contact" +msgstr "" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contacts" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Country" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Fax:" +msgstr "" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Mobile:" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Other Positions" +msgstr "" + +#. module: partner_contact_in_several_companies +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "" + +#. module: partner_contact_in_several_companies +#: model:ir.model,name:partner_contact_in_several_companies.model_res_partner +msgid "Partner" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "Person" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Phone:" +msgstr "" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "State" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Street..." +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Tags..." +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_personal_information +msgid "To see personal information about this contact, please\n" +" go to to the his person form:" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "ZIP" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "at" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "e.g. Sales Director" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other position" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other positions" +msgstr "" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "{'invisible': [('contact_type','=','attached')]}" +msgstr "" + diff --git a/partner_contact_in_several_companies/i18n/sl.po b/partner_contact_in_several_companies/i18n/sl.po new file mode 100644 index 000000000..ff4753dc9 --- /dev/null +++ b/partner_contact_in_several_companies/i18n/sl.po @@ -0,0 +1,169 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_contact +# +# Matjaž Mozetič , 2015. +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-20 09:26+0000\n" +"PO-Revision-Date: 2015-05-20 11:28+0100\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian \n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.7.6\n" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Address" +msgstr "Naslov" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All partner positions" +msgstr "Vsi partnerjevi položaji" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "All positions" +msgstr "Vsi položaji" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:32 +#, python-format +msgid "Attached to existing Contact" +msgstr "Pripeto obstoječemu stiku" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "City" +msgstr "Kraj" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Company" +msgstr "Družba" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contact" +msgstr "Stik" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_type:0 +msgid "Contact Type" +msgstr "Tip stika" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Contacts" +msgstr "Stiki" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Country" +msgstr "Država" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Fax:" +msgstr "Faks:" + +#. module: partner_contact_in_several_companies +#: field:res.partner,contact_id:0 +msgid "Main Contact" +msgstr "Glavni stik" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Mobile:" +msgstr "Mobilni telefon:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Other Positions" +msgstr "Drugi položaji" + +#. module: partner_contact_in_several_companies +#: field:res.partner,other_contact_ids:0 +msgid "Others Positions" +msgstr "Drugi položaji" + +#. module: partner_contact_in_several_companies +#: model:ir.model,name:partner_contact_in_several_companies.model_res_partner +msgid "Partner" +msgstr "Partner" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_filter_contact +msgid "Person" +msgstr "Oseba" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Phone:" +msgstr "Telefon:" + +#. module: partner_contact_in_several_companies +#: code:addons/partner_contact_in_several_companies/models.py:31 +#, python-format +msgid "Standalone Contact" +msgstr "Samostojni stik" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "State" +msgstr "Zvezna država" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Street..." +msgstr "Ulica..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "Tags..." +msgstr "Oznake..." + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_personal_information +#, fuzzy +msgid "" +"To see personal information about this contact, please\n" +" go to to the his person form:" +msgstr "Za ogled osebnih podatkov o tem stiku pojdite na njegov glavni obrazec:" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "ZIP" +msgstr "Poštna številka" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "at" +msgstr "pri" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "e.g. Sales Director" +msgstr "npr. vodja prodaje" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other position" +msgstr "drug položaj" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_res_partner_kanban_contact +msgid "other positions" +msgstr "drugi položaji" + +#. module: partner_contact_in_several_companies +#: view:res.partner:partner_contact_in_several_companies.view_partner_form_inherit +msgid "{'invisible': [('contact_type','=','attached')]}" +msgstr "" diff --git a/partner_contact_in_several_companies/models.py b/partner_contact_in_several_companies/models.py new file mode 100644 index 000000000..2493dc023 --- /dev/null +++ b/partner_contact_in_several_companies/models.py @@ -0,0 +1,232 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-TODAY OpenERP SA (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import fields, orm, expression +from openerp.tools.translate import _ + + +class res_partner(orm.Model): + _inherit = 'res.partner' + + def _type_selection(self, cr, uid, context=None): + return [ + ('standalone', _('Standalone Contact')), + ('attached', _('Attached to existing Contact')), + ] + + def _get_contact_type(self, cr, uid, ids, field_name, args, context=None): + result = dict.fromkeys(ids, 'standalone') + for partner in self.browse(cr, uid, ids, context=context): + if partner.contact_id: + result[partner.id] = 'attached' + return result + + _columns = { + 'contact_type': fields.function( + _get_contact_type, + type='selection', + selection=lambda self, *a, **kw: self._type_selection(*a, **kw), + string='Contact Type', + required=True, + select=1, + store=True, + ), + 'contact_id': fields.many2one( + 'res.partner', + 'Main Contact', + domain=[ + ('is_company', '=', False), + ('contact_type', '=', 'standalone'), + ], + ), + 'other_contact_ids': fields.one2many( + 'res.partner', + 'contact_id', + 'Others Positions', + ), + } + + _defaults = { + 'contact_type': 'standalone', + } + + def _basecontact_check_context(self, cr, user, mode, context=None): + """ Remove 'search_show_all_positions' for non-search mode. + Keeping it in context can result in unexpected behaviour (ex: reading + one2many might return wrong result - i.e with "attached contact" + removed even if it's directly linked to a company). + """ + context = dict(context or {}) + if mode != 'search': + context.pop('search_show_all_positions', None) + return context + + def search( + self, cr, user, args, offset=0, limit=None, order=None, + context=None, count=False): + """ Display only standalone contact matching ``args`` or having + attached contact matching ``args`` """ + if context is None: + context = {} + if context.get('search_show_all_positions') is False: + args = expression.normalize_domain(args) + attached_contact_args = expression.AND( + (args, [('contact_type', '=', 'attached')]) + ) + attached_contact_ids = super(res_partner, self).search( + cr, user, attached_contact_args, context=context + ) + args = expression.OR(( + expression.AND(([('contact_type', '=', 'standalone')], args)), + [('other_contact_ids', 'in', attached_contact_ids)], + )) + return super(res_partner, self).search( + cr, user, args, offset=offset, limit=limit, order=order, + context=context, count=count + ) + + def create(self, cr, user, vals, context=None): + context = self._basecontact_check_context(cr, user, 'create', context) + if not vals.get('name') and vals.get('contact_id'): + vals['name'] = self.browse( + cr, user, vals['contact_id'], context=context).name + return super(res_partner, self).create(cr, user, vals, context=context) + + def read( + self, cr, user, ids, fields=None, context=None, + load='_classic_read'): + context = self._basecontact_check_context(cr, user, 'read', context) + return super(res_partner, self).read( + cr, user, ids, fields=fields, context=context, load=load) + + def write(self, cr, user, ids, vals, context=None): + context = self._basecontact_check_context(cr, user, 'write', context) + return super( + res_partner, self).write(cr, user, ids, vals, context=context) + + def unlink(self, cr, user, ids, context=None): + context = self._basecontact_check_context(cr, user, 'unlink', context) + return super(res_partner, self).unlink(cr, user, ids, context=context) + + def _commercial_partner_compute( + self, cr, uid, ids, name, args, context=None): + """ Returns the partner that is considered the commercial + entity of this partner. The commercial entity holds the master data + for all commercial fields (see :py:meth:`~_commercial_fields`) """ + result = super(res_partner, self)._commercial_partner_compute( + cr, uid, ids, name, args, context=context) + for partner in self.browse(cr, uid, ids, context=context): + if partner.contact_type == 'attached' and not partner.parent_id: + result[partner.id] = partner.contact_id.id + return result + + def _contact_fields(self, cr, uid, context=None): + """ Returns the list of contact fields that are synced from the parent + when a partner is attached to him. """ + return ['name', 'title'] + + def _contact_sync_from_parent(self, cr, uid, partner, context=None): + """ Handle sync of contact fields when a new parent contact entity + is set, as if they were related fields + """ + if partner.contact_id: + contact_fields = self._contact_fields(cr, uid, context=context) + sync_vals = self._update_fields_values( + cr, uid, partner.contact_id, contact_fields, context=context + ) + partner.write(sync_vals) + + def update_contact(self, cr, uid, ids, vals, context=None): + if context is None: + context = {} + if context.get('__update_contact_lock'): + return + contact_fields = self._contact_fields(cr, uid, context=context) + contact_vals = dict( + (field, vals[field]) for field in contact_fields if field in vals + ) + if contact_vals: + ctx = dict(context, __update_contact_lock=True) + self.write(cr, uid, ids, contact_vals, context=ctx) + + def _fields_sync(self, cr, uid, partner, update_values, context=None): + """Sync commercial fields and address fields from company and to + children, contact fields from contact and to attached contact + after create/update, just as if those were all modeled as + fields.related to the parent + """ + super(res_partner, self)._fields_sync( + cr, uid, partner, update_values, context=context + ) + contact_fields = self._contact_fields(cr, uid, context=context) + # 1. From UPSTREAM: sync from parent contact + if update_values.get('contact_id'): + self._contact_sync_from_parent(cr, uid, partner, context=context) + # 2. To DOWNSTREAM: sync contact fields to parent or related + elif any(field in contact_fields for field in update_values): + update_ids = [ + c.id for c in partner.other_contact_ids if not c.is_company + ] + if partner.contact_id: + update_ids.append(partner.contact_id.id) + self.update_contact( + cr, uid, update_ids, update_values, context=context + ) + + def onchange_contact_id(self, cr, uid, ids, contact_id, context=None): + values = {} + if contact_id: + values['name'] = self.browse( + cr, uid, contact_id, context=context).name + return {'value': values} + + def onchange_contact_type(self, cr, uid, ids, contact_type, context=None): + values = {} + if contact_type == 'standalone': + values['contact_id'] = False + return {'value': values} + + +class ir_actions_window(orm.Model): + _inherit = 'ir.actions.act_window' + + def read( + self, cr, user, ids, fields=None, context=None, + load='_classic_read'): + action_ids = ids + if isinstance(ids, (int, long)): + action_ids = [ids] + actions = super(ir_actions_window, self).read( + cr, user, action_ids, fields=fields, context=context, load=load + ) + for action in actions: + if action.get('res_model', '') == 'res.partner': + # By default, only show standalone contact + action_context = action.get('context', '{}') or '{}' + if 'search_show_all_positions' not in action_context: + action['context'] = action_context.replace( + '{', "{'search_show_all_positions': False,", 1 + ) + if isinstance(ids, (int, long)): + if actions: + return actions[0] + return False + return actions diff --git a/partner_contact_in_several_companies/tests/__init__.py b/partner_contact_in_several_companies/tests/__init__.py new file mode 100644 index 000000000..bcbea6801 --- /dev/null +++ b/partner_contact_in_several_companies/tests/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 ⁻*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (C) 2013-TODAY OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import test_partner_contact_in_several_companies diff --git a/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py b/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py new file mode 100644 index 000000000..fef06fd58 --- /dev/null +++ b/partner_contact_in_several_companies/tests/test_partner_contact_in_several_companies.py @@ -0,0 +1,205 @@ +# -*- coding: utf-8 ⁻*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (C) 2013-TODAY OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.tests import common + + +class PartnerContactInSeveralCompaniesCase(common.TransactionCase): + + def setUp(self): + """*****setUp*****""" + super(PartnerContactInSeveralCompaniesCase, self).setUp() + cr, uid = self.cr, self.uid + ModelData = self.registry('ir.model.data') + self.partner = self.registry('res.partner') + + # Get test records reference + for attr, module, name in [ + ('main_partner_id', 'base', 'main_partner'), + ('bob_contact_id', + 'partner_contact_in_several_companies', + 'res_partner_contact1'), + ('bob_job1_id', + 'partner_contact_in_several_companies', + 'res_partner_contact1_work_position1'), + ('roger_contact_id', 'base', 'res_partner_main2'), + ('roger_job2_id', + 'partner_contact_in_several_companies', + 'res_partner_main2_position_consultant')]: + r = ModelData.get_object_reference(cr, uid, module, name) + setattr(self, attr, r[1] if r else False) + + def test_00_show_only_standalone_contact(self): + """Check that only standalone contact are shown if context + explicitly state to not display all positions + """ + cr, uid = self.cr, self.uid + ctx = {'search_show_all_positions': False} + partner_ids = self.partner.search(cr, uid, [], context=ctx) + partner_ids.sort() + self.assertTrue(self.bob_job1_id not in partner_ids) + self.assertTrue(self.roger_job2_id not in partner_ids) + + def test_01_show_all_positions(self): + """Check that all contact are show if context is empty or + explicitly state to display all positions + """ + cr, uid = self.cr, self.uid + + partner_ids = self.partner.search(cr, uid, [], context=None) + self.assertTrue(self.bob_job1_id in partner_ids) + self.assertTrue(self.roger_job2_id in partner_ids) + + ctx = {'search_show_all_positions': True} + partner_ids = self.partner.search(cr, uid, [], context=ctx) + self.assertTrue(self.bob_job1_id in partner_ids) + self.assertTrue(self.roger_job2_id in partner_ids) + + def test_02_reading_other_contact_one2many_show_all_positions(self): + """Check that readonly partner's ``other_contact_ids`` return + all values whatever the context + """ + cr, uid = self.cr, self.uid + + def read_other_contacts(pid, context=None): + return self.partner.read( + cr, uid, [pid], ['other_contact_ids'], + context=context)[0]['other_contact_ids'] + + def read_contacts(pid, context=None): + return self.partner.read( + cr, uid, [pid], ['child_ids'], context=context)[0]['child_ids'] + + ctx = None + self.assertEqual( + read_other_contacts(self.bob_contact_id, context=ctx), + [self.bob_job1_id], + ) + ctx = {'search_show_all_positions': False} + self.assertEqual(read_other_contacts( + self.bob_contact_id, context=ctx), + [self.bob_job1_id], + ) + ctx = {'search_show_all_positions': True} + self.assertEqual( + read_other_contacts(self.bob_contact_id, context=ctx), + [self.bob_job1_id], + ) + + ctx = None + self.assertIn( + self.bob_job1_id, + read_contacts(self.main_partner_id, context=ctx), + ) + ctx = {'search_show_all_positions': False} + self.assertIn( + self.bob_job1_id, + read_contacts(self.main_partner_id, context=ctx), + ) + ctx = {'search_show_all_positions': True} + self.assertIn( + self.bob_job1_id, + read_contacts(self.main_partner_id, context=ctx), + ) + + def test_03_search_match_attached_contacts(self): + """Check that searching partner also return partners having + attached contacts matching search criteria + """ + cr, uid = self.cr, self.uid + # Bob's contact has one other position which is related to + # 'YourCompany' + # so search for all contacts working for 'YourCompany' should contain + # bob position. + partner_ids = self.partner.search( + cr, uid, + [('parent_id', 'ilike', 'YourCompany')], + context=None + ) + self.assertIn(self.bob_job1_id, partner_ids, ) + + # but when searching without 'all positions', + # we should get the position standalone contact instead. + ctx = {'search_show_all_positions': False} + partner_ids = self.partner.search( + cr, uid, + [('parent_id', 'ilike', 'YourCompany')], + context=ctx + ) + self.assertIn(self.bob_contact_id, partner_ids, ) + + def test_04_contact_creation(self): + """Check that we're begin to create a contact""" + cr, uid = self.cr, self.uid + + # Create a contact using only name + new_contact_id = self.partner.create(cr, uid, {'name': 'Bob Egnops'}) + self.assertEqual( + self.partner.browse(cr, uid, new_contact_id).contact_type, + 'standalone', + ) + + # Create a contact with only contact_id + new_contact_id = self.partner.create( + cr, uid, {'contact_id': self.bob_contact_id} + ) + new_contact = self.partner.browse(cr, uid, new_contact_id) + self.assertEqual(new_contact.name, 'Bob Egnops') + self.assertEqual(new_contact.contact_type, 'attached') + + # Create a contact with both contact_id and name; + # contact's name should override provided value in that case + new_contact_id = self.partner.create( + cr, uid, {'contact_id': self.bob_contact_id, 'name': 'Rob Egnops'} + ) + self.assertEqual( + self.partner.browse(cr, uid, new_contact_id).name, + 'Bob Egnops' + ) + + # Reset contact to standalone + self.partner.write(cr, uid, [new_contact_id], {'contact_id': False}) + self.assertEqual( + self.partner.browse(cr, uid, new_contact_id).contact_type, + 'standalone', + ) + + def test_05_contact_fields_sync(self): + """Check that contact's fields are correctly synced between + parent contact or related contacts + """ + cr, uid = self.cr, self.uid + + # Test DOWNSTREAM sync + self.partner.write( + cr, uid, [self.bob_contact_id], {'name': 'Rob Egnops'} + ) + self.assertEqual( + self.partner.browse(cr, uid, self.bob_job1_id).name, + 'Rob Egnops', + ) + + # Test UPSTREAM sync + self.partner.write(cr, uid, [self.bob_job1_id], {'name': 'Bob Egnops'}) + self.assertEqual( + self.partner.browse(cr, uid, self.bob_contact_id).name, + 'Bob Egnops', + ) diff --git a/partner_contact_in_several_companies/views/res_partner.xml b/partner_contact_in_several_companies/views/res_partner.xml new file mode 100644 index 000000000..9026d1f96 --- /dev/null +++ b/partner_contact_in_several_companies/views/res_partner.xml @@ -0,0 +1,216 @@ + + + + + + res.partner.select.contact + res.partner + + + + + + + + + + + + + + res.partner.tree.contact + res.partner + + + + + + + + + + res.partner.form.contact + res.partner + + form + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ X +
+ + + + + + + + + + + + + + + + +
+
+ + + + +
+

+ + + + at + + +
Phone:
+
Mobile:
+
Fax:
+
+
+
+
+
+
+
+
+
+ + +
+
+ + + + + + + + + + +
+
+ + + +
+
+
+
+
+ + + + + + + + + {'invisible': [('contact_type','=','attached')]} + +
+
+ + + Contacts in several partners: personal info + res.partner + + + + +

+ To see personal information about this contact, please + go to to the his person form: + +

+
+
+
+
+ + + res.partner.kanban.contact + res.partner + + + + + + + + + + + + +
  • + + other position + other positions
  • +
    +
    +
    +
    + +
    +