Merge lp:~therp-nl/partner-contact-management/7.0-base_partner_sequence_commercial_partner into lp:~initos.com/partner-contact-management/7.0

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 34
Proposed branch: lp:~therp-nl/partner-contact-management/7.0-base_partner_sequence_commercial_partner
Merge into: lp:~initos.com/partner-contact-management/7.0
Diff against target: 108 lines (+45/-9)
3 files modified
base_partner_sequence/__openerp__.py (+12/-3)
base_partner_sequence/partner.py (+13/-6)
base_partner_sequence/partner_view.xml (+20/-0)
To merge this branch: bzr merge lp:~therp-nl/partner-contact-management/7.0-base_partner_sequence_commercial_partner
Reviewer Review Type Date Requested Status
Thomas Rehn Approve
Pedro Manuel Baeza (community) Approve
Review via email: mp+195742@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

OK, I see the changes very clear.

Thanks for proposing them.

You may credit yourself on contributors key of the manifest file.

Regards.

review: Approve
Revision history for this message
Thomas Rehn (thomas-rehn) wrote :

Thanks for helping with this module. I fully agree with the new 'ref-needed' logic based on parent.

What I don't understand is the partial 'readonly' logic in partner_view.xml. Why and in which cases must the 'ref'-field be editable? Why not set the field to be readonly all the time? With the new 'readinly'-domain, the 'ref'-field can always be edited when, for instance, a new customer is created.

review: Needs Information
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Thomas, the partial read-only is for enabling the possibility to put a manual reference in a given moment: imagine you are adding an old customer that has an old reference or that you need a customer with an special reference (a priority client). With this option you can do both.

Regards.

Revision history for this message
Thomas Rehn (thomas-rehn) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_partner_sequence/__openerp__.py'
2--- base_partner_sequence/__openerp__.py 2013-11-15 10:09:34 +0000
3+++ base_partner_sequence/__openerp__.py 2013-11-19 10:59:32 +0000
4@@ -23,7 +23,7 @@
5 {
6 "name": "Add a sequence on customers' code",
7 "version": "1.1",
8- "author": "initOS GmbH & Co. KG",
9+ "author": "Tiny/initOS GmbH & Co. KG",
10 "category": "Generic Modules/Base",
11 "website": "http://www.initos.com",
12 "depends": ["base"],
13@@ -31,13 +31,22 @@
14 "description": """
15 This module adds the possibility to define a sequence for
16 the partner code. This code is then set as default when you
17- create a new customer or supplier, using the defined sequence.
18+ create a new commercial partner, using the defined sequence.
19+
20+ The reference field is treated as a commercial field, i.e. it
21+ is managed from the commercial partner and then propagated to
22+ the partner's contacts. The field is visible on the contacts,
23+ but it can only be modified from the commercial partner.
24+
25 No codes are assigned for contacts such as shipping and
26 invoice addresses.
27 This module is a migration of the original base_partner_sequence
28 addon to OpenERP version 7.0.
29 """,
30- "data": ['partner_sequence.xml'],
31+ "data": [
32+ 'partner_sequence.xml',
33+ 'partner_view.xml',
34+ ],
35 "demo": [],
36 "active": False,
37 "installable": True
38
39=== modified file 'base_partner_sequence/partner.py'
40--- base_partner_sequence/partner.py 2013-11-15 10:14:58 +0000
41+++ base_partner_sequence/partner.py 2013-11-19 10:59:32 +0000
42@@ -32,13 +32,13 @@
43 def create(self, cr, uid, vals, context=None):
44 context = context or {}
45 if not vals.get('ref') and self._needsRef(cr, uid, vals=vals, context=context):
46- vals['ref'] = self.pool.get('ir.sequence').get(cr, uid, 'res.partner')
47+ vals['ref'] = self.pool.get('ir.sequence').next_by_code(cr, uid, 'res.partner')
48 return super(ResPartner, self).create(cr, uid, vals, context)
49
50 def copy(self, cr, uid, id, default=None, context=None):
51 default = default or {}
52 if not default.get('ref') and self._needsRef(cr, uid, id=id, context=context):
53- default['ref'] = self.pool.get('ir.sequence').get(cr, uid, 'res.partner', context=context)
54+ default['ref'] = self.pool.get('ir.sequence').next_by_code(cr, uid, 'res.partner', context=context)
55 return super(ResPartner, self).copy(cr, uid, id, default, context=context)
56
57 def _needsRef(self, cr, uid, id=None, vals=None, context=None):
58@@ -53,14 +53,21 @@
59 """
60 if not vals and not id:
61 raise Exception('Either field values or an id must be provided.')
62- # only assign a 'ref' if it is a customer or supplier and
63- # if it not a child object (such as a shipping/invoice address)
64+ # only assign a 'ref' to commercial partners
65 if id:
66- vals = self.read(cr, uid, id, ['parent_id', 'customer', 'supplier'], context=context)
67- return not vals.get('parent_id') and (vals.get('customer') or vals.get('supplier'))
68+ vals = self.read(cr, uid, id, ['parent_id', 'is_company'], context=context)
69+ return vals.get('is_company') or not vals.get('parent_id')
70
71 _columns = {
72 'ref': fields.char('Reference', size=64, readonly=True),
73 }
74
75+ def _commercial_fields(self, cr, uid, context=None):
76+ """
77+ Make the partner reference a field that is propagated
78+ to the partner's contacts
79+ """
80+ return super(ResPartner, self)._commercial_fields(
81+ cr, uid, context=context) + ['ref']
82+
83 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
84
85=== added file 'base_partner_sequence/partner_view.xml'
86--- base_partner_sequence/partner_view.xml 1970-01-01 00:00:00 +0000
87+++ base_partner_sequence/partner_view.xml 2013-11-19 10:59:32 +0000
88@@ -0,0 +1,20 @@
89+<?xml version="1.0" encoding="UTF-8"?>
90+<openerp>
91+ <data>
92+
93+ <record id="view_partner_form" model="ir.ui.view">
94+ <field name="name">Make partner reference readonly when non-commercial</field>
95+ <field name="model">res.partner</field>
96+ <field name="inherit_id" ref="base.view_partner_form"/>
97+ <field name="arch" type="xml">
98+ <field name="ref" position="attributes">
99+ <attribute name="attrs">{
100+ 'readonly': [('is_company', '=', False),
101+ ('parent_id', '!=', False)]}</attribute>
102+ </field>
103+ </field>
104+
105+ </record>
106+ </data>
107+</openerp>
108+

Subscribers

People subscribed via source and target branches

to all changes: