[MERGE] Alias Visibility and Salesteams View. Improve the display of alias in form views and in empty list help messages. Improve the use, visibility and display of salesteams.

ir_action:
- removed size on char fields
- help is now somewhat dynamic; it calls get_empty_list_help on the related model that could be overridden to display a custom message instead of the generic one defined on the action
BaseModel:
- added get_empty_list_help method, that basically returns the help that is given into parameter. Its purpose is to be overridden by models that should customize the empty list help message

bzr revid: tde@openerp.com-20130405150952-5f7sr2f61obl74yw
This commit is contained in:
Thibault Delavallée 2013-04-05 17:09:52 +02:00
commit 4d3ddf7a7a
3 changed files with 42 additions and 4 deletions

View File

@ -240,9 +240,9 @@ class act_window(osv.osv):
'name': fields.char('Action Name', size=64, translate=True),
'type': fields.char('Action Type', size=32, required=True),
'view_id': fields.many2one('ir.ui.view', 'View Ref.', ondelete='cascade'),
'domain': fields.char('Domain Value', size=250,
'domain': fields.char('Domain Value',
help="Optional domain filtering of the destination data, as a Python expression"),
'context': fields.char('Context Value', size=250, required=True,
'context': fields.char('Context Value', required=True,
help="Context dictionary as Python expression, empty by default (Default: {})"),
'res_id': fields.integer('Record ID', help="Database ID of record to open in form view, when ``view_mode`` is set to 'form' only"),
'res_model': fields.char('Destination Model', size=64, required=True,
@ -285,6 +285,36 @@ class act_window(osv.osv):
'multi': False,
}
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
""" call the method get_empty_list_help of the model and set the window action help message
"""
ids_int = isinstance(ids, (int, long))
if ids_int:
ids = [ids]
results = super(act_window, self).read(cr, uid, ids, fields=fields, context=context, load=load)
if not fields or 'help' in fields:
context = dict(context or {})
eval_dict = {
'active_model': context.get('active_model'),
'active_id': context.get('active_id'),
'active_ids': context.get('active_ids'),
'uid': uid,
}
for res in results:
model = res.get('res_model')
if model and self.pool.get(model):
try:
with tools.mute_logger("openerp.tools.safe_eval"):
eval_context = eval(res['context'] or "{}", eval_dict) or {}
except Exception:
continue
custom_context = dict(context, **eval_context)
res['help'] = self.pool.get(model).get_empty_list_help(cr, uid, res.get('help', ""), context=custom_context)
if ids_int:
return results[0]
return results
def for_xml_id(self, cr, uid, module, xml_id, context=None):
""" Returns the act_window object created for the provided xml_id

View File

@ -10,7 +10,7 @@
<menuitem id="base.menu_sales" parent="base.menu_base_partner" name="Sales" sequence="1" />
<menuitem id="menu_base_config" parent="menu_base_partner" name="Configuration" sequence="30" groups="group_system"/>
<menuitem id="menu_config_address_book" parent="menu_base_config" name="Address Book" sequence="40" groups="group_system"/>
<menuitem id="menu_config_address_book" parent="menu_base_config" name="Address Book" sequence="40" groups="group_system"/>
<!-- Partner Titles -->
<record id="view_partner_title_tree" model="ir.ui.view">
@ -420,7 +420,7 @@
<field name="view_id" ref="view_partner_tree"/>
<field name="act_window_id" ref="action_partner_form"/>
</record>
<menuitem id="menu_partner_form" parent="base.menu_sales" action="action_partner_form" sequence="1"/>
<menuitem id="menu_partner_form" parent="base.menu_sales" action="action_partner_form" sequence="2"/>
<record id="action_partner_customer_form" model="ir.actions.act_window">
<field name="name">Customers</field>

View File

@ -3538,6 +3538,14 @@ class BaseModel(object):
return res
def get_empty_list_help(self, cr, user, help, context=None):
""" Generic method giving the help message displayed when having
no result to display in a list or kanban view. By default it returns
the help given in parameter that is generally the help message
defined in the action.
"""
return help
def check_field_access_rights(self, cr, user, operation, fields, context=None):
"""
Check the user access rights on the given fields. This raises Access