Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3928 Lượt xem

I'm trying to set a couple of automated actions in Odoo 8. 

What i want to do is:

  • Automatically add the customer assigned to a project to the portal group when project begins.

  • Automatically delete the customer assigned to a project from the portal group when project ends.

The objetive of that is to automate the management of the portal access, so only customers who have an active project have permission access to portal.

Currently I'm trying to do that with Automated Actions /  Server Actions, so i created a Server Action named "Add user to portal group" wich "Base Model" is Partner that execute the following python code:

"Add user to portal group" Server Action: 

flag = self.pool.get('res.users').has_group(cr, model.id, 'base.group_portal')
if not flag:
 res_groups = self.pool['res.groups']
 users = self.pool['res.users'].search(cr, uid, [('id', '=', model.id)], context)
 group_id = self.pool['ir.model.data'].get_object(cr, uid, 'base', 'group_portal')
 res_groups.write(cr, uid, [group_id], {'users': [(4, user) for user in users]}, context=context)

Then i created an Automated Action named "Enable access to portal based on project duration", with this  parameters:

  • Related Document Model: "Project"

  • When to Run: "Based on Timed Condition"

  • Trigger Date: "Expiration Date"

  • Delay After Trigger Date: 0 Days.

The  first problem i have is that Automated Action Related Model  is "Project" and the Server Action Base Model is  Partner so I can't associate the Server Action  to the Automated Action.

I'm a bit confused and I do not know how to approach this issue in the simplest way possible :-)

I think that adding / removing membership to a group automatically can be of interest to many users, so any help?

Best regards,

Mario Pino

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 23
1590
2
thg 12 17
4114
0
thg 10 24
1481
0
thg 12 23
2544
1
thg 12 16
4607