[MERGE] Merged with server/trunk.
bzr revid: tde@openerp.com-20120806124337-9z4ussrxn2uhli4i
This commit is contained in:
commit
4d9ff0d5f9
|
@ -1796,7 +1796,6 @@
|
|||
<tree string="Config Wizard Steps">
|
||||
<field name="sequence"/>
|
||||
<field name="action_id"/>
|
||||
<field name="category_id"/>
|
||||
<field name="type"/>
|
||||
<field name="state" readonly="1"/>
|
||||
<button name="action_launch" states="open" string="Launch" type="object" icon="gtk-execute" help="Launch Configuration Wizard"/>
|
||||
|
@ -1828,7 +1827,6 @@
|
|||
<field name="action_id"/>
|
||||
<field name="type"/>
|
||||
<field name="sequence"/>
|
||||
<field name="category_id"/>
|
||||
</group>
|
||||
<group string="Groups">
|
||||
<field name="groups_id" nolabel="1" colspan="4"/>
|
||||
|
@ -1846,11 +1844,7 @@
|
|||
<search string="Search Actions">
|
||||
<filter string="To Do" name="todo" icon="terp-camera_test" domain=" [('state','=','open')]" help="Wizards to be Launched"/>
|
||||
<field name="action_id"/>
|
||||
<field name="category_id"/>
|
||||
<field name="state"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Category" context="{'group_by': 'category_id'}" icon="terp-folder-orange"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -1877,50 +1871,6 @@
|
|||
<field name="args">()</field>
|
||||
</record>
|
||||
|
||||
<!-- ir.actions.todo category -->
|
||||
|
||||
<record id="ir_actions_todo_category_form" model="ir.ui.view">
|
||||
<field name="name">ir.actions.todo.category.form</field>
|
||||
<field name="model">ir.actions.todo.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Wizard Category" version="7.0">
|
||||
<group col="4">
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
<field name="wizards_ids" nolabel="1" colspan="4"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_actions_todo_category_tree" model="ir.ui.view">
|
||||
<field name="name">ir.actions.todo.category.tree</field>
|
||||
<field name="model">ir.actions.todo.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Wizard Category">
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="category_administration_config" model="ir.actions.todo.category">
|
||||
<field name="name">Administration</field>
|
||||
<field name="sequence">1</field>
|
||||
</record>
|
||||
|
||||
<record id="category_sales_management_config" model="ir.actions.todo.category">
|
||||
<field name="name">Sales Management</field>
|
||||
<field name="sequence">5</field>
|
||||
</record>
|
||||
|
||||
<record id="category_tools_customization_config" model="ir.actions.todo.category">
|
||||
<field name="name">Tools / Customization</field>
|
||||
<field name="sequence">5</field>
|
||||
</record>
|
||||
|
||||
<!-- ir.mail.server -->
|
||||
<record model="ir.ui.view" id="ir_mail_server_form">
|
||||
<field name="name">ir.mail.server.form</field>
|
||||
|
|
|
@ -749,20 +749,6 @@ class act_window_close(osv.osv):
|
|||
}
|
||||
act_window_close()
|
||||
|
||||
class ir_actions_todo_category(osv.osv):
|
||||
"""
|
||||
Category of Configuration Wizards
|
||||
"""
|
||||
|
||||
_name = 'ir.actions.todo.category'
|
||||
_description = "Configuration Wizard Category"
|
||||
_columns = {
|
||||
'name':fields.char('Name', size=64, translate=True, required=True),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'wizards_ids': fields.one2many('ir.actions.todo', 'category_id', 'Configuration Wizards'),
|
||||
}
|
||||
ir_actions_todo_category()
|
||||
|
||||
# This model use to register action services.
|
||||
TODO_STATES = [('open', 'To Do'),
|
||||
('done', 'Done')]
|
||||
|
@ -776,8 +762,7 @@ class ir_actions_todo(osv.osv):
|
|||
_description = "Configuration Wizards"
|
||||
_columns={
|
||||
'action_id': fields.many2one(
|
||||
'ir.actions.act_window', 'Action', select=True, required=True,
|
||||
ondelete='cascade'),
|
||||
'ir.actions.actions', 'Action', select=True, required=True),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'state': fields.selection(TODO_STATES, string='State', required=True),
|
||||
'name': fields.char('Name', size=64),
|
||||
|
@ -787,14 +772,13 @@ Automatic: Runs whenever the system is reconfigured.
|
|||
Launch Manually Once: after hacing been launched manually, it sets automatically to Done."""),
|
||||
'groups_id': fields.many2many('res.groups', 'res_groups_action_rel', 'uid', 'gid', 'Groups'),
|
||||
'note': fields.text('Text', translate=True),
|
||||
'category_id': fields.many2one('ir.actions.todo.category','Category'),
|
||||
}
|
||||
_defaults={
|
||||
'state': 'open',
|
||||
'sequence': 10,
|
||||
'type': 'manual',
|
||||
}
|
||||
_order="sequence,name,id"
|
||||
_order="sequence,id"
|
||||
|
||||
def action_launch(self, cr, uid, ids, context=None):
|
||||
""" Launch Action of Wizard"""
|
||||
|
@ -804,7 +788,11 @@ Launch Manually Once: after hacing been launched manually, it sets automatically
|
|||
wizard.write({'state': 'done'})
|
||||
|
||||
# Load action
|
||||
res = self.pool.get('ir.actions.act_window').read(cr, uid, wizard.action_id.id, [], context=context)
|
||||
act_type = self.pool.get('ir.actions.actions').read(cr, uid, wizard.action_id.id, ['type'], context=context)
|
||||
|
||||
res = self.pool.get(act_type['type']).read(cr, uid, wizard.action_id.id, [], context=context)
|
||||
if act_type<>'ir.actions.act_window':
|
||||
return res
|
||||
res.setdefault('context','{}')
|
||||
res['nodestroy'] = True
|
||||
|
||||
|
@ -879,8 +867,10 @@ class act_client(osv.osv):
|
|||
])
|
||||
|
||||
def _set_params(self, cr, uid, id, field_name, field_value, arg, context):
|
||||
assert isinstance(field_value, dict), "params can only be dictionaries"
|
||||
self.write(cr, uid, id, {'params_store': repr(field_value)}, context=context)
|
||||
if isinstance(field_value, dict):
|
||||
self.write(cr, uid, id, {'params_store': repr(field_value)}, context=context)
|
||||
else:
|
||||
self.write(cr, uid, id, {'params_store': field_value}, context=context)
|
||||
|
||||
_columns = {
|
||||
'tag': fields.char('Client action tag', size=64, required=True,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
@ -34,7 +35,7 @@
|
|||
<field name="key"/>
|
||||
<field name="value"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -178,14 +178,16 @@ class ir_model(osv.osv):
|
|||
def create(self, cr, user, vals, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context and context.get('manual',False):
|
||||
if context and context.get('manual'):
|
||||
vals['state']='manual'
|
||||
res = super(ir_model,self).create(cr, user, vals, context)
|
||||
if vals.get('state','base')=='manual':
|
||||
self.instanciate(cr, user, vals['model'], context)
|
||||
self.pool.get(vals['model']).__init__(self.pool, cr)
|
||||
ctx = context.copy()
|
||||
ctx.update({'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0')})
|
||||
ctx = dict(context,
|
||||
field_name=vals['name'],
|
||||
field_state='manual',
|
||||
select=vals.get('select_level', '0'))
|
||||
self.pool.get(vals['model'])._auto_init(cr, ctx)
|
||||
#pooler.restart_pool(cr.dbname)
|
||||
return res
|
||||
|
@ -335,8 +337,11 @@ class ir_model_fields(osv.osv):
|
|||
if self.pool.get(vals['model']):
|
||||
self.pool.get(vals['model']).__init__(self.pool, cr)
|
||||
#Added context to _auto_init for special treatment to custom field for select_level
|
||||
ctx = context.copy()
|
||||
ctx.update({'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0'),'update_custom_fields':True})
|
||||
ctx = dict(context,
|
||||
field_name=vals['name'],
|
||||
field_state='manual',
|
||||
select=vals.get('select_level', '0'),
|
||||
update_custom_fields=True)
|
||||
self.pool.get(vals['model'])._auto_init(cr, ctx)
|
||||
|
||||
return res
|
||||
|
@ -446,8 +451,8 @@ class ir_model_fields(osv.osv):
|
|||
# was called earlier, they will be in-sync before the _auto_init.
|
||||
# Anything we don't update in _columns now will be reset from
|
||||
# the model into ir.model.fields (db).
|
||||
ctx = context.copy()
|
||||
ctx.update({'select': vals.get('select_level','0'),'update_custom_fields':True})
|
||||
ctx = dict(context, select=vals.get('select_level', '0'),
|
||||
update_custom_fields=True)
|
||||
|
||||
for __, patch_struct in models_patch.items():
|
||||
obj = patch_struct[0]
|
||||
|
@ -825,20 +830,16 @@ class ir_model_data(osv.osv):
|
|||
'res_id': inherit_id.id,
|
||||
'noupdate': noupdate,
|
||||
},context=context)
|
||||
if xml_id:
|
||||
if res_id:
|
||||
self.loads[(module, xml_id)] = (model, res_id)
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_field = model_obj._inherits[table]
|
||||
inherit_id = model_obj.read(cr, uid, res_id,
|
||||
[inherit_field])[inherit_field]
|
||||
self.loads[(module, xml_id + '_' + \
|
||||
table.replace('.', '_'))] = (table, inherit_id)
|
||||
if xml_id and res_id:
|
||||
self.loads[(module, xml_id)] = (model, res_id)
|
||||
for table, inherit_field in model_obj._inherits.iteritems():
|
||||
inherit_id = model_obj.read(cr, uid, res_id,
|
||||
[inherit_field])[inherit_field]
|
||||
self.loads[(module, xml_id + '_' + table.replace('.', '_'))] = (table, inherit_id)
|
||||
return res_id
|
||||
|
||||
def ir_set(self, cr, uid, key, key2, name, models, value, replace=True, isobject=False, meta=None, xml_id=False):
|
||||
if type(models[0])==type([]) or type(models[0])==type(()):
|
||||
if isinstance(models[0], (list, tuple)):
|
||||
model,res_id = models[0]
|
||||
else:
|
||||
res_id=None
|
||||
|
@ -858,7 +859,7 @@ class ir_model_data(osv.osv):
|
|||
res = cr.fetchone()
|
||||
if not res:
|
||||
ir_values_obj = pooler.get_pool(cr.dbname).get('ir.values')
|
||||
res = ir_values_obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
|
||||
ir_values_obj.set(cr, uid, key, key2, name, models, value, replace, isobject, meta)
|
||||
elif xml_id:
|
||||
cr.execute('UPDATE ir_values set value=%s WHERE model=%s and key=%s and name=%s'+where,(value, model, key, name))
|
||||
return True
|
||||
|
@ -890,8 +891,6 @@ class ir_model_data(osv.osv):
|
|||
for data in self.browse(cr, uid, ids, context):
|
||||
model = data.model
|
||||
res_id = data.res_id
|
||||
model_obj = self.pool.get(model)
|
||||
name = tools.ustr(data.name)
|
||||
|
||||
pair_to_unlink = (model, res_id)
|
||||
if pair_to_unlink not in to_unlink:
|
||||
|
@ -909,19 +908,19 @@ class ir_model_data(osv.osv):
|
|||
for model,res_id in wkf_todo:
|
||||
try:
|
||||
wf_service.trg_write(uid, model, res_id, cr)
|
||||
except:
|
||||
_logger.info('Unable to force processing of workflow for item %s@%s in order to leave activity to be deleted', res_id, model)
|
||||
except Exception:
|
||||
_logger.info('Unable to force processing of workflow for item %s@%s in order to leave activity to be deleted', res_id, model, exc_info=True)
|
||||
|
||||
def unlink_if_refcount(to_unlink):
|
||||
for model, res_id in to_unlink:
|
||||
external_ids = self.search(cr, uid, [('model', '=', model),('res_id', '=', res_id)])
|
||||
if (set(external_ids)-ids_set):
|
||||
if set(external_ids)-ids_set:
|
||||
# if other modules have defined this record, we must not delete it
|
||||
continue
|
||||
_logger.info('Deleting %s@%s', res_id, model)
|
||||
try:
|
||||
self.pool.get(model).unlink(cr, uid, [res_id], context=context)
|
||||
except:
|
||||
except Exception:
|
||||
_logger.info('Unable to delete %s@%s', res_id, model, exc_info=True)
|
||||
|
||||
# Remove non-model records first, then model fields, and finish with models
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search modules">
|
||||
<field name="name" filter_domain="['|', ('name','ilike',self), ('description','ilike',self)]" string="Module"/>
|
||||
<field name="description" string="Keywords" filter_domain="['|', '|', ('description', 'ilike', self), ('summary', 'ilike', self), ('shortdesc', 'ilike', self)]"/>
|
||||
<field name="name" filter_domain="['|', '|', '|', ('description', 'ilike', self), ('summary', 'ilike', self), ('shortdesc', 'ilike', self), ('name',
|
||||
'ilike', self)]"/>
|
||||
<filter name="app" icon="terp-check" string="Apps" domain="[('application', '=', 1)]"/>
|
||||
<filter name="extra" icon="terp-check" string="Extra" domain="[('application', '=', 0)]"/>
|
||||
<separator/>
|
||||
|
@ -188,7 +188,10 @@
|
|||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="context">{'search_default_app':1}</field>
|
||||
<field name="search_view_id" ref="view_module_filter"/>
|
||||
<field name="help">You can install new modules in order to activate new features, menu, reports or data in your OpenERP instance. To install some modules, click on the button "Install" from the form view and then click on "Start Upgrade".</field>
|
||||
<field name="help" type="html">
|
||||
<p><b>No module found!</b></p>
|
||||
<p>You should try others search criteria.</p>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem id="menu_module_tree" parent="base.menu_management" name="Modules"
|
||||
sequence="1" action="open_module_tree"/>
|
||||
|
|
|
@ -1,54 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="res_config_view_base" model="ir.ui.view">
|
||||
<field name="name">res.config.view.base</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form version="7.0">
|
||||
<group string="res_config_contents"/>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Apply" class="oe_highlight"/>
|
||||
or
|
||||
<button name="action_skip" type="object" special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<data>
|
||||
|
||||
<record id="view_config_wizard_form" model="ir.ui.view">
|
||||
<field name="name">Compabitiliby configuration wizard</field>
|
||||
<field name="model">ir.actions.configuration.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Next Configuration Step" version="7.0">
|
||||
<group>
|
||||
<field name="note"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Continue" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="res_config_view_base" model="ir.ui.view">
|
||||
<field name="name">res.config.view.base</field>
|
||||
<field name="model">res.config</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form version="7.0">
|
||||
<group string="res_config_contents"/>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Apply" class="oe_highlight"/>
|
||||
or
|
||||
<button name="action_skip" type="object" special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="res_config_installer" model="ir.ui.view">
|
||||
<field name="name">Inheritable view for installer objects</field>
|
||||
<field name="model">res.config.installer</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form version="7.0">
|
||||
<separator string="title" colspan="4"/>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Install Modules" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Skip" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_config_wizard_form" model="ir.ui.view">
|
||||
<field name="name">Compabitiliby configuration wizard</field>
|
||||
<field name="model">ir.actions.configuration.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Next Configuration Step" version="7.0">
|
||||
<group>
|
||||
<field name="note"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Continue" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
<record id="res_config_installer" model="ir.ui.view">
|
||||
<field name="name">Inheritable view for installer objects</field>
|
||||
<field name="model">res.config.installer</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form version="7.0">
|
||||
<separator string="title" colspan="4"/>
|
||||
<footer>
|
||||
<button name="action_next" type="object" string="Install Modules" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Skip" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -329,12 +329,14 @@
|
|||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="context">{"search_default_customer":1}</field>
|
||||
<field name="search_view_id" ref="view_res_partner_filter"/>
|
||||
<field name="help">
|
||||
Click on "Create" to add a new contact in your address book.
|
||||
<p>
|
||||
A contact is either a person or a company; a person can be linked to a company as a contact of that company.
|
||||
<p>
|
||||
You will be able to follow documents and history of your contacts (invoices, meetings, projects, etc.)
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to add a contact in your address book.
|
||||
</p><p>
|
||||
OpenERP helps you easily track all activities related to
|
||||
a customer; discussions, history of business opportunities,
|
||||
documents, etc.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_partner_form_view1" model="ir.actions.act_window.view">
|
||||
|
@ -366,12 +368,14 @@
|
|||
<field name="domain">[('customer','=',1)]</field>
|
||||
<field name="context">{'default_customer':1, 'search_default_customer':1}</field>
|
||||
<field name="filter" eval="True"/>
|
||||
<field name="help">
|
||||
Click on "Create" to add a new customer in your address book.
|
||||
<p>
|
||||
A contact is either a person or a company; a person can be linked to a company as a contact of that company.
|
||||
<p>
|
||||
You will be able to follow documents and history of your contacts (invoices, meetings, projects, etc.)
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to add a contact in your address book.
|
||||
</p><p>
|
||||
OpenERP helps you easily track all activities related to
|
||||
a customer: discussions, history of business opportunities,
|
||||
documents, etc.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
@ -384,12 +388,14 @@
|
|||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="context">{'search_default_supplier': 1,'default_customer': 0,'default_supplier': 1}</field>
|
||||
<field name="filter" eval="True"/>
|
||||
<field name="help">
|
||||
Click on "Create" to add a new supplier in your address book.
|
||||
<p>
|
||||
A supplier is either a person or a company; a person can be linked to a company as a contact of that company.
|
||||
<p>
|
||||
You will be able to follow documents and history of your contacts (invoices, meetings, projects, etc.)
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
Click to add a contact in your address book.
|
||||
</p><p>
|
||||
OpenERP helps you easily track all activities related to
|
||||
a supplier: discussions, history of purchases,
|
||||
documents, etc.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -117,7 +117,6 @@
|
|||
"access_res_widget_user","res.widget.user","model_res_widget",,1,0,0,0
|
||||
"access_ir_config_parameter","ir_config_parameter","model_ir_config_parameter",,1,0,0,0
|
||||
"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_ir_needaction_users_rel","ir_needaction_users_rel","model_ir_needaction_users_rel",,1,1,1,1
|
||||
"access_ir_needaction_mixin","ir_needaction_mixin","model_ir_needaction_mixin",,1,1,1,1
|
||||
|
|
|
|
@ -127,6 +127,23 @@ class _column(object):
|
|||
res = obj.read(cr, uid, ids, [name], context=context)
|
||||
return [x[name] for x in res]
|
||||
|
||||
def as_display_name(self, cr, uid, obj, value, context=None):
|
||||
"""Converts a field value to a suitable string representation for a record,
|
||||
e.g. when this field is used as ``rec_name``.
|
||||
|
||||
:param obj: the ``BaseModel`` instance this column belongs to
|
||||
:param value: a proper value as returned by :py:meth:`~openerp.orm.osv.BaseModel.read`
|
||||
for this column
|
||||
"""
|
||||
# delegated to class method, so a column type A can delegate
|
||||
# to a column type B.
|
||||
return self._as_display_name(self, cr, uid, obj, value, context=None)
|
||||
|
||||
@classmethod
|
||||
def _as_display_name(cls, field, cr, uid, obj, value, context=None):
|
||||
# This needs to be a class method, in case a column type A as to delegate
|
||||
# to a column type B.
|
||||
return tools.ustr(value)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Simple fields
|
||||
|
@ -154,11 +171,6 @@ class integer(_column):
|
|||
|
||||
def __init__(self, string='unknown', required=False, **args):
|
||||
super(integer, self).__init__(string=string, required=required, **args)
|
||||
if required:
|
||||
_logger.debug(
|
||||
"required=True is deprecated: making an integer field"
|
||||
" `required` has no effect, as NULL values are "
|
||||
"automatically turned into 0.")
|
||||
|
||||
class reference(_column):
|
||||
_type = 'reference'
|
||||
|
@ -178,6 +190,17 @@ class reference(_column):
|
|||
result[value['id']] = False
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def _as_display_name(cls, field, cr, uid, obj, value, context=None):
|
||||
if value:
|
||||
# reference fields have a 'model,id'-like value, that we need to convert
|
||||
# to a real name
|
||||
model_name, res_id = value.split(',')
|
||||
model = obj.pool.get(model_name)
|
||||
if model and res_id:
|
||||
return model.name_get(cr, uid, [int(res_id)], context=context)[0][1]
|
||||
return tools.ustr(value)
|
||||
|
||||
class char(_column):
|
||||
_type = 'char'
|
||||
|
||||
|
@ -218,11 +241,6 @@ class float(_column):
|
|||
self.digits = digits
|
||||
# synopsis: digits_compute(cr) -> (precision, scale)
|
||||
self.digits_compute = digits_compute
|
||||
if required:
|
||||
_logger.debug(
|
||||
"required=True is deprecated: making a float field"
|
||||
" `required` has no effect, as NULL values are "
|
||||
"automatically turned into 0.0.")
|
||||
|
||||
def digits_change(self, cr):
|
||||
if self.digits_compute:
|
||||
|
@ -453,6 +471,11 @@ class many2one(_column):
|
|||
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, context=None):
|
||||
return obj.pool.get(self._obj).search(cr, uid, args+self._domain+[('name', 'like', value)], offset, limit, context=context)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _as_display_name(cls, field, cr, uid, obj, value, context=None):
|
||||
return value[1] if isinstance(value, tuple) else tools.ustr(value)
|
||||
|
||||
|
||||
class one2many(_column):
|
||||
_classic_read = False
|
||||
|
@ -543,6 +566,10 @@ class one2many(_column):
|
|||
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, operator='like', context=None):
|
||||
return obj.pool.get(self._obj).name_search(cr, uid, value, self._domain, operator, context=context,limit=limit)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _as_display_name(cls, field, cr, uid, obj, value, context=None):
|
||||
raise NotImplementedError('One2Many columns should not be used as record name (_rec_name)')
|
||||
|
||||
#
|
||||
# Values: (0, 0, { fields }) create
|
||||
|
@ -725,6 +752,10 @@ class many2many(_column):
|
|||
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None, operator='like', context=None):
|
||||
return obj.pool.get(self._obj).search(cr, uid, args+self._domain+[('name', operator, value)], offset, limit, context=context)
|
||||
|
||||
@classmethod
|
||||
def _as_display_name(cls, field, cr, uid, obj, value, context=None):
|
||||
raise NotImplementedError('Many2Many columns should not be used as record name (_rec_name)')
|
||||
|
||||
|
||||
def get_nice_size(value):
|
||||
size = 0
|
||||
|
@ -1078,6 +1109,12 @@ class function(_column):
|
|||
if self._fnct_inv:
|
||||
self._fnct_inv(obj, cr, user, id, name, value, self._fnct_inv_arg, context)
|
||||
|
||||
@classmethod
|
||||
def _as_display_name(cls, field, cr, uid, obj, value, context=None):
|
||||
# Function fields are supposed to emulate a basic field type,
|
||||
# so they can delegate to the basic type for record name rendering
|
||||
return globals()[field._type]._as_display_name(field, cr, uid, obj, value, context=context)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Related fields
|
||||
# ---------------------------------------------------------
|
||||
|
@ -1211,7 +1248,6 @@ class related(function):
|
|||
result[-1]['relation'] = f['relation']
|
||||
self._relations = result
|
||||
|
||||
|
||||
class sparse(function):
|
||||
|
||||
def convert_value(self, obj, cr, uid, record, value, read_value, context=None):
|
||||
|
|
|
@ -2280,12 +2280,12 @@ class BaseModel(object):
|
|||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
|
||||
rec_name = self._rec_name
|
||||
if rec_name not in self._columns:
|
||||
res = [(r['id'], "%s,%s"%(self._name,r['id'])) for r in self.read(cr, user, ids, ['id'], context, load='_classic_write')]
|
||||
else:
|
||||
res = [(r['id'], tools.ustr(r[rec_name])) for r in self.read(cr, user, ids, [rec_name], context, load='_classic_write')]
|
||||
return res
|
||||
if self._rec_name in self._all_columns:
|
||||
rec_name_column = self._all_columns[self._rec_name].column
|
||||
return [(r['id'], rec_name_column.as_display_name(cr, user, self, r[self._rec_name], context=context))
|
||||
for r in self.read(cr, user, ids, [self._rec_name],
|
||||
load='_classic_write', context=context)]
|
||||
return [(id, "%s,%s" % (self._name, id)) for id in ids]
|
||||
|
||||
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
|
||||
"""Search for records that have a display name matching the given ``name`` pattern if compared
|
||||
|
@ -4160,6 +4160,12 @@ class BaseModel(object):
|
|||
|
||||
self.check_create(cr, user)
|
||||
|
||||
if self._log_access:
|
||||
for f in LOG_ACCESS_COLUMNS:
|
||||
if vals.pop(f, None) is not None:
|
||||
_logger.warning(
|
||||
'Field `%s` is not allowed when creating the model `%s`.',
|
||||
f, self._name)
|
||||
vals = self._add_missing_default_values(cr, user, vals, context)
|
||||
|
||||
tocreate = {}
|
||||
|
|
|
@ -142,18 +142,20 @@ def _eval_xml(self, node, pool, cr, uid, idref, context=None):
|
|||
except Exception:
|
||||
_logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True)
|
||||
return ""
|
||||
def _process(s, idref):
|
||||
m = re.findall('[^%]%\((.*?)\)[ds]', s)
|
||||
for id in m:
|
||||
if not id in idref:
|
||||
idref[id]=self.id_get(cr, id)
|
||||
return s % idref
|
||||
if t == 'xml':
|
||||
def _process(s, idref):
|
||||
m = re.findall('[^%]%\((.*?)\)[ds]', s)
|
||||
for id in m:
|
||||
if not id in idref:
|
||||
idref[id]=self.id_get(cr, id)
|
||||
return s % idref
|
||||
_fix_multiple_roots(node)
|
||||
return '<?xml version="1.0"?>\n'\
|
||||
+_process("".join([etree.tostring(n, encoding='utf-8')
|
||||
for n in node]),
|
||||
idref)
|
||||
for n in node]), idref)
|
||||
if t == 'html':
|
||||
return _process("".join([etree.tostring(n, encoding='utf-8')
|
||||
for n in node]), idref)
|
||||
if t in ('char', 'int', 'float'):
|
||||
d = node.text
|
||||
if t == 'int':
|
||||
|
|
Loading…
Reference in New Issue