初始数据:
翻拍/ 开幕式 .py>>的全成
cnts = {'1':1, '2': 3, '3':1, ...}
重制/ 初始 .py>>的全成
# -*- coding: utf-8 -*-
{
'name': 'Remake',
'version': '1.0.1',
'author': 'BZ Group',
'category': 'System',
'sequence': 8,
'depends': [
'base',
'account',
'project',
'account_analytic_analysis'
],
'data': [
'security/remake_security.xml',
'security/ir.model.access.csv',
],
'installable': True,
'application': True,
'post_init_hook': 'set_account_analytic_account_project_id',
}
翻拍/ account_analytic_project_id.py>>的全成
# -*- coding: utf-8 -*-
from . import account_analytic_project_id
from .post_install import set_account_analytic_account_project_id
翻拍/ post_install.py>>的全成
# -*- coding: utf-8 -*-
from openerp import fields, models, api
class AccountAnalyticAccount(models.Model):
_inherit = 'account.analytic.account'
project_id = fields.Many2one(
'project.project', 'Project', copy=False,
index=True)
class ProjectProject(models.Model):
_name = 'project.project'
_inherit = 'project.project'
@api.model
@api.returns('self', lambda value: value.id)
def create(self, vals):
project = super(ProjectProject, self).create(vals)
project.analytic_account_id.sudo().write({'project_id': project.id})
return project
翻拍/安全/ ir.model.access.csv>>的全成
def set_account_analytic_account_project_id(cr, pool):
'''
Initialize the project_id field in case the module is
installed when projects already exist
'''
cr.execute("""
update account_analytic_account
set project_id = (select id
from project_project where
analytic_account_id = account_analytic_account.id)
""")
return
remake / security / remake_security.xml>> 需要帮助:remake_g4_rule_account
id, name, model_id:id, group_id:id,perm_read,perm_write,perm_create,perm_unlink
remake_g4_pr_pr, remake_g4_pr.pr, project.model_project_project, remake.remake_g4,1,0,0,0
remake_g4_ac_an_in_ln, remake_g4_ac.an.in.ln, account_analytic_analysis.model_account_analytic_invoice_line, remake.remake_g4,1,0,0,0
remake_g4_ac_an_ac, remake_g4_ac.an.ac, analytic.model_account_analytic_account, remake.remake_g4,1,0,0,0
remake_g4_ac_ac, remake_g4_ac.ac, account.model_account_account, remake.remake_g4,1,0,0,0
remake_g4_pr_ac_an_ln, remake_g4_pr.ac.an.ln, account.model_project_account_analytic_line, remake.remake_g4,1,0,0,0
remake_g4_ac_in, remake_g4_ac.in, account.model_account_invoice, remake.remake_g4,1,0,0,0
remake_g4_ac_in_ln, remake_g4_ac.in.ln, account.model_account_invoice_line, remake.remake_g4,1,0,0,0
转到销售时>合同:
结果: AccessError,请求的操作无法完成安全限制。请联系您的系统 管理员。(文档类型:account.analytic.account,操作: 读取)
答案 0 :(得分:0)
您需要在ir.model.access.csv中创建访问规则,并为该特定模型和组以及CRUD访问定义访问规则。 那会对你有用。