在odoo 10中为自定义模块创建安全组 [英] Creating security groups for a custom module in odoo 10
问题描述
我已经在odoo 10上创建了一个自定义模块.现在,我想与用户一起创建安全组,其中每个组都具有我的自定义模块的特定菜单.我已经问过这个问题,我遵循了我得到的答案,但是我没有得到结果(我肯定在某个时候搞砸了,但是我看不到哪里,这是我第一次与ood合作),所以我问再来一个问题.这是我所做的:
I have created a custom module on odoo 10. Now I wanted to create security groups with users where each group have a particular menu of my custom module. I've already asked this question and I followed the answers that I got but I did not get the results (I definitely messed up at some point but I can't see where, this is my first time working with odoo) so I ask again the question. Here's what I did:
我在安全文件夹中创建了文件security.xml,其中包含以下内容
I created a file security.xml in my security folder with contain the following
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<!-- Creating a Group Category -->
<record id="evaluation_subj" model="ir.module.category">
<field name="name">evaluation subjective</field>
<field name="sequence">1</field>
</record>
<!-- Adding a Group to the Group Category -->
<record id="group_eval_subj" model="res.groups">
<field name="name">Groupe Evaluation Subjective</field>
<field name="evaluation_subj" ref="evaluation subjective"/>
<!-- Adding Rights of existing Groups -->
<field name="implied_ids"
eval="[(4, ref('base.group_system')),
(4,ref('base.group_sale_manager'))]"/>
</record>
</data>
</odoo>
然后在文件pnc_menus.xml中(我有一个名为pnc_menus.xml的文件,在该文件中创建了所有菜单),我在该菜单中添加了groups字段:
Then in the file pnc_menus.xml (I have a file called pnc_menus.xml where I created all of my menus) I added the groups field to this menu:
<menuitem name="Parties Prenantes" id="pnc_evaluation_stakeholders"
action="pncevaluation_partieprenante" parent="pnc_documents" sequence="40" groups="base.group_system"/>
然后在安全文件夹的csv文件中添加以下内容:
Then in csv file of my security folder I added this :
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
eval_group,groupe_evaluation,pnc_evaluation_stakeholders,group_eval_subj,1,1,1,1
更新模块时出现错误,提示无法处理csv文件"
When I updated my module I have an error saying "csv file could not be proccessed"
In the log file I have this:
`Exception: Module loading pncevaluation failed: file pncevaluation\security/ir.model.access.csv could not be processed:
Aucun enregistrement trouv\xe9 pour id externe 'group_eval_subj' dans le champ 'Group'
ERREUR: une instruction insert ou update sur la table \xab ir_model_access \xbb viole la contrainte de cl\xe9
\xe9trang\xe8re \xab ir_model_access_model_id_fkey \xbb
DETAIL: La cl\xe9 (model_id)=(559) n'est pas pr\xe9sente dans la table \xab ir_model \xbb.
File "D:\Odoo 10.0\server\odoo\tools\convert.py", line 898, in convert_csv_import
raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
Exception: Module loading pncevaluation failed: file pncevaluation\security/ir.model.access.csv could not be processed:
Aucun enregistrement trouv\xe9 pour id externe 'group_eval_subj' dans le champ 'Group'
ERREUR: une instruction insert ou update sur la table \xab ir_model_access \xbb viole la contrainte de cl\xe9
\xe9trang\xe8re \xab ir_model_access_model_id_fkey \xbb
DETAIL: La cl\xe9 (model_id)=(559) n'est pas pr\xe9sente dans la table \xab ir_model \xbb.
链接. >
推荐答案
在Odoo 10中,组group_sale_manager
从 base 移到了 sales_team .
因此,如下所示更改代码
The Group group_sale_manager
is moved from base to sales_team in Odoo 10.
So change your code like the below
<field name="implied_ids" eval="[(4, ref('base.group_system')), (4,ref('sales_team.group_sale_manager'))]"/>
别忘了在模块中添加sales_team依赖项
And do not forget to add sales_team dependency in your module
这篇关于在odoo 10中为自定义模块创建安全组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!