I want to create access rights to the credit_limit module. Only Admin can 'approve' the Credit Limit. For normal users, just until the display below there should be an 'Approve' button to the right of 'Cancel'. And only logged in user data is displayed. Please help me...
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
1.Create Access Rights in XML
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_credit_limit_admin,access_credit_limit_admin,model_credit_limit,base.group_system,1,1,1,1
access_credit_limit_user,access_credit_limit_user,model_credit_limit,,1,0,0,0
2. Modify the Model
class CreditLimit(models.Model):
_name = 'credit.limit'
_description = 'Credit Limit'
name = fields.Char(string='Credit Limit Name')
credit_limit = fields.Float(string='Credit Limit Amount')
approved = fields.Boolean(string='Approved', default=False)
@api.multi def action_approve(self):
if not self.env.user.has_group('base.group_system'):
raise AccessError("You do not have permission to approve credit limits.")
self.approved = True
3. Update the View
<odoo>
<record id="view_credit_limit_form" model="ir.ui.view">
<field name="name">credit.limit.form</field>
<field name="model">credit.limit</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
<field name="credit_limit"/>
</group>
<footer>
<button name="action_approve"
type="object"
string="Approve"
states="draft"
attrs="{'invisible': [('approved', '=', True)]}"
class="btn-primary"/>
<button string="Cancel" class="btn-secondary" type="object" name="action_cancel"/>
</footer>
</sheet>
</form>
</field>
</record>
<record id="view_credit_limit_tree" model="ir.ui.view">
<field name="name">credit.limit.tree</field>
<field name="model">credit.limit</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="credit_limit"/>
<field name="approved"/>
</tree>
</field>
</record>
</odoo>
Hope it helps
Hello,
You have to create a "Credit Limit Approver" group from the XML file and assign that group to the "Approve" button.
After creating this group assign an admin user inside that group, now only the admin can see the "Approve" button.
Thanks,
info@creyox.com
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 7 24
|
1729 | ||
|
1
thg 12 23
|
4302 | ||
|
0
thg 7 24
|
4 | ||
|
0
thg 6 24
|
1223 | ||
How to define user groups?
Đã xử lý
|
|
1
thg 12 22
|
10726 |