2

Here shows my model class which i need to add approval work flow.

class bpl_work_update(osv.osv):
    _name = "bpl.work.update"
    _description = "BPL Work Update"
    _columns = {
        'bpl_company_id':fields.many2one('res.company', 'Company', help='Company'),
        'ref_no': fields.char('Reference No', size=10,),
        'offered_date': fields.date('Offered Date'),
        # below lines are related to work update approve Workflow (i refer hr.holidays model for )
        'state': fields.selection([('draft', 'To Submit'), ('cancel', 'Cancelled'), ('confirm', 'To Approve'), ('refuse', 'Refused'), ('validate1', 'Second Approval'), ('validate', 'Approved')],
            'Status', readonly=True, track_visibility='onchange'),
        'user_id': fields.many2one('hr.employee', 'Add records', invisible=False, readonly=True),
        'manager_id': fields.many2one('hr.employee', 'First Approval', invisible=False, readonly=True),

     }
    _defaults = {
                 'bpl_company_id':_default_company,
                 'offered_date':fields.date.context_today,
                 'state': 'draft',
                 'user_id': lambda obj, cr, uid, context: uid,
                 }

bpl_work_update()

Here shows my view.xml file (i got only lines here which are related to work flow handling )

<header>
    <button string="Approve" name="validate" states="confirm"
        type="workflow" groups="group_checkroll_user" class="oe_highlight" />
    <button string="Validate" name="second_validate" states="validate1"
        type="workflow" groups="group_checkroll_manager" class="oe_highlight" />
    <button string="Refuse" name="refuse" states="confirm,validate,validate1"
        type="workflow" groups="group_checkroll_manager" />
    <button string="Reset to New" name="set_to_draft" states="cancel,refuse"
        type="object" groups="group_checkroll_manager" />
    <field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate"
        statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}' />
</header>

i have no idea for how to implement this approval type work flow. i refer hr.holidays model class but unable to got clear idea about it. please help me to add level to approve my work order request. & please give me a link to refer regarding this type of work flow creating..

now that workflow buttons added to form and shows correctly.but how to handle those.? here is my screen photo

4

1 回答 1

4

你可以参考这个链接: http ://doc.openerp.com/v6.1/developer/07_workflows.html

您需要创建一个新的 workflow.xml 文件,您需要在其中定义要创建的对象的第一个工作流、要在该工作流中显示的不同活动以及活动之间的不同转换。首先你参考上面的链接,理解它,然后去开发它。

您通过在按钮中分配 type="workflow" 做了正确的事情。在这里,按钮的名称用作转换中的信号。这意味着如果您的流程将获得信号,它将在转换中检查它,并且从转换开始,它将触发为该活动创建转换的功能。

于 2013-05-06T07:06:41.417 回答