I created a new customized model in odoo 17 using studio, it's a form. There's this pipeline stages. (New request, For Approval, On progress, and Done).
I put a button on it. And this button called, "submit". I created the button's action in Technical>Server Actions>Execute Code. Now, i want this button to function as, when the normal user filled up the form, then clicked the submit button, the form will change to next stage (From 'new request' to 'for approval' stage). And the some fields in the form must change to not fillable field or readonly. (Only user who have a administrative rights can edit it.)
Here's the execute code that i tried..
`
for record in records:
values = {
'x_studio_stage_id': 2,
}
record.write(values)
field_names = ['x_name', 'x_studio_position', 'x_studio_department', 'x_studio_read', 'x_studio_write', 'x_studio_create', 'x_studio_delete', 'x_studio_reason_and_justification'] # Replace with your field names
fields = env['ir.model.fields'].search([('model', '=', 'x_access_request'), ('name', 'in', field_names)])
group_id = env.ref('__export__.res_groups_183_e7aae201').id
access = env['ir.model.access'].search([('model_id', '=', model_id), ('group_id', '=', group_id)])
if not access:
access = env['ir.model.access'].create({
'name': 'Access Rights for Group',
'model_id': model_id,
'group_id': group_id,
})
for field in fields:
access.write({
'perm_read': [(4, field.id)], # Add readonly permission
'perm_write': [(3, field.id)], # Remove write permission
})
But it's telling the user to have a "administration/access rights" permission.