Skip to content

Commit

Permalink
Merge pull request #4 from Merctrans/feature/create-user-group
Browse files Browse the repository at this point in the history
created 2 new user groups
  • Loading branch information
svseas authored Dec 18, 2023
2 parents ae09801 + b827670 commit bcc73f3
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion local-addons/morons/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-

from . import controllers
from . import models
from . import models

# admin can see all contributors and all POs that they are creating: old/ current and upcoming
4 changes: 3 additions & 1 deletion local-addons/morons/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Uncategorized',
'category': 'Morons',
'version': '0.1',

# any module necessary for this one to work correctly
Expand All @@ -26,6 +26,8 @@
# 'security/ir.model.access.csv',
'views/project.xml',
'views/user.xml',
"security/ir.model.access.csv",
"security/security.xml",
'data/languages.xml',
'data/currencies.xml',
'data/email_template.xml',
Expand Down
1 change: 1 addition & 0 deletions local-addons/morons/models/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytz


# uncomment and create a view for it
class InternalUser(models.Model):
"""MercTrans Internal Users"""
_inherit = ["res.users"]
Expand Down
3 changes: 1 addition & 2 deletions local-addons/morons/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sample_module_sample_module,sample_module.sample_module,model_sample_module_sample_module,base.group_user,1,1,1,1
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
86 changes: 86 additions & 0 deletions local-addons/morons/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- create 2 groups: PM, contributor - assign different rights (he will give sample) -->
<record model="ir.module.category" id="module_category_morons">
<field name="name">Morons</field>
</record>

<!-- Update the group to use this category -->
<record id="group_contributors" model="res.groups">
<field name="name">Contributors</field>
<field name="category_id" ref="module_category_morons"/>
</record>

<record id="group_pm" model="res.groups">
<field name="name">PM</field>
<field name="category_id" ref="module_category_morons"/>
</record>

<!-- Create CRUD rights -->
<record id="module_category_contributor_access" model="ir.model.access">
<field name="name">Contributor access</field>
<field name="model_id" ref="morons.model_project_task"/>
<field name="group_id" ref="morons.group_contributors"/>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="0"/>
<field name="perm_create" eval="0"/>
<field name="perm_unlink" eval="0"/>
</record>

<record id="module_category_pm_access" model="ir.model.access">
<field name="name">PM access</field>
<field name="model_id" ref="morons.model_project_task"/>
<field name="group_id" ref="morons.group_pm"/>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_unlink" eval="1"/>
</record>

<!-- Rule for normal users -->
<!-- <record id="rule_supreme_court_letter_own" model="ir.rule">
<field name="name">Supreme Court Letter Own</field>
<field name="model_id" ref="supco.model_supreme_court_letter"/>
<field name="domain_force">[('created_by', '=', user.id)]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
</record> -->

<record model="ir.rule" id="rule_po_contributor_access">
<field name="name">PO Contributor Access</field>
<field name="model_id" ref="morons.model_project_task"/>
<field name="domain_force">[('user_id','=',user.id)]</field>
<field name="groups" eval="[( 4, ref('morons.group_contributors'))]"/>
</record>


<record model="ir.rule" id="rule_po_pm_access">
<field name="name">PO PM Access</field>
<field name="model_id" ref="morons.model_project_task"/>
<field name="domain_force">[('user_id','=',user.id)]</field>
<field name="groups" eval="[(4, ref('morons.group_pm'))]"/>
</record>

<!-- Rule for first approver -->
<!-- <record id="rule_supreme_court_letter_first_approval" model="ir.rule">
<field name="name">Supreme Court Letter First Approval</field>
<field name="model_id" ref="supco.model_supreme_court_letter"/>
<field name="domain_force">['|', '|', '|', ('created_by', '=', user.id), '&amp;', ('created_by', '!=',
user.id),
('approval_status', '=', 'waiting_first_approval'), ('approval_status', '=', 'waiting_second_approval'),
('reject_by', '=', user.id)]
</field>
<field name="groups" eval="[(4, ref('supco.group_first_approval'))]"/>
</record> -->

<!-- <record id="rule_supreme_court_letter_second_approval" model="ir.rule">
<field name="name">Supreme Court Letter Second Approval</field>
<field name="model_id" ref="supco.model_supreme_court_letter"/>
<field name="domain_force">['|', '|', ('created_by', '=', user.id), '|', ('approval_status', '=',
'waiting_second_approval'),
('approval_status', '=', 'approved'), ('reject_by', '=', user.id)]
</field>
<field name="groups" eval="[(4, ref('supco.group_second_approval'))]"/>
</record> -->
</data>
</odoo>

0 comments on commit bcc73f3

Please sign in to comment.