Browse Source

[IMP] partner_firstname: Make the function of the 'name' field inheritable.

pull/2/head
unknown 11 years ago
committed by Pedro M. Baeza
parent
commit
5eaeb8fff6
  1. 17
      partner_firstname/partner.py

17
partner_firstname/partner.py

@ -35,14 +35,19 @@ class ResPartner(Model):
if cursor.fetchone(): if cursor.fetchone():
cursor.execute('ALTER TABLE res_partner ALTER COLUMN lastname SET NOT NULL') cursor.execute('ALTER TABLE res_partner ALTER COLUMN lastname SET NOT NULL')
def _prepare_name_custom(self, cursor, uid, partner, context=None):
"""
This function is designed to be inherited in a custom module
"""
names = (partner.lastname, partner.firstname)
fullname = " ".join([s for s in names if s])
return fullname
def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None): def _compute_name_custom(self, cursor, uid, ids, fname, arg, context=None):
res = {} res = {}
partners = self.read(cursor, uid, ids,
['firstname', 'lastname'], context=context)
for rec in partners:
names = (rec['lastname'], rec['firstname'])
fullname = " ".join([s for s in names if s])
res[rec['id']] = fullname
for partner in self.browse(cursor, uid, ids, context=context):
res[partner.id] = self._prepare_name_custom(
cursor, uid, partner, context=context)
return res return res
def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None): def _write_name(self, cursor, uid, partner_id, field_name, field_value, arg, context=None):

Loading…
Cancel
Save