Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3789 Переглядів

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
лист. 23
1490
2
груд. 17
4018
0
жовт. 24
1379
0
груд. 23
2417
1
груд. 16
4477