[Add] base/res: Add the photo field in res.partner
bzr revid: kjo@tinyerp.com-20120301064312-ac1c9wnb6dtu6rv8
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -26,6 +26,7 @@ import tools
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
import logging
|
||||
import os
|
||||
|
||||
class res_payterm(osv.osv):
|
||||
_description = 'Payment term'
|
||||
@@ -180,6 +181,12 @@ class res_partner(osv.osv):
|
||||
'use_parent_address':True
|
||||
}
|
||||
|
||||
def _get_photo(self, cr, uid, is_company, context=None):
|
||||
if is_company == 'contact':
|
||||
return open(os.path.join( tools.config['root_path'], 'addons', 'base', 'res', 'photo.png'), 'rb') .read().encode('base64')
|
||||
else:
|
||||
return open(os.path.join( tools.config['root_path'], 'addons', 'base', 'res', 'res_company_logo.png'), 'rb') .read().encode('base64')
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if default is None:
|
||||
default = {}
|
||||
@@ -190,12 +197,13 @@ 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, child_ids,context=None):
|
||||
def onchange_type(self, cr, uid, ids, is_company, title, child_ids, photo,context=None):
|
||||
photo=False
|
||||
if is_company == 'contact':
|
||||
return {'value': {'is_company': is_company, 'title': '','child_ids':[(5,)]}}
|
||||
return {'value': {'is_company': is_company, 'title': '','child_ids':[(5,)], 'photo': self._get_photo(cr, uid, is_company, context)}}
|
||||
elif is_company == 'partner':
|
||||
return {'value': {'is_company': is_company, 'title': '','parent_id':False}}
|
||||
return {'value': {'is_comapny': '', 'title': ''}}
|
||||
return {'value': {'is_company': is_company, 'title': '','parent_id':False, 'photo': self._get_photo(cr, uid, is_company, context)}}
|
||||
return {'value': {'is_comapny': '', 'title': '','photo':''}}
|
||||
|
||||
|
||||
def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):
|
||||
|
||||
@@ -328,7 +328,7 @@
|
||||
<form string="Partners">
|
||||
<group col="8" colspan="4">
|
||||
<group col="2">
|
||||
<field name="is_company" on_change="onchange_type(is_company, title,child_ids)" required="1"/>
|
||||
<field name="is_company" on_change="onchange_type(is_company, title,child_ids,photo)" required="1"/>
|
||||
<field name="function" attrs="{'invisible': [('is_company','=', 'partner')]}" colspan="2"/>
|
||||
<field name="title" size="0" groups="base.group_extended" domain="[('domain', '=', is_company)]"/>
|
||||
</group>
|
||||
@@ -467,7 +467,7 @@
|
||||
<field name="mobile"/><br/>
|
||||
</td>
|
||||
<td t-if="record.is_company.raw_value == 'contact'" valign="top" align="right">
|
||||
<img t-att-src="kanban_gravatar(record.photo.value, 22)" class="oe_kanban_gravatar"/>
|
||||
<!--img t-att-src="kanban_image('res.partner', 'photo', record.id.value)" class="oe_kanban_gravatar"/-->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -496,23 +496,30 @@
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">res.partner</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">tree,form,kanban</field>
|
||||
<field name="context">{"search_default_customer":1}</field>
|
||||
<field name="search_view_id" ref="view_res_partner_filter"/>
|
||||
<field name="help">A customer is an entity you do business with, like a company or an organization. A customer can have several contacts or addresses which are the people working for this company. You can use the history tab, to follow all transactions related to a customer: sales order, emails, opportunities, claims, etc. If you use the email gateway, the Outlook or the Thunderbird plugin, don't forget to register emails to each contact so that the gateway will automatically attach incoming emails to the right partner.</field>
|
||||
</record>
|
||||
<record id="action_partner_form_view1" model="ir.actions.act_window.view">
|
||||
<field eval="10" name="sequence"/>
|
||||
<field eval="0" name="sequence"/>
|
||||
<field name="view_mode">kanban</field>
|
||||
<field name="view_id" ref="res_partner_kanban_view"/>
|
||||
<field name="act_window_id" ref="action_partner_form"/>
|
||||
</record>
|
||||
<record id="action_partner_form_view2" model="ir.actions.act_window.view">
|
||||
<field eval="20" name="sequence"/>
|
||||
<field eval="2" name="sequence"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_partner_form"/>
|
||||
<field name="act_window_id" ref="action_partner_form"/>
|
||||
</record>
|
||||
|
||||
<record id="action_partner_tree_view1" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_partner_tree"/>
|
||||
<field name="act_window_id" ref="action_partner_form"/>
|
||||
</record>
|
||||
<menuitem
|
||||
action="action_partner_form"
|
||||
id="menu_partner_form"
|
||||
|
||||
Reference in New Issue
Block a user