仅由用户组中的用户确认发票

时间:2018-07-03 15:39:54

标签: odoo odoo-8 odoo-9

我有用户组(目前无法正常工作) 并且我希望只有该组中的用户才能确认状态为“草稿”且类型为“ 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"

1 个答案:

答案 0 :(得分:2)

您可以通过在按钮定义中指定groups来实现。

例如:

 <button name="function_name" type="object" string="Confirm" groups="module_name.group_manager"/>

确认按钮仅对group_manager组中的用户可见。

OR

您可以使用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'))

希望它会对您有所帮助。