OpenERP 7 - Добавить еще один статус в рабочий процесс account.invoice

Я хотел добавить еще один статус («расширенный») в рабочий процесс 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. Что я не так?

Спасибо, Патрицио.


person PattPatel    schedule 03.07.2014    source источник


Ответы (1)


Я решил делегировать управление блок-схемой другому классу, который наследуется от account.invoice.

class advance_invoice_account_ui(osv.osv) :
    _name = 'account.invoice'
    _inherit = "account.invoice"
person PattPatel    schedule 03.07.2014