Browse Source

[FIX] base_partner_surname : bugfix and code optimization

(../addons/extra-trunk rev 5791)
pull/7/head
Serpent Consulting Services 12 years ago
parent
commit
c7da365ff9
  1. 2
      base_partner_surname/__init__.py
  2. 9
      base_partner_surname/__openerp__.py
  3. 41
      base_partner_surname/partner.py
  4. 24
      base_partner_surname/partner_view.xml

2
base_partner_surname/__init__.py

@ -19,5 +19,5 @@
#
##############################################################################
import partner
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

9
base_partner_surname/__openerp__.py

@ -21,19 +21,20 @@
{
"name" : "Base Partner Surname",
"version" : "1.0",
"author" : "Tiny",
"author" : "Tiny, Serpent Consulting Services",
"website" : "http://www.openerp.com",
"category" : "Generic Modules/Base",
"description": """
This module use for seperate surname from contact name of partner. Now You can give first name & last name on contact Name.
This module is deprecated, it is higly recommended to use base_contact instead.
This module is used for separate surname from contact name of partner. Now You can give first name & last name on contact Name.
This module is deprecated, it is highly recommended to use base_contact instead.
""",
"depends" : ["base"],
"init_xml" : [ ],
"demo_xml" : [ ],
"update_xml" : [ "partner_view.xml" ],
"installable": True
"installable": True,
"auto_install": False
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

41
base_partner_surname/partner.py

@ -30,34 +30,47 @@ class res_partner_address(osv.osv):
'name' : fields.char('Name', size=128, readonly=True),
}
def write(self, cr, uid, ids, vals, context={}):
first_name = ''
last_name = ''
if 'first_name' in vals and vals['first_name']:
first_name = vals['first_name']
if 'last_name' in vals and vals['last_name']:
last_name = vals['last_name']
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
if isinstance(ids,list):
ids = ids[0]
data = self.read(cr, uid, ids, ['first_name','last_name'], context=context)
first_name = data['first_name'] or ''
if 'first_name' in vals:
first_name = vals['first_name'] or ''
last_name = data['last_name'] or ''
if 'last_name' in vals:
last_name = vals['last_name'] or ''
if first_name or last_name:
vals['name'] = first_name + ' ' + last_name
return super(res_partner_address, self).write(cr, uid, ids, vals, context)
def create(self, cr, uid, vals, context={}):
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
first_name = ''
last_name = ''
if 'first_name' in vals and vals['first_name']:
first_name = vals['first_name']
if 'last_name' in vals and vals['last_name']:
last_name = vals['last_name']
if 'first_name' in vals:
first_name = vals['first_name'] or ''
if 'last_name' in vals:
last_name = vals['last_name'] or ''
if first_name or last_name:
vals['name'] = first_name + ' ' + last_name
return super(res_partner_address, self).create(cr, uid, vals, context)
def onchange_name(self, cr, uid, id, first_name, last_name, context={}):
def onchange_name(self, cr, uid, id, first_name, last_name):
res = {}
if not first_name:
first_name = ''
if not last_name:
last_name = ''
return {'value': {'name': first_name + ' ' + last_name}}
if first_name or last_name:
res = {'name': first_name + ' ' + last_name}
return {'value': res}
res_partner_address()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

24
base_partner_surname/partner_view.xml

@ -21,35 +21,35 @@
<field name="type">form</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="address">
<field name="address" position='replace'>
<field colspan="4" mode="form,tree" name="address" nolabel="1" select="1" height="260">
<form string="Partner Contacts">
<field name="name" select="2"/>
<field name="name" />
<field name="title" domain="[('domain', '=', 'contact')]"/>
<field name="first_name" select="1" on_change="onchange_name(first_name,last_name)"/>
<field name="last_name" select="1" on_change="onchange_name(first_name,last_name)"/>
<field name="function"/>
<field name="type" select="2"/>
<field name="type" />
<newline/>
<field name="street" select="2"/>
<field name="street" />
<field name="street2"/>
<newline/>
<field name="zip" select="2"/>
<field name="city" select="2"/>
<field name="zip" />
<field name="city" />
<newline/>
<field name="country_id" select="2"/>
<field name="state_id" select="2"/>
<field name="country_id" />
<field name="state_id" />
<newline/>
<field name="phone"/>
<field name="fax"/>
<newline/>
<field name="mobile"/>
<field name="email" select="2" widget="email" />
<field name="email" widget="email" />
</form>
</field>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save