[MERGE] Merged with needaction branch
bzr revid: tde@openerp.com-20120330134244-hhtt90g9mgcs3iec
This commit is contained in:
@@ -25,7 +25,6 @@ import res
|
||||
import publisher_warranty
|
||||
import report
|
||||
import test
|
||||
import base_needaction
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
],
|
||||
'update_xml': [
|
||||
'base_update.xml',
|
||||
'base_needaction_view.xml',
|
||||
'ir/wizard/wizard_menu_view.xml',
|
||||
'ir/ir.xml',
|
||||
'ir/ir_config_parameter_view.xml',
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_notification_tree">
|
||||
<field name="name">base.needaction_users_rel.tree</field>
|
||||
<field name="model">base.needaction_users_rel</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="sequence">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Subscription">
|
||||
<field name="user_id"/>
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_needaction_users_rel" model="ir.actions.act_window">
|
||||
<field name="name">Need action relationships</field>
|
||||
<field name="res_model">base.needaction_users_rel</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_needaction_users_rel" name="Need actions" parent="base.menu_users" sequence="20" action="action_view_needaction_users_rel" groups="base.group_extended"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
import ir_model
|
||||
import ir_sequence
|
||||
import ir_needaction
|
||||
import ir_ui_menu
|
||||
import ir_ui_view
|
||||
import ir_default
|
||||
|
||||
@@ -661,6 +661,30 @@
|
||||
|
||||
<menuitem action="ir_action_wizard" id="menu_ir_action_wizard" parent="base.next_id_6"/>
|
||||
|
||||
<!-- Needaction mechanism -->
|
||||
<record model="ir.ui.view" id="view_notification_tree">
|
||||
<field name="name">ir.needaction_users_rel.tree</field>
|
||||
<field name="model">ir.needaction_users_rel</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="sequence">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Subscription">
|
||||
<field name="user_id"/>
|
||||
<field name="res_model"/>
|
||||
<field name="res_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_view_needaction_users_rel" model="ir.actions.act_window">
|
||||
<field name="name">Need action relationships</field>
|
||||
<field name="res_model">ir.needaction_users_rel</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_needaction_users_rel" name="Need actions" parent="base.menu_users" sequence="20" action="action_view_needaction_users_rel" groups="base.group_extended"/>
|
||||
|
||||
<!-- Companies -->
|
||||
<menuitem id="menu_res_company_global"
|
||||
parent="base.menu_administration"
|
||||
|
||||
@@ -23,7 +23,7 @@ import openerp.pooler as pooler
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class base_needaction_users_rel(osv.osv):
|
||||
class ir_needaction_users_rel(osv.osv):
|
||||
'''
|
||||
base_needaction_users_rel holds data related to the needaction
|
||||
mechanism inside OpenERP. A needaction is characterized by:
|
||||
@@ -33,7 +33,7 @@ class base_needaction_users_rel(osv.osv):
|
||||
has to perform the action
|
||||
'''
|
||||
|
||||
_name = 'base.needaction_users_rel'
|
||||
_name = 'ir.needaction_users_rel'
|
||||
_description = 'Needaction relationship table'
|
||||
_rec_name = 'id'
|
||||
_order = 'res_model asc'
|
||||
@@ -47,7 +47,7 @@ class base_needaction_users_rel(osv.osv):
|
||||
}
|
||||
|
||||
|
||||
class base_needaction(osv.osv):
|
||||
class ir_needaction(osv.osv):
|
||||
'''Mixin class for objects using the need action feature.
|
||||
|
||||
Need action feature can be used by objects willing to be able to
|
||||
@@ -81,7 +81,7 @@ class base_needaction(osv.osv):
|
||||
but returns only the number of action, not the ids (performs a
|
||||
search with count=True)
|
||||
'''
|
||||
_name = 'base.needaction'
|
||||
_name = 'ir.needaction'
|
||||
_description = 'Need action of users on records API'
|
||||
|
||||
_columns = {
|
||||
@@ -95,7 +95,7 @@ class base_needaction(osv.osv):
|
||||
"""Given ids of model self._name, find the user_ids that have an action to perform"""
|
||||
if context is None:
|
||||
context = {}
|
||||
needact_obj = self.pool.get('base.needaction_users_rel')
|
||||
needact_obj = self.pool.get('ir.needaction_users_rel')
|
||||
needact_ids = needact_obj.search(cr, uid, [('res_model', '=', self._nanme), ('res_id', 'in', ids)], context=context)
|
||||
needacts = needact_obj.read(cr, uid, needact_ids, context=context)
|
||||
return [needact['user_id'] for needact in needacts]
|
||||
@@ -104,7 +104,7 @@ class base_needaction(osv.osv):
|
||||
"""Given ids of model self._name, add user_ids to the relationship table"""
|
||||
if context is None:
|
||||
context = {}
|
||||
needact_obj = self.pool.get('base.needaction_users_rel')
|
||||
needact_obj = self.pool.get('ir.needaction_users_rel')
|
||||
for id in ids:
|
||||
for user_id in user_ids:
|
||||
needact_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)
|
||||
@@ -114,7 +114,7 @@ class base_needaction(osv.osv):
|
||||
"""Given ids of model self._name, delete all entries in the relationship table"""
|
||||
if context is None:
|
||||
context = {}
|
||||
needact_obj = self.pool.get('base.needaction_users_rel')
|
||||
needact_obj = self.pool.get('ir.needaction_users_rel')
|
||||
to_del_ids = needact_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context)
|
||||
return needact_obj.unlink(cr, uid, to_del_ids, context=context)
|
||||
|
||||
@@ -139,7 +139,7 @@ class base_needaction(osv.osv):
|
||||
if context is None:
|
||||
context = {}
|
||||
# perform create
|
||||
obj_id = super(base_needaction, self).create(cr, uid, values, context=context)
|
||||
obj_id = super(ir_needaction, self).create(cr, uid, values, context=context)
|
||||
# link user_ids
|
||||
needaction_user_ids = self.get_needaction_user_ids(cr, uid, [obj_id], context=context)
|
||||
self._update_users(cr, uid, [obj_id], needaction_user_ids[obj_id], context=context)
|
||||
@@ -149,7 +149,7 @@ class base_needaction(osv.osv):
|
||||
if context is None:
|
||||
context = {}
|
||||
# perform write
|
||||
write_res = super(base_needaction, self).write(cr, uid, ids, values, context=context)
|
||||
write_res = super(ir_needaction, self).write(cr, uid, ids, values, context=context)
|
||||
# get and update user_ids
|
||||
needaction_user_ids = self.get_needaction_user_ids(cr, uid, ids, context=context)
|
||||
for id in ids:
|
||||
@@ -162,7 +162,7 @@ class base_needaction(osv.osv):
|
||||
# unlink user_ids
|
||||
self._unlink_users(cr, uid, ids, context=context)
|
||||
# perform unlink
|
||||
return super(base_needaction, self).unlink(cr, uid, ids, context=context)
|
||||
return super(ir_needaction, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
#------------------------------------------------------
|
||||
# Need action API
|
||||
@@ -174,7 +174,7 @@ class base_needaction(osv.osv):
|
||||
get the user_ids that have to perform at least one action"""
|
||||
if context is None:
|
||||
context = {}
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('base.needaction_users_rel')
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('ir.needaction_users_rel')
|
||||
need_act_ids = need_act_obj.search(cr, uid, [('res_model', '=', model)], context=context)
|
||||
need_acts = need_act_obj.read(cr, uid, need_act_ids, context=context)
|
||||
return list(set([need_act['user_id'] for need_act in need_acts]))
|
||||
@@ -185,7 +185,7 @@ class base_needaction(osv.osv):
|
||||
get the number of actions it has to perform"""
|
||||
if context is None:
|
||||
context = {}
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('base.needaction_users_rel')
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('ir.needaction_users_rel')
|
||||
need_act_ids = need_act_obj.search(cr, uid, [('res_model', '=', model_name), ('user_id', '=', user_id)], limit=limit, context=context)
|
||||
return [need_act['res_id'] for need_act in need_act_obj.read(cr, uid, need_act_ids, context=context)]
|
||||
|
||||
@@ -195,7 +195,7 @@ class base_needaction(osv.osv):
|
||||
get the number of actions it has to perform"""
|
||||
if context is None:
|
||||
context = {}
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('base.needaction_users_rel')
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('ir.needaction_users_rel')
|
||||
return need_act_obj.search(cr, uid, [('res_model', '=', model_name), ('user_id', '=', user_id)], limit=limit, count=True, context=context)
|
||||
|
||||
@classmethod
|
||||
@@ -207,7 +207,7 @@ class base_needaction(osv.osv):
|
||||
This method is trans-model."""
|
||||
if context is None:
|
||||
context = {}
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('base.needaction_users_rel')
|
||||
need_act_obj = pooler.get_pool(cr.dbname).get('ir.needaction_users_rel')
|
||||
need_act_ids = need_act_obj.search(cr, uid, [('user_id', '=', user_id)], offset=offset, limit=limit, order=order, context=context)
|
||||
need_acts = need_act_obj.browse(cr, uid, need_act_ids, context=context)
|
||||
record_references = [(need_act.res_model, need_act.res_id) for need_act in need_acts]
|
||||
@@ -265,8 +265,8 @@ class ir_ui_menu(osv.osv):
|
||||
menu_needaction_res = osv.osv.get_needaction_info(cr, uid, menu.action.res_model, uid, domain=menu.action.domain, context=context)
|
||||
else:
|
||||
menu_needaction_res = [False, 0]
|
||||
res[menu.id]['uses_needaction'] = menu_needaction_res[0]
|
||||
res[menu.id]['needaction_uid_ctr'] = menu_needaction_res[1]
|
||||
res[menu.id]['needaction_enabled'] = menu_needaction_res[0]
|
||||
res[menu.id]['needaction_counter'] = menu_needaction_res[1]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
@@ -285,8 +285,8 @@ class ir_ui_menu(osv.osv):
|
||||
'web_icon_hover':fields.char('Web Icon File (hover)', size=128),
|
||||
'web_icon_data': fields.function(_get_image_icon, string='Web Icon Image', type='binary', readonly=True, store=True, multi='icon'),
|
||||
'web_icon_hover_data':fields.function(_get_image_icon, string='Web Icon Image (hover)', type='binary', readonly=True, store=True, multi='icon'),
|
||||
'uses_needaction': fields.function(_get_needaction, string='Related model uses the need action mechanism', type='boolean', help='If the menu entry is related to a act_window action, and this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false.', multi='_get_needaction'),
|
||||
'needaction_uid_ctr': fields.function(_get_needaction, string='Number of actions the user has to perform', type='integer', help='If the related model uses the need action mechanism, this field gives the number of actions the current user has to perform.', multi='_get_needaction'),
|
||||
'needaction_enabled': fields.function(_get_needaction, string='Related model uses the need action mechanism', type='boolean', help='If the menu entry is related to a act_window action, and this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false.', multi='_get_needaction'),
|
||||
'needaction_counter': fields.function(_get_needaction, string='Number of actions the user has to perform', type='integer', help='If the related model uses the need action mechanism, this field gives the number of actions the current user has to perform.', multi='_get_needaction'),
|
||||
'action': fields.function(_action, fnct_inv=_action_inv,
|
||||
type='reference', string='Action',
|
||||
selection=[
|
||||
|
||||
@@ -125,4 +125,4 @@
|
||||
"access_ir_mail_server_all","ir_mail_server","model_ir_mail_server",,1,0,0,0
|
||||
"access_ir_actions_todo_category","ir_actions_todo_category","model_ir_actions_todo_category","group_system",1,1,1,1
|
||||
"access_ir_actions_client","ir_actions_client all","model_ir_actions_client",,1,0,0,0
|
||||
"access_base_needaction_users_rel","base_needaction_users_rel all","model_base_needaction_users_rel",,1,1,1,1
|
||||
"access_ir_needaction_users_rel","ir_needaction_users_rel all","model_ir_needaction_users_rel",,1,1,1,1
|
||||
|
||||
|
Reference in New Issue
Block a user