[IMP] res_partner: set domain on title field

bzr revid: kjo@tinyerp.com-20120224090854-t2gq45iw4g2wjw5z
This commit is contained in:
Kuldeep Joshi (OpenERP)
2012-02-24 14:38:54 +05:30
parent f4a91d5d21
commit a7895adc86
2 changed files with 14 additions and 6 deletions
+9 -1
View File
@@ -155,7 +155,7 @@ class res_partner(osv.osv):
'fax': fields.char('Fax', size=64),
'mobile': fields.char('Mobile', size=64),
'birthdate': fields.char('Birthdate', size=64),
'is_company': fields.boolean('Company', help="Check if the partner is a company, uncheck it for a person"),
'is_company': fields.selection( [ ('contact','Person'),('partner','Company') ],'Partner Type', help="Select if the partner is a company or person"),
'use_parent_address': fields.boolean('Use Company Address', help="Check to use the company's address"),
'photo': fields.binary('Photo'),
'company_id': fields.many2one('res.company', 'Company', select=1),
@@ -188,6 +188,14 @@ class res_partner(osv.osv):
def do_share(self, cr, uid, ids, *args):
return True
def onchange_type(self, cr, uid, ids, is_company, title, context=None):
if is_company == 'contact':
return {'value': {'is_company': is_company, 'title': ''}}
elif is_company == 'partner':
return {'value': {'is_company': is_company, 'title': ''}}
return {'value': {'is_comapny': '', 'title': ''}}
def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):
if use_parent_address and parent_id:
parent = self.browse(cr, uid, parent_id, context=context)
+5 -5
View File
@@ -327,12 +327,11 @@
<group col="8" colspan="4">
<group col="2">
<field name="name"/>
<field name="parent_id" string="Company" attrs="{'invisible': [('is_company','=', True)]}"/>
<field name="function" attrs="{'invisible': [('is_company','=', True)]}"/>
<field name="parent_id" string="Company" attrs="{'invisible': [('is_company','=', 'partner')]}"/>
</group>
<group col="2">
<field name="title" size="0" groups="base.group_extended"/>
<field name="is_company"/>
<field name="title" size="0" groups="base.group_extended" domain="[('domain', '=', is_company)]"/>
<field name="is_company" on_change="onchange_type(is_company, title)"/>
</group>
<group col="2">
<field name="customer"/>
@@ -366,8 +365,9 @@
<field name="email" widget="email" colspan="4"/>
<field name="website" widget="url" colspan="4"/>
<field name="ref" groups="base.group_extended" colspan="4"/>
<field name="function" attrs="{'invisible': [('is_company','=', 'partner')]}" colspan="4"/>
</group>
<group colspan="4" attrs="{'invisible': [('is_company','=', False)]}">
<group colspan="4" attrs="{'invisible': [('is_company','!=', 'partner')]}">
<field name="child_ids" nolabel="1"/>
</group>
</page>