Merge lp:~akretion-team/partner-contact-management/partner-firstname-inheritable into lp:~partner-contact-core-editors/partner-contact-management/7.0

Proposed by Alexis de Lattre
Status: Merged
Merged at revision: 40
Proposed branch: lp:~akretion-team/partner-contact-management/partner-firstname-inheritable
Merge into: lp:~partner-contact-core-editors/partner-contact-management/7.0
Diff against target: 29 lines (+11/-6)
1 file modified
partner_firstname/partner.py (+11/-6)
To merge this branch: bzr merge lp:~akretion-team/partner-contact-management/partner-firstname-inheritable
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp code review Approve
David BEAL (ak) (community) Approve
Stéphane Bidoul (Acsone) (community) code review Approve
Benoit Guillot - http://www.akretion.com (community) code review, no test Approve
Pedro Manuel Baeza code review Approve
Review via email: mp+222730@code.launchpad.net

Description of the change

This MP is small but very usefull : with the partner_firstname module, the 'name' field on res.partner becomes a fields.function ; this MP make the code of the fields.function inheritable.

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM

review: Approve (code review)
Revision history for this message
Benoit Guillot - http://www.akretion.com (benoit-guillot-z) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

LGTM

review: Approve (code review)
Revision history for this message
David BEAL (ak) (davidbeal) wrote :

LGTM

review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'partner_firstname/partner.py'
2--- partner_firstname/partner.py 2014-02-18 17:09:53 +0000
3+++ partner_firstname/partner.py 2014-06-10 21:04:21 +0000
4@@ -35,14 +35,19 @@
5 if cursor.fetchone():
6 cursor.execute('ALTER TABLE res_partner ALTER COLUMN lastname SET NOT NULL')
7
8+ def _prepare_name_custom(self, cursor, uid, partner, context=None):
9+ """
10+ This function is designed to be inherited in a custom module
11+ """
12+ names = (partner.lastname, partner.firstname)
13+ fullname = " ".join([s for s in names if s])
14+ return fullname
15+
16 def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None):
17 res = {}
18- partners = self.read(cursor, uid, ids,
19- ['firstname', 'lastname'], context=context)
20- for rec in partners:
21- names = (rec['lastname'], rec['firstname'])
22- fullname = " ".join([s for s in names if s])
23- res[rec['id']] = fullname
24+ for partner in self.browse(cursor, uid, ids, context=context):
25+ res[partner.id] = self._prepare_name_custom(
26+ cursor, uid, partner, context=context)
27 return res
28
29 def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None):

Subscribers

People subscribed via source and target branches

to status/vote changes: