Yannick Vaucher
12 years ago
4 changed files with 196 additions and 0 deletions
-
24res_partner_affiliate/__init__.py
-
42res_partner_affiliate/__openerp__.py
-
38res_partner_affiliate/res_partner.py
-
92res_partner_affiliate/res_partner_view.xml
@ -0,0 +1,24 @@ |
|||||
|
# -*- 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
|
||||
|
import res_partner |
||||
|
|
||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
@ -0,0 +1,42 @@ |
|||||
|
# -*- 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/>. |
||||
|
# |
||||
|
############################################################################## |
||||
|
{'name' : 'Partner Affilates', |
||||
|
'version' : '1.0', |
||||
|
'author' : 'Camptocamp', |
||||
|
'maintainer': 'Camptocamp', |
||||
|
'category': 'CRM', |
||||
|
'complexity': "normal", # easy, normal, expert |
||||
|
'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', |
||||
|
'init_xml': [], |
||||
|
'update_xml': [ |
||||
|
'res_partner_view.xml', |
||||
|
], |
||||
|
'demo_xml': [], |
||||
|
'tests': [], |
||||
|
'installable': True, |
||||
|
'images': [], |
||||
|
'auto_install': False, |
||||
|
'license': 'AGPL-3', |
||||
|
'application': True} |
||||
|
|
@ -0,0 +1,38 @@ |
|||||
|
# -*- 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 osv, fields |
||||
|
|
||||
|
class ResPartner(osv.osv): |
||||
|
""" |
||||
|
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)]), |
||||
|
#'lot_count': fields.function(_count_related, string="Lot", type='integer', multi='count_rel'), |
||||
|
} |
@ -0,0 +1,92 @@ |
|||||
|
<?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}" 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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue