1

我正在 OpenERP 7 中为餐厅模块开发看板视图,该视图用于显示客户订购的食物状态。目前的阶段是:

  • 等待队列
  • 进行中
  • 准备上菜
  • 已送达
  • 取消

我创建了 2 个组:

  • 服务员
  • 厨师

当用户的组是服务员时,他/她只有在阶段是'Ready to be Served'时才能修改记录。
对于 Chef,他/她只能在阶段为“Waiting Queue”或“In Progress”时修改记录。


如何为这种情况设置域/访问权限?这是我的看板视图的 XML:

<record model="ir.ui.view" id="inno_master_kitchen_kanban_view">
        <field name="name">Master Kitchen</field>
        <field name="model">inno.master.kitchen</field>
        <field name="arch" type="xml">
            <kanban default_group_by="state" create="false">
                <field name="state"/>
                <field name="customer_id"/>
                <field name="product_id"/>
                <field name="product_qty"/>
                <field name="table_name"/>
                <field name="order_reference"/>
                <templates>
                    <t t-name="kanban-box">
                      <div class="kitchen_kanban oe_kanban_color_0 oe_kanban_card">
                          <div class="oe_kanban_box_header ">
                                <b><field name="table_name"/></b>
                          </div>
                          <div class="oe_kanban_content">
                              <img style="float:left;" t-att-src="kanban_image('product.product', 'image_medium', record.product_id.raw_value)" class="oe_kanban_image" />
                              <div><b><field name="order_reference"/></b></div>
                              <div><field name="product_id"/></div>
                              <div>
                                <field name="product_qty"/>
                                <field name="product_uom"/>
                              </div>
                              <img style="float:right;" t-att-src="kanban_image('res.partner', 'image_small', record.customer_id.raw_value)" width="24" height="24" t-att-title="record.customer_id.value" class="oe_kanban_avatar" />
                          </div>
                          <div class="oe_clear"></div>
                      </div>
                    </t>
                </templates>
            </kanban>
        </field>
    </record>
4

1 回答 1

2

只需简单地授予更新状态字段的权限。

或者

覆盖写入方法并执行正确的代码并引发您无法执行此操作的消息。

def write(self, cr, uid, ids, vals, context=None):
    res = super(crm_lead, self).write(cr, uid, ids, vals, context)
    warning = {}
    if vals.get('stage_id'):
        stage = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context)
        if stage.name == 'Pre Sale':
            #raise osv.except_osv(_('Error!'),_('You cannot confirm a sales order which has no line.'))
            dummy,group_id = self.pool.get('ir.model.data').get_object_reference(cr, 1, 'base', 'group_sale_manager')
            user_groups = self.pool.get('res.users').read(cr, uid, [uid], context)[0]['groups_id']
            if group_id not in user_groups:
                raise osv.except_osv(_('Warning!'), _('You are not a sales manager and so you are not allowed to win this thing'))
    return res
于 2013-09-17T11:29:36.457 回答