Browse Source

Merge pull request #368 from Tecnativa/9.0-mig-res_partner_affiliate

[9.0][MIG] res_partner_affiliate module
pull/384/head
Pedro M. Baeza 8 years ago
committed by GitHub
parent
commit
a305bcb990
  1. 58
      res_partner_affiliate/README.rst
  2. 23
      res_partner_affiliate/__init__.py
  3. 45
      res_partner_affiliate/__openerp__.py
  4. 13
      res_partner_affiliate/i18n/de.po
  5. 9
      res_partner_affiliate/i18n/es.po
  6. 50
      res_partner_affiliate/i18n/fi.po
  7. 50
      res_partner_affiliate/i18n/it.po
  8. 5
      res_partner_affiliate/models/__init__.py
  9. 18
      res_partner_affiliate/models/res_partner.py
  10. 39
      res_partner_affiliate/res_partner.py
  11. 92
      res_partner_affiliate/res_partner_view.xml
  12. 79
      res_partner_affiliate/views/res_partner_view.xml

58
res_partner_affiliate/README.rst

@ -0,0 +1,58 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==================
Partner Affiliates
==================
This module allows to use parent_id in company partner to refer to a parent
company, plus will show a tab in parent company of affiliated companies.
Usage
=====
New tab 'Affiliates' are available on the contact form if partner is company.
In tab 'Contact & Addresses' only are shown those contacts that are not
companies.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/9.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/partner-contact/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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
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 https://odoo-community.org.

23
res_partner_affiliate/__init__.py

@ -1,22 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2012 Camptocamp 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2012 Camptocamp SA - Yannick Vaucher
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import res_partner
from . import models

45
res_partner_affiliate/__openerp__.py

@ -1,40 +1,21 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2012 Camptocamp 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2012 Camptocamp SA - Yannick Vaucher
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Partner Affiliates',
'version': '8.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'maintainer': 'Camptocamp',
'version': '9.0.1.0.0',
'author': "Camptocamp, "
"Tecnativa, "
"Odoo Community Association (OCA)",
'website': 'http://www.camptocamp.com',
'category': 'CRM',
'license': 'AGPL-3',
'depends': ['base'],
'description': """
Allows to use parent_id in company partner to refer to a parent company
Plus will show a tab in parent company of affiliated companies""",
'website': 'http://www.camptocamp.com',
'installable': True,
'depends': [
'base'
],
'data': [
'res_partner_view.xml',
'views/res_partner_view.xml',
],
'demo': [],
'installable': False,
'auto_install': False,
'application': True
}

13
res_partner_affiliate/i18n/de.po

@ -3,13 +3,14 @@
# * res_partner_affiliate
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2016
msgid ""
msgstr ""
"Project-Id-Version: partner-contact (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-08-28 15:54+0000\n"
"PO-Revision-Date: 2015-05-22 13:07+0000\n"
"Last-Translator: Maxime Chambreuil <maxime.chambreuil@gmail.com>\n"
"POT-Creation-Date: 2016-01-19 01:46+0000\n"
"PO-Revision-Date: 2016-01-18 08:09+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
"Language-Team: German (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -26,12 +27,12 @@ msgstr "Tochtergesellschaften"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Contacts"
msgstr ""
msgstr "Kontakte"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Fax:"
msgstr ""
msgstr "Fax:"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
@ -41,7 +42,7 @@ msgstr "Mobil:"
#. module: res_partner_affiliate
#: model:ir.model,name:res_partner_affiliate.model_res_partner
msgid "Partner"
msgstr ""
msgstr "Partner"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate

9
res_partner_affiliate/i18n/es.po

@ -3,13 +3,14 @@
# * res_partner_affiliate
#
# Translators:
# Antonio Trueba, 2016
msgid ""
msgstr ""
"Project-Id-Version: partner-contact (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-08-28 15:54+0000\n"
"PO-Revision-Date: 2015-05-22 13:07+0000\n"
"Last-Translator: Maxime Chambreuil <maxime.chambreuil@gmail.com>\n"
"POT-Creation-Date: 2016-01-19 01:46+0000\n"
"PO-Revision-Date: 2016-01-16 15:06+0000\n"
"Last-Translator: Antonio Trueba\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -26,7 +27,7 @@ msgstr "Filiales"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Contacts"
msgstr ""
msgstr "Contactos"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate

50
res_partner_affiliate/i18n/fi.po

@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_partner_affiliate
#
# Translators:
# Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: partner-contact (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-19 01:46+0000\n"
"PO-Revision-Date: 2016-01-27 20:34+0000\n"
"Last-Translator: Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>\n"
"Language-Team: Finnish (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/fi/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fi\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
#: field:res.partner,affiliate_ids:0
msgid "Affiliates"
msgstr "Yhteistyökumppanit"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Contacts"
msgstr "Kontaktit"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Fax:"
msgstr "Faksi:"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Mobile:"
msgstr "Kännykkä:"
#. module: res_partner_affiliate
#: model:ir.model,name:res_partner_affiliate.model_res_partner
msgid "Partner"
msgstr "Kumppani"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Phone:"
msgstr "Puhelin:"

50
res_partner_affiliate/i18n/it.po

@ -0,0 +1,50 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * res_partner_affiliate
#
# Translators:
# Paolo Valier, 2016
msgid ""
msgstr ""
"Project-Id-Version: partner-contact (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-03-13 00:57+0000\n"
"PO-Revision-Date: 2016-03-13 13:09+0000\n"
"Last-Translator: Paolo Valier\n"
"Language-Team: Italian (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
#: field:res.partner,affiliate_ids:0
msgid "Affiliates"
msgstr "Affiliati"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Contacts"
msgstr "Contatti"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Fax:"
msgstr "Fax:"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Mobile:"
msgstr "Cellulare:"
#. module: res_partner_affiliate
#: model:ir.model,name:res_partner_affiliate.model_res_partner
msgid "Partner"
msgstr "Partner"
#. module: res_partner_affiliate
#: view:res.partner:res_partner_affiliate.view_partner_form_add_affiliate
msgid "Phone:"
msgstr ""

5
res_partner_affiliate/models/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Camptocamp SA - Yannick Vaucher
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import res_partner

18
res_partner_affiliate/models/res_partner.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Camptocamp SA - Yannick Vaucher
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import fields, models
class ResPartner(models.Model):
"""Add relation affiliate_ids."""
_inherit = "res.partner"
child_ids = fields.One2many(domain=[('is_company', '=', False)])
affiliate_ids = fields.One2many(
comodel_name='res.partner',
inverse_name='parent_id',
string='Affiliates',
domain=[('is_company', '=', True)],
)

39
res_partner_affiliate/res_partner.py

@ -1,39 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2012 Camptocamp 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class ResPartner(orm.Model):
"""
Add relation affiliate_ids
"""
_name = "res.partner"
_inherit = "res.partner"
_columns = {
'child_ids': fields.one2many(
'res.partner', 'parent_id',
'Contacts', domain=[('is_company', '=', False)]),
'affiliate_ids': fields.one2many(
'res.partner', 'parent_id',
'Affiliates', domain=[('is_company', '=', True)]),
}

92
res_partner_affiliate/res_partner_view.xml

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Form view -->
<!-- Show always parent_id plus add affiliates -->
<record id="view_partner_form_add_affiliate" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field eval="1" name="priority"/>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="parent_id" position="attributes">
<attribute name="attrs"></attribute>
</field>
<page string="Contacts" position="after">
<page string="Affiliates" attrs="{'invisible': [('is_company','=',False)]}">
<field name="affiliate_ids" context="{'default_parent_id': active_id, 'default_is_company': True}" mode="kanban">
<kanban>
<field name="color"/>
<field name="name"/>
<field name="title"/>
<field name="email"/>
<field name="parent_id"/>
<field name="is_company"/>
<field name="function"/>
<field name="phone"/>
<field name="street"/>
<field name="street2"/>
<field name="zip"/>
<field name="city"/>
<field name="country_id"/>
<field name="mobile"/>
<field name="fax"/>
<field name="state_id"/>
<field name="has_image"/>
<templates>
<t t-name="kanban-box">
<t t-set="color" t-value="kanban_color(record.color.raw_value)"/>
<div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '')" style="position: relative">
<a t-if="! read_only_mode" type="delete" style="position: absolute; right: 0; padding: 4px; diplay: inline-block">X</a>
<div class="oe_module_vignette">
<a type="open">
<t t-if="record.has_image.raw_value === true">
<img t-att-src="kanban_image('res.partner', 'image', record.id.value, {'preview_image': 'image_small'})" class="oe_avatar oe_kanban_avatar_smallbox"/>
</t>
<t t-if="record.image and record.image.raw_value !== false">
<img t-att-src="'data:image/png;base64,'+record.image.raw_value" class="oe_avatar oe_kanban_avatar_smallbox"/>
</t>
<t t-if="record.has_image.raw_value === false and (!record.image or record.image.raw_value === false)">
<t t-if="record.is_company.raw_value === true">
<img t-att-src='_s + "/base/static/src/img/company_image.png"' class="oe_kanban_image oe_kanban_avatar_smallbox"/>
</t>
<t t-if="record.is_company.raw_value === false">
<img t-att-src='_s + "/base/static/src/img/avatar.png"' class="oe_kanban_image oe_kanban_avatar_smallbox"/>
</t>
</t>
</a>
<div class="oe_module_desc">
<div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_color_border">
<table class="oe_kanban_table">
<tr>
<td class="oe_kanban_title1" align="left" valign="middle">
<h4><a type="open"><field name="name"/></a></h4>
<i><div t-if="record.function.raw_value">
<field name="function"/></div></i>
<div><a t-if="record.email.raw_value" title="Mail" t-att-href="'mailto:'+record.email.value">
<field name="email"/>
</a></div>
<div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
<div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
<div t-if="record.fax.raw_value">Fax: <field name="fax"/></div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</page>
</page>
</field>
</record>
</data>
</openerp>

79
res_partner_affiliate/views/res_partner_view.xml

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Show always parent_id plus add affiliates -->
<record id="view_partner_form_add_affiliate" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field eval="1" name="priority"/>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet//div[@class='o_row']/field[@name='parent_id']" position="attributes">
<attribute name="attrs"></attribute>
</xpath>
<xpath expr='//page[@name="internal_notes"]' position="before">
<page string="Affiliates" attrs="{'invisible': [('is_company','=',False)]}">
<field name="affiliate_ids" context="{'default_parent_id': active_id, 'default_is_company': True}" mode="kanban">
<kanban>
<field name="color"/>
<field name="name"/>
<field name="title"/>
<field name="type"/>
<field name="email"/>
<field name="parent_id"/>
<field name="is_company"/>
<field name="function"/>
<field name="phone"/>
<field name="street"/>
<field name="street2"/>
<field name="zip"/>
<field name="city"/>
<field name="country_id"/>
<field name="mobile"/>
<field name="fax"/>
<field name="state_id"/>
<field name="image"/>
<field name="lang"/>
<templates>
<t t-name="kanban-box">
<t t-set="color" t-value="kanban_color(record.color.raw_value)"/>
<div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '') + ' oe_kanban_global_click'">
<a t-if="!read_only_mode" type="delete" class="fa fa-times pull-right"/>
<div class="o_kanban_image">
<img t-if="record.image.raw_value" t-att-src="'data:image/png;base64,'+record.image.raw_value"/>
<t t-if="!record.image.raw_value">
<img t-if="record.type.raw_value === 'delivery'" t-att-src='_s + "/base/static/src/img/truck.png"'/>
<img t-if="record.type.raw_value === 'invoice'" t-att-src='_s + "/base/static/src/img/money.png"'/>
<t t-if="record.type.raw_value !== 'invoice' &amp;&amp; record.type.raw_value !== 'delivery'">
<img t-if="record.is_company.raw_value === true" t-att-src='_s + "/base/static/src/img/company_image.png"'/>
<img t-if="record.is_company.raw_value === false" t-att-src='_s + "/base/static/src/img/avatar.png"'/>
</t>
</t>
</div>
<div class="oe_kanban_details">
<field name="name"/>
<div t-if="record.function.raw_value"><field name="function"/></div>
<div t-if="record.email.raw_value"><field name="email"/></div>
<div t-if="record.type.raw_value != 'contact'">
<div>
<field name="zip"/>
<field name="city"/>
</div>
<field t-if="record.state_id.raw_value" name="state_id"/>
<field name="country_id"/>
</div>
<div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
<div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
<div t-if="record.fax.raw_value">Fax: <field name="fax"/></div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</page>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save