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
=== added directory 'res_partner_affiliate'
=== added file 'res_partner_affiliate/__init__.py'
--- res_partner_affiliate/__init__.py 1970-01-01 00:00:00 +0000
+++ res_partner_affiliate/__init__.py 2013-01-24 08:23:21 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Yannick Vaucher
5# Copyright 2012 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import res_partner
23
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
025
=== added file 'res_partner_affiliate/__openerp__.py'
--- res_partner_affiliate/__openerp__.py 1970-01-01 00:00:00 +0000
+++ res_partner_affiliate/__openerp__.py 2013-01-24 08:23:21 +0000
@@ -0,0 +1,42 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Yannick Vaucher
5# Copyright 2012 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{'name': 'Partner Affilates',
22 'version': '1.0',
23 'author': 'Camptocamp',
24 'maintainer': 'Camptocamp',
25 'category': 'CRM',
26 'complexity': 'normal', # easy, normal, expert
27 'depends': ['base'],
28 'description': """Allows to use parent_id in company partner to refer to a parent company
29 Plus will show a tab in parent company of affiliated companies""",
30 'website': 'http://www.camptocamp.com',
31 'init_xml': [],
32 'update_xml': [
33 'res_partner_view.xml',
34 ],
35 'demo_xml': [],
36 'tests': [],
37 'installable': True,
38 'images': [],
39 'auto_install': False,
40 'license': 'AGPL-3',
41 'application': True}
42
043
=== added file 'res_partner_affiliate/res_partner.py'
--- res_partner_affiliate/res_partner.py 1970-01-01 00:00:00 +0000
+++ res_partner_affiliate/res_partner.py 2013-01-24 08:23:21 +0000
@@ -0,0 +1,37 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Yannick Vaucher
5# Copyright 2012 Camptocamp SA
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21from openerp.osv import orm, fields
22
23class ResPartner(orm.Model):
24 """
25 Add relation affiliate_ids
26 """
27 _name = "res.partner"
28 _inherit = "res.partner"
29
30 _columns = {
31 'child_ids': fields.one2many(
32 'res.partner', 'parent_id',
33 'Contacts', domain=[('is_company', '=', False)]),
34 'affiliate_ids': fields.one2many(
35 'res.partner', 'parent_id',
36 'Affiliates', domain=[('is_company', '=', True)]),
37 }
038
=== added file 'res_partner_affiliate/res_partner_view.xml'
--- res_partner_affiliate/res_partner_view.xml 1970-01-01 00:00:00 +0000
+++ res_partner_affiliate/res_partner_view.xml 2013-01-24 08:23:21 +0000
@@ -0,0 +1,92 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5
6 <!-- Form view -->
7
8 <!-- Show always parent_id plus add affiliates -->
9 <record id="view_partner_form_add_affiliate" model="ir.ui.view">
10 <field name="name">res.partner.form</field>
11 <field name="model">res.partner</field>
12 <field eval="1" name="priority"/>
13 <field name="inherit_id" ref="base.view_partner_form"/>
14 <field name="arch" type="xml">
15 <field name="parent_id" position="attributes">
16 <attribute name="attrs"></attribute>
17 </field>
18 <page string="Contacts" position="after">
19 <page string="Affiliates" attrs="{'invisible': [('is_company','=',False)]}">
20 <field name="affiliate_ids" context="{'default_parent_id': active_id}" mode="kanban">
21 <kanban>
22 <field name="color"/>
23 <field name="name"/>
24 <field name="title"/>
25 <field name="email"/>
26 <field name="parent_id"/>
27 <field name="is_company"/>
28 <field name="function"/>
29 <field name="phone"/>
30 <field name="street"/>
31 <field name="street2"/>
32 <field name="zip"/>
33 <field name="city"/>
34 <field name="country_id"/>
35 <field name="mobile"/>
36 <field name="fax"/>
37 <field name="state_id"/>
38 <field name="has_image"/>
39 <templates>
40 <t t-name="kanban-box">
41 <t t-set="color" t-value="kanban_color(record.color.raw_value)"/>
42 <div t-att-class="color + (record.title.raw_value == 1 ? ' oe_kanban_color_alert' : '')" style="position: relative">
43 <a t-if="! read_only_mode" type="delete" style="position: absolute; right: 0; padding: 4px; diplay: inline-block">X</a>
44 <div class="oe_module_vignette">
45 <a type="open">
46 <t t-if="record.has_image.raw_value === true">
47 <img t-att-src="kanban_image('res.partner', 'image', record.id.value, {'preview_image': 'image_small'})" class="oe_avatar oe_kanban_avatar_smallbox"/>
48 </t>
49 <t t-if="record.image and record.image.raw_value !== false">
50 <img t-att-src="'data:image/png;base64,'+record.image.raw_value" class="oe_avatar oe_kanban_avatar_smallbox"/>
51 </t>
52 <t t-if="record.has_image.raw_value === false and (!record.image or record.image.raw_value === false)">
53 <t t-if="record.is_company.raw_value === true">
54 <img t-att-src='_s + "/base/static/src/img/company_image.png"' class="oe_kanban_image oe_kanban_avatar_smallbox"/>
55 </t>
56 <t t-if="record.is_company.raw_value === false">
57 <img t-att-src='_s + "/base/static/src/img/avatar.png"' class="oe_kanban_image oe_kanban_avatar_smallbox"/>
58 </t>
59 </t>
60 </a>
61 <div class="oe_module_desc">
62 <div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_color_border">
63 <table class="oe_kanban_table">
64 <tr>
65 <td class="oe_kanban_title1" align="left" valign="middle">
66 <h4><a type="open"><field name="name"/></a></h4>
67 <i><div t-if="record.function.raw_value">
68 <field name="function"/></div></i>
69 <div><a t-if="record.email.raw_value" title="Mail" t-att-href="'mailto:'+record.email.value">
70 <field name="email"/>
71 </a></div>
72 <div t-if="record.phone.raw_value">Phone: <field name="phone"/></div>
73 <div t-if="record.mobile.raw_value">Mobile: <field name="mobile"/></div>
74 <div t-if="record.fax.raw_value">Fax: <field name="fax"/></div>
75 </td>
76 </tr>
77 </table>
78 </div>
79 </div>
80 </div>
81 </div>
82 </t>
83 </templates>
84 </kanban>
85 </field>
86 </page>
87 </page>
88 </field>
89 </record>
90
91 </data>
92</openerp>

Subscribers

People subscribed via source and target branches

to status/vote changes: