仅由用户组中的用户确认发票
Confirm invoice only by user from usergroup
我有用户组(现在不能正常工作)
我希望只有该组中的用户才能确认处于状态 = 'draft' 和类型 = 'in_refund' 的发票,所有其他用户都应该得到一个错误,表明他们不在该特定组中。我想我需要在 account.invoice
中创建一个方法来检查用户是否在这个组中,但我不知道如何做。
<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"
您可以通过在按钮定义中指定 groups
来实现。
例如:
<button name="function_name" type="object" string="Confirm" groups="module_name.group_manager"/>
按钮确认仅对group_manager
组中的用户可见。
或
您可以使用has_group
函数来检查用户是否属于组group_manager
。
if self.env.user.has_group('account.group_supplier_inv_check_total'):
// Write your statement
else:
raise UserError(_('Your error message'))
希望对您有所帮助。
我有用户组(现在不能正常工作)
我希望只有该组中的用户才能确认处于状态 = 'draft' 和类型 = 'in_refund' 的发票,所有其他用户都应该得到一个错误,表明他们不在该特定组中。我想我需要在 account.invoice
中创建一个方法来检查用户是否在这个组中,但我不知道如何做。
<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"
您可以通过在按钮定义中指定 groups
来实现。
例如:
<button name="function_name" type="object" string="Confirm" groups="module_name.group_manager"/>
按钮确认仅对group_manager
组中的用户可见。
或
您可以使用has_group
函数来检查用户是否属于组group_manager
。
if self.env.user.has_group('account.group_supplier_inv_check_total'):
// Write your statement
else:
raise UserError(_('Your error message'))
希望对您有所帮助。