[MERGE]merge from trunk

bzr revid: sgo@tinyerp.com-20120703053008-ayk0e8v0bg11af8e
This commit is contained in:
Sanjay Gohel (Open ERP) 2012-07-03 11:00:08 +05:30
commit bd7dde4dbb
7 changed files with 64 additions and 73 deletions

View File

@ -1,23 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem id="menu_reporting" name="Reporting" sequence="90"/>
<menuitem id="menu_reporting" name="Reporting" sequence="90" groups="base.group_user"/>
<menuitem id="menu_reporting_dashboard" name="Dashboards" parent="menu_reporting" sequence="0"/>
<menuitem id="menu_reporting_config" name="Configuration" parent="menu_reporting" sequence="100" groups="base.group_system"/>
<menuitem id="menu_administration" name="Settings" sequence="100" icon="terp-administration"/>
<menuitem id="menu_administration" name="Settings" sequence="100"/>
<menuitem id="menu_management" name="Modules" parent="menu_administration" sequence="0"/>
<menuitem id="menu_config" name="Configuration" parent="menu_administration" sequence="1"/>
<menuitem id="menu_administration_shortcut" parent="menu_administration" name="Custom Shortcuts" sequence="50"/>
<menuitem id="menu_users" name="Users" parent="menu_administration" sequence="4" groups="base.group_no_one"/>
<menuitem id="menu_users" name="Users" parent="menu_administration" sequence="4"/>
<menuitem id="menu_translation" name="Translations" parent="menu_administration" sequence="7"/>
<menuitem id="menu_translation_app" name="Application Terms" parent="menu_translation" sequence="4" groups="base.group_no_one"/>
<menuitem id="menu_translation_export" name="Import / Export" groups="base.group_no_one" parent="menu_translation" sequence="3"/>
<menuitem id="menu_custom" name="Technical" parent="menu_administration" sequence="110" groups="base.group_no_one"/>
<menuitem id="next_id_2" name="User Interface" parent="menu_custom"/>
<menuitem id="menu_translation_export" name="Import / Export" parent="menu_translation" sequence="3" groups="base.group_no_one"/>
<menuitem id="menu_custom" name="Technical" parent="menu_administration" sequence="110" groups="base.group_no_one"/>
<menuitem id="next_id_2" name="User Interface" parent="menu_custom"/>
<menuitem id="menu_email" name="Email" parent="menu_custom" sequence="1"/>
<menuitem id="menu_security" name="Security" parent="menu_custom" sequence="25"/>
<menuitem id="menu_ir_property" name="Parameters" parent="menu_custom" sequence="24"/>
<menuitem id="next_id_4" name="Low Level Objects" parent="menu_custom" sequence="30"/>
<menuitem id="menu_low_workflow" name="Workflows" parent="next_id_4"/>
</data>
</openerp>

View File

@ -328,7 +328,7 @@
<field name="view_id" ref="action_view_tree"/>
<field name="search_view_id" ref="action_view_search"/>
</record>
<menuitem id="next_id_6" name="Actions" parent="base.next_id_4" sequence="1"/>
<menuitem id="next_id_6" name="Actions" parent="base.menu_custom" sequence="2"/>
<menuitem action="ir_sequence_actions" id="menu_ir_sequence_actions" parent="next_id_6"/>
<menuitem action="act_values_form_action" id="menu_values_form_action" parent="next_id_6"/>
<menuitem action="act_values_form_defaults" id="menu_values_form_defaults" parent="next_id_6"/>

View File

@ -40,7 +40,6 @@
</record>
<act_window name="System Parameters" res_model="ir.config_parameter" id="ir_config_list_action"/>
<menuitem name="System Parameters" id="ir_config_menu"
parent="base.next_id_4" action="ir_config_list_action" groups="base.group_no_one"/>
<menuitem id="ir_config_menu" name="System Parameters" parent="menu_ir_property" action="ir_config_list_action"/>
</data>
</openerp>

View File

@ -24,16 +24,16 @@ from operator import itemgetter
from osv import osv, fields
from tools.translate import _
class ir_needaction_users_rel(osv.osv):
'''
ir_needaction_users_rel holds data related to the needaction
mechanism inside OpenERP. A row in this model is characterized by:
class ir_needaction_users_rel(osv.Model):
''' ir_needaction_users_rel holds data related to the needaction
mechanism inside OpenERP. A row in this model is characterized
by:
- res_model: model of the record requiring an action
- res_id: ID of the record requiring an action
- user_id: foreign key to the res.users table, to the user that
has to perform the action
This model can be seen as a many2many, linking (res_model, res_id) to
users (those whose attention is required on the record).'''
- user_id: foreign key to the res.users table, to the user that has to
perform the action
This model can be seen as a many2many, linking (res_model, res_id) to users
(those whose attention is required on the record). '''
_name = 'ir.needaction_users_rel'
_description = 'Needaction relationship table'
@ -78,50 +78,47 @@ class ir_needaction_users_rel(osv.osv):
return True
class ir_needaction_mixin(osv.osv):
class ir_needaction_mixin(osv.Model):
'''Mixin class for objects using the need action feature.
Need action feature can be used by objects willing to be able to
signal that an action is required on a particular record. If in the
business logic an action must be performed by somebody, for instance
validation by a manager, this mechanism allows to set a list of
users asked to perform an action.
Need action feature can be used by objects having to be able to
signal that an action is required on a particular record. If in
the business logic an action must be performed by somebody, for
instance validation by a manager, this mechanism allows to set a
list of users asked to perform an action.
This class wraps a class (ir.ir_needaction_users_rel) that behaves
like a many2many field. However, no field is added to the model
inheriting from this mixin class. This class handles the low-level
considerations of updating relationships. Every change made on the
record calls a method that updates the relationships.
This class wraps a class (ir.ir_needaction_users_rel) that
behaves like a many2many field. This class handles the low-level
considerations of updating relationships. Every change made on
the record calls a method that updates the relationships.
Objects using the 'need_action' feature should override the
``get_needaction_user_ids`` method. This methods returns a dictionary
whose keys are record ids, and values a list of user ids, like
in a many2many relationship. Therefore by defining only one method,
you can specify if an action is required by defining the users
that have to do it, in every possible situation.
Objects using the 'need_action' feature should override the
``get_needaction_user_ids`` method. This methods returns a
dictionary whose keys are record ids, and values a list of user
ids, like in a many2many relationship. Therefore by defining
only one method, you can specify if an action is required by
defining the users that have to do it, in every possible
situation.
This class also offers several global services,:
This class also offers several global services:
- ``needaction_get_record_ids``: for the current model and uid, get
all record ids that ask this user to perform an action. This
mechanism is used for instance to display the number of pending
actions in menus, such as Leads (12)
all record ids that ask this user to perform an action. This
mechanism is used for instance to display the number of pending
actions in menus, such as Leads (12)
- ``needaction_get_action_count``: as ``needaction_get_record_ids``
but returns only the number of action, not the ids (performs a
search with count=True)
- ``needaction_get_user_record_references``: for a given uid, get all
the records that ask this user to perform an action. Records
are given as references, a list of tuples (model_name, record_id)
but returns only the number of action, not the ids (performs a
search with count=True)
The ``ir_needaction_mixin`` class adds a function field on models inheriting
from the class. This field allows to state whether a given record has
a needaction for the current user. This is usefull if you want to customize
views according to the needaction feature. For example, you may want to
set records in bold in a list view if the current user has an action to
perform on the record. This makes the class not a pure abstract class,
but allows to easily use the action information.'''
The ``ir_needaction_mixin`` class adds a calculated field
``needaction_pending``. This function field allows to state
whether a given record has a needaction for the current user.
This is usefull if you want to customize views according to the
needaction feature. For example, you may want to set records in
bold in a list view if the current user has an action to perform
on the record. '''
_name = 'ir.needaction_mixin'
_description = '"Need action" mixin'
_description = 'Need action mixin'
def get_needaction_pending(self, cr, uid, ids, name, arg, context=None):
res = {}
@ -129,13 +126,19 @@ class ir_needaction_mixin(osv.osv):
for id in ids:
res[id] = uid in needaction_user_ids[id]
return res
def search_needaction_pending(self, cr, uid, self_again, field_name, criterion, context=None):
ids = self.needaction_get_record_ids(
cr, uid, uid, limit=1024, context=context)
return [('id', 'in', ids)]
_columns = {
'needaction_pending': fields.function(get_needaction_pending, type='boolean',
string='Need action pending',
help='If True, this field states that users have to perform an action. \
This field comes from the needaction mechanism. Please refer \
to the ir.needaction_mixin class.'),
'needaction_pending': fields.function(
get_needaction_pending, type='boolean',
fnct_search=search_needaction_pending,
string='Need action pending',
help="If True, this field states that users have to perform an " \
"action This field comes from the ir.needaction_mixin class."),
}
#------------------------------------------------------
@ -146,7 +149,7 @@ class ir_needaction_mixin(osv.osv):
""" Returns the user_ids that have to perform an action
:return: dict { record_id: [user_ids], }
"""
return dict.fromkeys(ids, [])
return dict((id,list()) for id in ids)
def create(self, cr, uid, values, context=None):
rel_obj = self.pool.get('ir.needaction_users_rel')
@ -191,14 +194,5 @@ class ir_needaction_mixin(osv.osv):
get the number of actions it has to perform"""
rel_obj = self.pool.get('ir.needaction_users_rel')
return rel_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, count=True, context=context)
def needaction_get_record_references(self, cr, uid, user_id, offset=None, limit=None, order=None, context=None):
"""For a given user_id, get all the records that asks this user to
perform an action. Records are given as references, a list of
tuples (model_name, record_id).
This method is trans-model."""
rel_obj = self.pool.get('ir.needaction_users_rel')
rel_ids = rel_obj.search(cr, uid, [('user_id', '=', user_id)], offset=offset, limit=limit, order=order, context=context)
return map(itemgetter('res_model', 'res_id'), rel_obj.read(cr, uid, rel_ids, ['res_model', 'res_id'], context=context))
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -321,7 +321,7 @@
<field name="context">{'search_default_active':1}</field>
<field name="search_view_id" ref="view_workflow_instance_search"/>
</record>
<menuitem action="action_workflow_instance_form" id="menu_workflow_instance" parent="base.menu_low_workflow"/>
<menuitem action="action_workflow_instance_form" id="menu_workflow_instance" parent="base.menu_workflow_root"/>
<!--
================================
@ -387,7 +387,7 @@
<field name="context">{'search_default_active':1}</field>
<field name="search_view_id" ref="view_workflow_workitem_search"/>
</record>
<menuitem action="action_workflow_workitem_form" id="menu_workflow_workitem" parent="base.menu_low_workflow"/>
<menuitem action="action_workflow_workitem_form" id="menu_workflow_workitem" parent="base.menu_workflow_root"/>
</data>
</openerp>

View File

@ -66,7 +66,6 @@
<field name="view_type">form</field>
<field name="view_id" ref="ir_property_view_tree"/>
</record>
<menuitem id="menu_ir_property" name="Parameters" parent="menu_custom" groups="base.group_no_one" sequence="24"/>
<menuitem id="menu_ir_property_form_all" parent="menu_ir_property" action="ir_property_form"/>
</data>
</openerp>

View File

@ -1740,11 +1740,11 @@ class BaseModel(object):
if node.text and node.text.strip():
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.text.strip())
if trans:
node.text = trans
node.text = node.text.replace(node.text.strip(), trans)
if node.tail and node.tail.strip():
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.tail.strip())
if trans:
node.tail = trans
node.tail = node.tail.replace(node.tail.strip(), trans)
if node.get('string') and not result:
trans = self.pool.get('ir.translation')._get_source(cr, user, self._name, 'view', context['lang'], node.get('string'))