0

我想在 account.invoice 的工作流程中添加另一个状态(“高级”),介于“开放”和“已支付”之间。所以我继承了模块

class advance_invoice_workflow(osv.osv) :
    _name = 'account.invoice'
    _inherit = "account.invoice"
    _columns = {
    'state': fields.selection([
        ('draft','Draft'),
        ('proforma','Pro-forma'),
        ('proforma2','Pro-forma'),
        ('open','Open'),
        ('advanced','Advanced'),
        ('paid','Paid'),
        ('paid_advanced','Paid advanced'),
        ('cancel','Cancelled'),
        ],'Status', select=True, readonly=True, track_visibility='onchange',
        help='* The \'Draft\' status is used when a user is encoding a new and unconfirmed Invoice. \
            \n* The \'Pro-forma\' when invoice is in Pro-forma status,invoice does not have an invoice number. \
            \n* The \'Open\' status is used when user create invoice,a invoice number is generated.Its in open status till user does not pay invoice. \
            \n* The \'Paid\' status is set automatically when the invoice is paid. Its related journal entries may or may not be reconciled. \
            \n* The \'Cancelled\' status is used when user cancel invoice. \
        '),
    }

并通过在 XML 文件中声明状态

    <record id="act_advanced" model="workflow.activity">
        <field name="wkf_id" ref="account.wkf" />
        <field name="name">advanced</field>
        <field name="kind">function</field>
        <field name="action">set_advanced()</field>
    </record>

所以我有两个过渡:

  • 第一个从开放到高级,

    <record id="t2" model="workflow.transition">
        <field name="act_from" ref="account.act_open" />
        <field name="act_to" ref="act_advanced" />
        <field name="trigger_model">account.move.line</field>
        <field name="trigger_expr_id">move_line_id_payment_get()</field>
        <field name="condition">test_advanced()</field>
        <field name="signal">button_confirm_advance</field>
    </record>
    
  • 第二个从高级到付费

    <record id="t1" model="workflow.transition">
        <field name="act_from" ref="act_advanced"/>
        <field name="act_to" ref="account.act_paid"/>
        <field name="trigger_model">account.move.line</field>
        <field name="trigger_expr_id">move_line_id_payment_get()</field>
        <field name="condition">test_paid()</field>
    </record>
    

从一个不从 account.invoice 继承但引用它的外部模块,我想将信号发送到工作流以从“act_open”移动到“act_advanced”。所以我添加了一个带有 name="button_confirm_advance" 的按钮来绑定这个动作:

def button_confirm_advance(self,cr,uid,ids,context=None):
    context = context or {}
    for invoice in self.browse(cr,uid,ids,context=context):
        wf_service = netsvc.LocalService("workflow")
        self.write(cr, uid, [invoice.id],{})
        wf_service.trg_validate(uid,'account.invoice',invoice.id,'button_confirm_advance',cr)   
    return {'type': 'ir.actions.act_window_close'}

所有变量都是正确的,但 trg_validate 返回 False。我错了什么?

谢谢,帕特里齐奥

4

1 回答 1

0

我解决了将流程图管理委托给另一个继承自 account.invoice 的类

class advance_invoice_account_ui(osv.osv) :
    _name = 'account.invoice'
    _inherit = "account.invoice"
于 2014-07-03T20:11:36.207 回答