Browse Source

[9.0][MIG] res_partner_affiliate module

- Updated views
- Created README
- Updated file structure
pull/368/head
cubells 8 years ago
committed by Pedro M. Baeza
parent
commit
7fd5797267
  1. 58
      res_partner_affiliate/README.rst
  2. 23
      res_partner_affiliate/__init__.py
  3. 45
      res_partner_affiliate/__openerp__.py
  4. 5
      res_partner_affiliate/models/__init__.py
  5. 18
      res_partner_affiliate/models/res_partner.py
  6. 39
      res_partner_affiliate/res_partner.py
  7. 92
      res_partner_affiliate/res_partner_view.xml
  8. 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 -*- # -*- 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 -*- # -*- 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', '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', 'category': 'CRM',
'license': 'AGPL-3', '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': [ 'data': [
'res_partner_view.xml',
'views/res_partner_view.xml',
], ],
'demo': [],
'installable': False,
'auto_install': False,
'application': True
} }

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