odoo ir.sequence 在使用系统管理员以外的用户时不工作
odoo ir.sequence not working when Use a user other than the system administrator
我正在开发 Openerp7
我尝试将附件转换为保存在服务器中的文件,而不是将它们保存在数据库中
我的问题是命名文件
我正在尝试使用 ir.sequence
为她的名字添加序列号
我用系统管理员登录的时候没问题
但是当使用任何其他用户登录时:ir.sequence 不创建序列
函数创建 return False
我的xml代码:
<record id="ir_attachment" model="ir.sequence.type">
<field name="name">ir attachment</field>
<field name="code">ir.attachment</field>
</record>
<record id="seq_ir_attachment" model="ir.sequence">
<field name="name">ir attachment</field>
<field name="code">ir.attachment</field>
<field name="prefix">Att</field>
<field name="padding">5</field>
<field name="implementation">no_gap</field>
</record>
python代码:
data_rec.write({'file_name':self.pool.get("ir.sequence").get(cr,uid,'ir.attachment')})
The get
method returns False
because the ir.attachment
company is not present in the currently visible companies and different from False
(set to default value).
get
方法将通过调用 _next 方法结束,如果我们提供一个空序列 ID 列表(seq_ids
,该方法将 return False
).
序列 ID 列表 (ids
) 计算如下:
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) + [False]
ids = self.search(cr, uid, ['&', ('code', '=', sequence_code), ('company_id', 'in', company_ids)])
使用系统管理员登录时可以正常使用,因为超级用户绕过了安全规则,可以看到所有可用的公司,但是用户根据规则只能select当前可见的公司.
在select显示当前用户的可见公司后,OpenERP 将False
添加到该列表(这意味着如果序列company_id
is not set,序列id 对应于传递给 search
方法的代码将始终被 returned 而不取决于用户设置)然后,它将尝试找到序列代码等于序列代码的序列 id传递给 get
方法,company_id
出现在 selected 公司中。
如果序列 company_id
字段值不存在于用户当前可见的公司中,它将 return 一个空列表并且 _next
方法将 return False
因为 seq_ids
是空的。
def _next(self, cr, uid, seq_ids, context=None):
if not seq_ids:
return False
在搜索结果中包含用户允许的公司:
res 公司搜索方法已更改,可以通过 user_preference
抛出上下文 return 用户公司及其允许的所有公司。
您可以在 res.company
_search 方法中找到突出显示的评论:
if context.get('user_preference'):
# We browse as superuser. Otherwise, the user would be able to
# select only the currently visible companies (according to rules,
# which are probably to allow to see the child companies) even if
# she belongs to some other companies.
user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)
cmp_ids = list(set([user.company_id.id] + [cmp.id for cmp in user.company_ids]))
return cmp_ids
例子:
if context is None:
context = {}
context["user_preference"] = True
self.pool.get("ir.sequence").get(cr, uid, 'ir.attachment', context=context)
在服务器文件系统中存储附件的替代方法:
要在OpenERP服务器文件系统中存储文件,您可以安装文件管理系统。
Managing Attachments OpenERP-7
If you do not install the document management system then the files that are attached to an OpenERP resource are stored directly in the database. Once the document management system has been installed, the contents of the files are no longer stored in the database but are stored instead on the OpenERP server filesystem in a directory named 'filestore'.
You can then read and add attachments to OpenERP resources quite independent of the OpenERP interface or the FTP server using simple drag and drop.
的文档
我正在开发 Openerp7 我尝试将附件转换为保存在服务器中的文件,而不是将它们保存在数据库中
我的问题是命名文件 我正在尝试使用 ir.sequence
为她的名字添加序列号我用系统管理员登录的时候没问题 但是当使用任何其他用户登录时:ir.sequence 不创建序列 函数创建 return False
我的xml代码:
<record id="ir_attachment" model="ir.sequence.type">
<field name="name">ir attachment</field>
<field name="code">ir.attachment</field>
</record>
<record id="seq_ir_attachment" model="ir.sequence">
<field name="name">ir attachment</field>
<field name="code">ir.attachment</field>
<field name="prefix">Att</field>
<field name="padding">5</field>
<field name="implementation">no_gap</field>
</record>
python代码:
data_rec.write({'file_name':self.pool.get("ir.sequence").get(cr,uid,'ir.attachment')})
The
get
method returnsFalse
because their.attachment
company is not present in the currently visible companies and different fromFalse
(set to default value).
get
方法将通过调用 _next 方法结束,如果我们提供一个空序列 ID 列表(seq_ids
,该方法将 return False
).
序列 ID 列表 (ids
) 计算如下:
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context) + [False]
ids = self.search(cr, uid, ['&', ('code', '=', sequence_code), ('company_id', 'in', company_ids)])
使用系统管理员登录时可以正常使用,因为超级用户绕过了安全规则,可以看到所有可用的公司,但是用户根据规则只能select当前可见的公司.
在select显示当前用户的可见公司后,OpenERP 将False
添加到该列表(这意味着如果序列company_id
is not set,序列id 对应于传递给 search
方法的代码将始终被 returned 而不取决于用户设置)然后,它将尝试找到序列代码等于序列代码的序列 id传递给 get
方法,company_id
出现在 selected 公司中。
如果序列 company_id
字段值不存在于用户当前可见的公司中,它将 return 一个空列表并且 _next
方法将 return False
因为 seq_ids
是空的。
def _next(self, cr, uid, seq_ids, context=None):
if not seq_ids:
return False
在搜索结果中包含用户允许的公司:
res 公司搜索方法已更改,可以通过 user_preference
抛出上下文 return 用户公司及其允许的所有公司。
您可以在 res.company
_search 方法中找到突出显示的评论:
if context.get('user_preference'):
# We browse as superuser. Otherwise, the user would be able to
# select only the currently visible companies (according to rules,
# which are probably to allow to see the child companies) even if
# she belongs to some other companies.
user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)
cmp_ids = list(set([user.company_id.id] + [cmp.id for cmp in user.company_ids]))
return cmp_ids
例子:
if context is None:
context = {}
context["user_preference"] = True
self.pool.get("ir.sequence").get(cr, uid, 'ir.attachment', context=context)
在服务器文件系统中存储附件的替代方法:
要在OpenERP服务器文件系统中存储文件,您可以安装文件管理系统。
Managing Attachments OpenERP-7
If you do not install the document management system then the files that are attached to an OpenERP resource are stored directly in the database. Once the document management system has been installed, the contents of the files are no longer stored in the database but are stored instead on the OpenERP server filesystem in a directory named 'filestore'.的文档You can then read and add attachments to OpenERP resources quite independent of the OpenERP interface or the FTP server using simple drag and drop.