I have user group(that is not working properly now)
and I want that only users in this group could confirm invoice that is in state = 'draft' and type = 'in_refund' all other users should get an error that they not in this particular group. I think that I need to create a method in account.invoice
that will check if the user in this group but I have no clue how.
<record model="ir.module.category" id="module_management">
<field name="name">Asortment</field>
<field name="description">User access level for this module</field>
<field name="sequence">3</field>
</record>
<record id="group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="account.group_manager"/>
</record>
"id" "name" "model_id:id" "group_id:id" "perm_read" "perm_write" "perm_create" "perm_unlink"
"User" "Asortment" "model_account_invoice" "account.group_manager" "1" "1" "1" "1"
You can achieve this by specifying the groups
in button definition.
Ex:
<button name="function_name" type="object" string="Confirm" groups="module_name.group_manager"/>
The button Confirm is only visible to the users in the group_manager
group.
OR
You can use has_group
function to check whether the user belongs to the group group_manager
.
if self.env.user.has_group('account.group_supplier_inv_check_total'):
// Write your statement
else:
raise UserError(_('Your error message'))
Hope it will help you.