i look this error i all internet but i really dont understand the answers, i hard to understand what is the function given to you or what it has to give to you, i let you my code i hope any one help
我看起来这个错误我所有的互联网,但我真的不明白的答案,我很难理解给你的功能是什么或它给你什么,我让你的代码我希望任何一个帮助
What im looking for? i need to put into act_user_suc the users sucursal_u fro res_users thats all and i relly apreciated the help
我在寻找什么?我需要把act_user_suc用户sucursal_u从res_users中解放出来,而且我非常感谢apreciated的帮助
class bodega(osv.Model):
_name = 'bodega'
_description = 'datos generales'
def dame_usuario(self, cr, uid, ids, fieldname, arg, context=None):
digits = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id
return digits
_columns = {
'name': fields.char("Name", required=True),
'act_user_suc': fields.function(dame_usuario, type='many2one', readonly = True),
}
_defaults = {
}
bodega()
1 个解决方案
#1
1
You need to update few things in code.
您需要在代码中更新一些内容。
Specify relation
attribute in fields.function
, you have defined that many2one
as field type but it's related to which model ?.
在fields.function中指定关系属性,您已将many2one定义为字段类型,但它与哪个模型相关?
And other things is that company_id.currency_id
it gives you an browsable object not an id.
而其他的东西就是company_id.currency_id它给你一个可浏览的对象而不是id。
So try following,
所以尝试下面,
def dame_usuario(self, cr, uid, ids, fieldname, arg, context=None):
res = {}
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = False
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user and user.sucursal_u:
result[obj.id] = user.sucursal_u.id
return res
_columns = {
'name': fields.char("Name", required=True),
'act_user_suc': fields.function(dame_usuario,
type='many2one', readonly = True, relation='sucursales'),
}
#1
1
You need to update few things in code.
您需要在代码中更新一些内容。
Specify relation
attribute in fields.function
, you have defined that many2one
as field type but it's related to which model ?.
在fields.function中指定关系属性,您已将many2one定义为字段类型,但它与哪个模型相关?
And other things is that company_id.currency_id
it gives you an browsable object not an id.
而其他的东西就是company_id.currency_id它给你一个可浏览的对象而不是id。
So try following,
所以尝试下面,
def dame_usuario(self, cr, uid, ids, fieldname, arg, context=None):
res = {}
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = False
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user and user.sucursal_u:
result[obj.id] = user.sucursal_u.id
return res
_columns = {
'name': fields.char("Name", required=True),
'act_user_suc': fields.function(dame_usuario,
type='many2one', readonly = True, relation='sucursales'),
}