コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3209 ビュー

Hello

I follow the tutorial of documentation Odoo, Openacademy,

at the level of workflow, i set the signal attribute of transition egal a name of button,

with the type button egal a workflow

but the workflow doesn't work

help me please

アバター
破棄
最善の回答

create a field in the database


'state': fields.selection([

('draft', 'Draft'),

('verify', 'Verified'),

('cancel', 'Cancelled'),

('done', 'Approved')],

'Status',  readonly=True,),

copy the code in view file

<header>

<button string="Verify" name="action_verify" states="draft,cancel" type="object" class="oe_highlight" />

<button string="Cancel" name="action_cancel" states="draft,verify" type="object" class="oe_highlight" />

<button string="Approve" name="action_approve" states="verify" type="object" class="oe_highlight" />

<field name="state" widget="statusbar" statusbar_visible="draft,verify,done,cancel" class="oe_highlight" type="workflow"/>

</header>


write the functions in .py file


def action_verify(self,cr, uid, ids, context=None):

      if context is None:

          context = {}

      self.write(cr, uid, ids, {'state': 'verify'}, context=context)

      return True


def action_cancel(self,cr, uid, ids, context=None):

      if context is None:

          context = {}

      self.write(cr, uid, ids, {'state': 'cancel'}, context=context)

      return True


def action_approve(self,cr, uid, ids, context=None):

      if context is None:

          context = {}

      self.write(cr, uid, ids, {'state': 'done'}, context=context)

      return True

アバター
破棄