[IMP]: base : Improvements in base module
bzr revid: jas@tinyerp.com-20100929075801-l569rvj9tiq2ha9w
This commit is contained in:
parent
276b05358b
commit
55bec50ff0
|
@ -13,14 +13,13 @@
|
||||||
<menuitem id="menu_custom_action" name="Actions" parent="base.menu_custom" groups="base.group_extended" sequence="20"/>
|
<menuitem id="menu_custom_action" name="Actions" parent="base.menu_custom" groups="base.group_extended" sequence="20"/>
|
||||||
<menuitem id="menu_config" name="Configuration" parent="base.menu_administration" sequence="1"/>
|
<menuitem id="menu_config" name="Configuration" parent="base.menu_administration" sequence="1"/>
|
||||||
<menuitem id="menu_translation" name="Translations" parent="base.menu_administration" sequence="4"/>
|
<menuitem id="menu_translation" name="Translations" parent="base.menu_administration" sequence="4"/>
|
||||||
<menuitem id="menu_translation_app" name="Application Terms" parent="base.menu_translation" sequence="4"/>
|
<menuitem id="menu_translation_app" name="Application Terms" parent="base.menu_translation" sequence="4" groups="base.group_extended"/>
|
||||||
<menuitem id="menu_translation_export" name="Import / Export"
|
<menuitem id="menu_translation_export" name="Import / Export"
|
||||||
groups="base.group_extended"
|
groups="base.group_extended" parent="base.menu_translation" sequence="3"/>
|
||||||
parent="base.menu_translation" sequence="4"/>
|
|
||||||
<menuitem id="menu_users" name="Users" parent="base.menu_administration" sequence="6"/>
|
<menuitem id="menu_users" name="Users" parent="base.menu_administration" sequence="6"/>
|
||||||
<menuitem id="menu_security" name="Security" parent="base.menu_administration" sequence="8"
|
<menuitem id="menu_security" name="Security" parent="base.menu_administration" sequence="8"
|
||||||
groups="base.group_extended"/>
|
groups="base.group_extended"/>
|
||||||
<menuitem id="menu_management" name="Modules Management" parent="base.menu_administration" sequence="10"
|
<menuitem id="menu_management" name="Modules" parent="base.menu_administration" sequence="10"
|
||||||
groups="base.group_extended"/>
|
groups="base.group_extended"/>
|
||||||
<menuitem icon="terp-graph" id="reporting_menu" name="Reporting" sequence="45"
|
<menuitem icon="terp-graph" id="reporting_menu" name="Reporting" sequence="45"
|
||||||
groups="group_extended"/>
|
groups="group_extended"/>
|
||||||
|
|
|
@ -142,103 +142,6 @@ class ir_model(osv.osv):
|
||||||
x_custom_model._rec_name = x_name
|
x_custom_model._rec_name = x_name
|
||||||
ir_model()
|
ir_model()
|
||||||
|
|
||||||
|
|
||||||
class ir_model_grid(osv.osv):
|
|
||||||
_name = 'ir.model.grid'
|
|
||||||
_table = 'ir_model'
|
|
||||||
_inherit = 'ir.model'
|
|
||||||
_description = "Objects Security Grid"
|
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
|
||||||
raise osv.except_osv('Error !', 'You cannot add an entry to this view !')
|
|
||||||
|
|
||||||
def unlink(self, *args, **argv):
|
|
||||||
raise osv.except_osv('Error !', 'You cannot delete an entry of this view !')
|
|
||||||
|
|
||||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
|
||||||
result = super(osv.osv, self).read(cr, uid, ids, fields, context, load)
|
|
||||||
allgr = self.pool.get('res.groups').search(cr, uid, [], context=context)
|
|
||||||
acc_obj = self.pool.get('ir.model.access')
|
|
||||||
|
|
||||||
if not isinstance(result,list):
|
|
||||||
result=[result]
|
|
||||||
|
|
||||||
for res in result:
|
|
||||||
rules = acc_obj.search(cr, uid, [('model_id', '=', res['id'])])
|
|
||||||
rules_br = acc_obj.browse(cr, uid, rules, context=context)
|
|
||||||
for g in allgr:
|
|
||||||
res['group_'+str(g)] = ''
|
|
||||||
for rule in rules_br:
|
|
||||||
perm_list = []
|
|
||||||
if rule.perm_read:
|
|
||||||
perm_list.append('r')
|
|
||||||
if rule.perm_write:
|
|
||||||
perm_list.append('w')
|
|
||||||
if rule.perm_create:
|
|
||||||
perm_list.append('c')
|
|
||||||
if rule.perm_unlink:
|
|
||||||
perm_list.append('u')
|
|
||||||
perms = ",".join(perm_list)
|
|
||||||
if rule.group_id:
|
|
||||||
res['group_%d'%rule.group_id.id] = perms
|
|
||||||
else:
|
|
||||||
res['group_0'] = perms
|
|
||||||
return result
|
|
||||||
|
|
||||||
#
|
|
||||||
# This function do not write fields from ir.model because
|
|
||||||
# access rights may be different for managing models and
|
|
||||||
# access rights
|
|
||||||
#
|
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
|
||||||
vals_new = vals.copy()
|
|
||||||
acc_obj = self.pool.get('ir.model.access')
|
|
||||||
for grid in self.browse(cr, uid, ids, context=context):
|
|
||||||
model_id = grid.id
|
|
||||||
perms_rel = ['read','write','create','unlink']
|
|
||||||
for val in vals:
|
|
||||||
if not val[:6]=='group_':
|
|
||||||
continue
|
|
||||||
group_id = int(val[6:]) or False
|
|
||||||
rules = acc_obj.search(cr, uid, [('model_id', '=', model_id),('group_id', '=', group_id)])
|
|
||||||
if not rules:
|
|
||||||
rules = [acc_obj.create(cr, uid, {
|
|
||||||
'name': grid.name,
|
|
||||||
'model_id':model_id,
|
|
||||||
'group_id':group_id
|
|
||||||
}) ]
|
|
||||||
vals2 = dict(map(lambda x: ('perm_'+x, x[0] in (vals[val] or '')), perms_rel))
|
|
||||||
acc_obj.write(cr, uid, rules, vals2, context=context)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def fields_get(self, cr, uid, fields=None, context=None):
|
|
||||||
result = super(ir_model_grid, self).fields_get(cr, uid, fields, context)
|
|
||||||
groups = self.pool.get('res.groups').search(cr, uid, [])
|
|
||||||
groups_br = self.pool.get('res.groups').browse(cr, uid, groups)
|
|
||||||
result['group_0'] = {'string': 'All Users','type': 'char','size': 7}
|
|
||||||
for group in groups_br:
|
|
||||||
result['group_%d'%group.id] = {'string': '%s'%group.name,'type': 'char','size': 7}
|
|
||||||
return result
|
|
||||||
|
|
||||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
|
|
||||||
result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
|
|
||||||
groups = self.pool.get('res.groups').search(cr, uid, [])
|
|
||||||
groups_br = self.pool.get('res.groups').browse(cr, uid, groups)
|
|
||||||
cols = ['model', 'name']
|
|
||||||
xml = '''<?xml version="1.0"?>
|
|
||||||
<%s editable="bottom">
|
|
||||||
<field name="name" select="1" readonly="1" required="1"/>
|
|
||||||
<field name="model" select="1" readonly="1" required="1"/>
|
|
||||||
<field name="group_0"/>
|
|
||||||
''' % (view_type,)
|
|
||||||
for group in groups_br:
|
|
||||||
xml += '''<field name="group_%d"/>''' % (group.id, )
|
|
||||||
xml += '''</%s>''' % (view_type,)
|
|
||||||
result['arch'] = xml
|
|
||||||
result['fields'] = self.fields_get(cr, uid, cols, context)
|
|
||||||
return result
|
|
||||||
ir_model_grid()
|
|
||||||
|
|
||||||
class ir_model_fields(osv.osv):
|
class ir_model_fields(osv.osv):
|
||||||
_name = 'ir.model.fields'
|
_name = 'ir.model.fields'
|
||||||
_description = "Fields"
|
_description = "Fields"
|
||||||
|
@ -327,7 +230,7 @@ class ir_model_access(osv.osv):
|
||||||
'perm_read': fields.boolean('Read Access'),
|
'perm_read': fields.boolean('Read Access'),
|
||||||
'perm_write': fields.boolean('Write Access'),
|
'perm_write': fields.boolean('Write Access'),
|
||||||
'perm_create': fields.boolean('Create Access'),
|
'perm_create': fields.boolean('Create Access'),
|
||||||
'perm_unlink': fields.boolean('Delete Permission'),
|
'perm_unlink': fields.boolean('Delete Access'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_groups(self, cr, uid, group):
|
def check_groups(self, cr, uid, group):
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<field name="model">base.module.import</field>
|
<field name="model">base.module.import</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Module import">
|
<form string="Import module">
|
||||||
<separator string="Module Import" colspan="4"/>
|
<separator string="Module Import" colspan="4"/>
|
||||||
<label string="Please give your module .ZIP file to import." colspan="4"/>
|
<label string="Please give your module .ZIP file to import." colspan="4"/>
|
||||||
<field name="module_file"/>
|
<field name="module_file"/>
|
||||||
|
|
|
@ -92,7 +92,7 @@ class base_module_update_open(osv.osv_memory):
|
||||||
"""
|
"""
|
||||||
res = {
|
res = {
|
||||||
'domain': str([]),
|
'domain': str([]),
|
||||||
'name': 'Module List',
|
'name': 'Modules',
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'res_model': 'ir.module.module',
|
'res_model': 'ir.module.module',
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Scan for new modules">
|
<form string="Scan for new modules">
|
||||||
<label string="This function will check for new modules in the 'addons' path" colspan="4" align="0.0"/>
|
<label string="This wizard will scan all module repositories (on the server side) to detect any new or updated modules. Please be patient as this operation may take a few seconds..." colspan="4" align="0.0"/>
|
||||||
<separator string="" colspan="4" />
|
<separator string="" colspan="4" />
|
||||||
<newline/>
|
<newline/>
|
||||||
<group colspan="6" >
|
<group colspan="6" >
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<field name="model">base.module.upgrade</field>
|
<field name="model">base.module.upgrade</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="System update done">
|
<form string="Apply Scheduled Upgrades">
|
||||||
<separator string="System update completed" colspan="4"/>
|
<separator string="System update completed" colspan="4"/>
|
||||||
<label align="0.0" string="The selected modules have been updated / installed !" colspan="4"/>
|
<label align="0.0" string="The selected modules have been updated / installed !" colspan="4"/>
|
||||||
<label align="0.0" string="We suggest to reload the menu tab to see the new menus (Ctrl+T then Ctrl+R)." colspan="4"/>
|
<label align="0.0" string="We suggest to reload the menu tab to see the new menus (Ctrl+T then Ctrl+R)." colspan="4"/>
|
||||||
|
|
|
@ -50,6 +50,12 @@ class base_update_translations(osv.osv_memory):
|
||||||
buf.close()
|
buf.close()
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
||||||
|
def default_get(self, cr, uid, fields, context=None):
|
||||||
|
lang_obj = self.pool.get('res.lang')
|
||||||
|
record_id = context and context.get('active_id', False) or False
|
||||||
|
lang=lang_obj.browse(cr,uid,record_id).code
|
||||||
|
return {'lang':lang}
|
||||||
|
|
||||||
_name = 'base.update.translations'
|
_name = 'base.update.translations'
|
||||||
_columns = {
|
_columns = {
|
||||||
'lang': fields.selection(_get_languages, 'Language', required=True),
|
'lang': fields.selection(_get_languages, 'Language', required=True),
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group colspan="8" col="8">
|
<group colspan="8" col="8">
|
||||||
<separator string="" colspan="8"/>
|
<separator string="" colspan="6"/>
|
||||||
<group colspan="4" width="220">
|
<group colspan="4" width="220">
|
||||||
<field name="progress" widget="progressbar" nolabel="1" colspan="2"/>
|
<field name="progress" widget="progressbar" nolabel="1" colspan="2"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -24,22 +24,23 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Languages">
|
<form string="Languages">
|
||||||
<group col="4" colspan="4">
|
<group col="6" colspan="4">
|
||||||
<field name="name" colspan="4"/>
|
<field name="name"/>
|
||||||
<field name="code" />
|
<field name="code" />
|
||||||
<field name="iso_code"/>
|
<field name="iso_code"/>
|
||||||
<field name="active" />
|
<newline/>
|
||||||
<field name="translatable"/>
|
<field name="grouping" />
|
||||||
<field name="grouping" />
|
<field name="date_format"/>
|
||||||
<field name="direction" />
|
<field name="time_format"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="date_format"/>
|
<field name="direction" />
|
||||||
<field name="time_format"/>
|
<field name="decimal_point"/>
|
||||||
<field name="decimal_point"/>
|
<field name="thousands_sep"/>
|
||||||
<field name="thousands_sep"/>
|
<newline/>
|
||||||
<newline/>
|
<field name="active" />
|
||||||
</group>
|
<field name="translatable"/>
|
||||||
<separator colspan="4" string="Legends for Date and Time Formats"/>
|
</group>
|
||||||
|
<separator colspan="4" string="Legends for Date and Time Formats"/>
|
||||||
<group col="4" colspan="4">
|
<group col="4" colspan="4">
|
||||||
<label align="0.0" string="%%a - Abbreviated weekday name."/>
|
<label align="0.0" string="%%a - Abbreviated weekday name."/>
|
||||||
<label align="0.0" string="%%A - Full weekday name."/>
|
<label align="0.0" string="%%A - Full weekday name."/>
|
||||||
|
@ -106,10 +107,14 @@
|
||||||
<field name="type">search</field>
|
<field name="type">search</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="Languages">
|
<search string="Languages">
|
||||||
<field name="name"/>
|
<group>
|
||||||
<field name="code"/>
|
<filter string="Translatable" icon="terp-tools" domain="[('translatable','=',True)]"/>
|
||||||
<field name="iso_code"/>
|
<separator orientation="vertical"/>
|
||||||
<field name="direction"/>
|
<field name="name"/>
|
||||||
|
<field name="code"/>
|
||||||
|
<field name="iso_code"/>
|
||||||
|
<field name="direction"/>
|
||||||
|
</group>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -121,6 +126,6 @@
|
||||||
<field name="context">{'active_test': False}</field>
|
<field name="context">{'active_test': False}</field>
|
||||||
<field name="search_view_id" ref="res_lang_search"/>
|
<field name="search_view_id" ref="res_lang_search"/>
|
||||||
</record>
|
</record>
|
||||||
<menuitem action="res_lang_act_window" id="menu_res_lang_act_window" parent="menu_translation"/>
|
<menuitem action="res_lang_act_window" id="menu_res_lang_act_window" parent="menu_translation" groups="base.group_extended" sequence="1"/>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||||
#
|
#
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
class res_log(osv.osv_memory):
|
class res_log(osv.osv_memory):
|
||||||
_name = 'res.log'
|
_name = 'res.log'
|
||||||
|
@ -29,7 +29,8 @@ class res_log(osv.osv_memory):
|
||||||
'user_id': fields.many2one('res.users','User', required=True),
|
'user_id': fields.many2one('res.users','User', required=True),
|
||||||
'res_model': fields.char('Object', size=128),
|
'res_model': fields.char('Object', size=128),
|
||||||
'res_id': fields.integer('Object ID'),
|
'res_id': fields.integer('Object ID'),
|
||||||
'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on')
|
'secondary': fields.boolean('Secondary Log', help='Do not display this log if it belongs to the same object the user is working on'),
|
||||||
|
'create_date': fields.datetime('Created Date', readonly=True),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'user_id': lambda self,cr,uid,ctx: uid
|
'user_id': lambda self,cr,uid,ctx: uid
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<tree string="Logs">
|
<tree string="Logs">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
|
<field name="create_date"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -32,11 +33,13 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Logs">
|
<form string="Logs">
|
||||||
<group colspan="4" col="6">
|
<field name="name" colspan="3"/>
|
||||||
<field name="name" colspan="4"/>
|
<newline/>
|
||||||
|
<group colspan="4" col="8">
|
||||||
<field name="user_id" />
|
<field name="user_id" />
|
||||||
<field name="res_model"/>
|
<field name="res_model"/>
|
||||||
<field name="res_id"/>
|
<field name="res_id"/>
|
||||||
|
<field name="create_date" colspan="1"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|
Loading…
Reference in New Issue