Merge lp:~camptocamp/partner-contact-management/7.0-add-partner-affiliate into lp:~partner-contact-core-editors/partner-contact-management/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merge reported by: Joël Grand-Guillaume @ camptocamp
Merged at revision: not available
Proposed branch: lp:~camptocamp/partner-contact-management/7.0-add-partner-affiliate
Merge into: lp:~partner-contact-core-editors/partner-contact-management/7.0
Diff against target: 215 lines (+195/-0)
4 files modified
res_partner_affiliate/__init__.py (+24/-0)
res_partner_affiliate/__openerp__.py (+42/-0)
res_partner_affiliate/res_partner.py (+37/-0)
res_partner_affiliate/res_partner_view.xml (+92/-0)
To merge this branch: bzr merge lp:~camptocamp/partner-contact-management/7.0-add-partner-affiliate
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp no test, code review Approve
Nicolas Bessi - Camptocamp (community) Needs Fixing
Review via email: mp+144516@code.launchpad.net

Description of the change

Add module res_partner_affiliate

It assumes other modules takes care of checking if current partner is a company or not before using parent_id

Like in openobject-addons/account_invoice.py:1273

To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello,

There is some styling error here and there, for example sometime there is spaces before ":" sometime not. Some indentation trouble in _columns. A quick pass into a pep8 checker would be nice.

You should not use osv.osv any more but orm.Model:
From openerp.osv import orm, fields

You should suppress commented line:

+ #'lot_count': fields.function(_count_related, string="Lot", type='integer', multi='count_rel'),

Shouldn't you also add a form view under the kanban view you add ?

Tanks

Regards

Nicolas

review: Needs Fixing
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

I made the python corrections

About a form view under the kanban one, I prefer to let this this way to use the complete default res_partner form view.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

So, it allows to have a hierarchy of companies? I think the manifest of the addon deserves a better description.

Otherwise, LGTM.

review: Approve (no test, code review)
11. By Yannick Vaucher @ Camptocamp

[MRG] [ADD] res_partner_affiliate module to deal with complex company structure (Parent company -> company -> partner)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'res_partner_affiliate'
2=== added file 'res_partner_affiliate/__init__.py'
3--- res_partner_affiliate/__init__.py 1970-01-01 00:00:00 +0000
4+++ res_partner_affiliate/__init__.py 2013-01-24 08:23:21 +0000
5@@ -0,0 +1,24 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Yannick Vaucher
10+# Copyright 2012 Camptocamp SA
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+import res_partner
28+
29+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
30
31=== added file 'res_partner_affiliate/__openerp__.py'
32--- res_partner_affiliate/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ res_partner_affiliate/__openerp__.py 2013-01-24 08:23:21 +0000
34@@ -0,0 +1,42 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# Author: Yannick Vaucher
39+# Copyright 2012 Camptocamp SA
40+#
41+# This program is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU Affero General Public License as
43+# published by the Free Software Foundation, either version 3 of the
44+# License, or (at your option) any later version.
45+#
46+# This program is distributed in the hope that it will be useful,
47+# but WITHOUT ANY WARRANTY; without even the implied warranty of
48+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+# GNU Affero General Public License for more details.
50+#
51+# You should have received a copy of the GNU Affero General Public License
52+# along with this program. If not, see <http://www.gnu.org/licenses/>.
53+#
54+##############################################################################
55+{'name': 'Partner Affilates',
56+ 'version': '1.0',
57+ 'author': 'Camptocamp',
58+ 'maintainer': 'Camptocamp',
59+ 'category': 'CRM',
60+ 'complexity': 'normal', # easy, normal, expert
61+ 'depends': ['base'],
62+ 'description': """Allows to use parent_id in company partner to refer to a parent company
63+ Plus will show a tab in parent company of affiliated companies""",
64+ 'website': 'http://www.camptocamp.com',
65+ 'init_xml': [],
66+ 'update_xml': [
67+ 'res_partner_view.xml',
68+ ],
69+ 'demo_xml': [],
70+ 'tests': [],
71+ 'installable': True,
72+ 'images': [],
73+ 'auto_install': False,
74+ 'license': 'AGPL-3',
75+ 'application': True}
76+
77
78=== added file 'res_partner_affiliate/res_partner.py'
79--- res_partner_affiliate/res_partner.py 1970-01-01 00:00:00 +0000
80+++ res_partner_affiliate/res_partner.py 2013-01-24 08:23:21 +0000
81@@ -0,0 +1,37 @@
82+# -*- coding: utf-8 -*-
83+##############################################################################
84+#
85+# Author: Yannick Vaucher
86+# Copyright 2012 Camptocamp SA
87+#
88+# This program is free software: you can redistribute it and/or modify
89+# it under the terms of the GNU Affero General Public License as
90+# published by the Free Software Foundation, either version 3 of the
91+# License, or (at your option) any later version.
92+#
93+# This program is distributed in the hope that it will be useful,
94+# but WITHOUT ANY WARRANTY; without even the implied warranty of
95+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+# GNU Affero General Public License for more details.
97+#
98+# You should have received a copy of the GNU Affero General Public License
99+# along with this program. If not, see <http://www.gnu.org/licenses/>.
100+#
101+##############################################################################
102+from openerp.osv import orm, fields
103+
104+class ResPartner(orm.Model):
105+ """
106+ Add relation affiliate_ids
107+ """
108+ _name = "res.partner"
109+ _inherit = "res.partner"
110+
111+ _columns = {
112+ 'child_ids': fields.one2many(
113+ 'res.partner', 'parent_id',
114+ 'Contacts', domain=[('is_company', '=', False)]),
115+ 'affiliate_ids': fields.one2many(
116+ 'res.partner', 'parent_id',
117+ 'Affiliates', domain=[('is_company', '=', True)]),
118+ }
119
120=== added file 'res_partner_affiliate/res_partner_view.xml'
121--- res_partner_affiliate/res_partner_view.xml 1970-01-01 00:00:00 +0000
122+++ res_partner_affiliate/res_partner_view.xml 2013-01-24 08:23:21 +0000
123@@ -0,0 +1,92 @@
124+<?xml version="1.0" encoding="utf-8"?>
125+<openerp>
126+ <data>
127+
128+
129+ <!-- Form view -->
130+
131+ <!-- Show always parent_id plus add affiliates -->
132+ <record id="view_partner_form_add_affiliate" model="ir.ui.view">
133+ <field name="name">res.partner.form</field>
134+ <field name="model">res.partner</field>
135+ <field eval="1" name="priority"/>
136+ <field name="inherit_id" ref="base.view_partner_form"/>
137+ <field name="arch" type="xml">
138+ <field name="parent_id" position="attributes">
139+ <attribute name="attrs"></attribute>
140+ </field>
141+ <page string="Contacts" position="after">
142+ <page string="Affiliates" attrs="{'invisible': [('is_company','=',False)]}">
143+ <field name="affiliate_ids" context="{'default_parent_id': active_id}" mode="kanban">
144+ <kanban>
145+ <field name="color"/>
146+ <field name="name"/>
147+ <field name="title"/>
148+ <field name="email"/>
149+ <field name="parent_id"/>
150+ <field name="is_company"/>
151+ <field name="function"/>
152+ <field name="phone"/>
153+ <field name="street"/>
154+ <field name="street2"/>
155+ <field name="zip"/>
156+ <field name="city"/>
157+ <field name="country_id"/>
158+ <field name="mobile"/>
159+ <field name="fax"/>
160+ <field name="state_id"/>
161+ <field name="has_image"/>
162+ <templates>
163+ <t t-name="kanban-box">
164+ <t t-set="color" t-value="kanban_color(record.color.raw_value)"/>
165+ <div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '')" style="position: relative">
166+ <a t-if="! read_only_mode" type="delete" style="position: absolute; right: 0; padding: 4px; diplay: inline-block">X</a>
167+ <div class="oe_module_vignette">
168+ <a type="open">
169+ <t t-if="record.has_image.raw_value === true">
170+ <img t-att-src="kanban_image('res.partner', 'image', record.id.value, {'preview_image': 'image_small'})" class="oe_avatar oe_kanban_avatar_smallbox"/>
171+ </t>
172+ <t t-if="record.image and record.image.raw_value !== false">
173+ <img t-att-src="'data:image/png;base64,'+record.image.raw_value" class="oe_avatar oe_kanban_avatar_smallbox"/>
174+ </t>
175+ <t t-if="record.has_image.raw_value === false and (!record.image or record.image.raw_value === false)">
176+ <t t-if="record.is_company.raw_value === true">
177+ <img t-att-src='_s + "/base/static/src/img/company_image.png"' class="oe_kanban_image oe_kanban_avatar_smallbox"/>
178+ </t>
179+ <t t-if="record.is_company.raw_value === false">
180+ <img t-att-src='_s + "/base/static/src/img/avatar.png"' class="oe_kanban_image oe_kanban_avatar_smallbox"/>
181+ </t>
182+ </t>
183+ </a>
184+ <div class="oe_module_desc">
185+ <div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_color_border">
186+ <table class="oe_kanban_table">
187+ <tr>
188+ <td class="oe_kanban_title1" align="left" valign="middle">
189+ <h4><a type="open"><field name="name"/></a></h4>
190+ <i><div t-if="record.function.raw_value">
191+ <field name="function"/></div></i>
192+ <div><a t-if="record.email.raw_value" title="Mail" t-att-href="'mailto:'+record.email.value">
193+ <field name="email"/>
194+ </a></div>
195+ <div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
196+ <div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
197+ <div t-if="record.fax.raw_value">Fax: <field name="fax"/></div>
198+ </td>
199+ </tr>
200+ </table>
201+ </div>
202+ </div>
203+ </div>
204+ </div>
205+ </t>
206+ </templates>
207+ </kanban>
208+ </field>
209+ </page>
210+ </page>
211+ </field>
212+ </record>
213+
214+ </data>
215+</openerp>

Subscribers

People subscribed via source and target branches

to status/vote changes: