Sale.order.basic 的workflow中有一段activity不明白作用什么?
-
sale_workflow.xml 中
<!-- Activity -->
<record id="act_router" model="workflow.activity">
<field name="wkf_id" ref="wkf_sale"/>
<field name="name">router</field>
<field name="kind">function</field>
<field name="action">action_wait()</field>
<field name="split_mode">OR</field>
</record>
<record id="act_wait_invoice" model="workflow.activity">
<field name="wkf_id" ref="wkf_sale"/>
<field name="name">wait_invoice</field>
</record>
<record id="act_invoice" model="workflow.activity">
<field name="wkf_id" ref="wkf_sale"/>
<field name="name">invoice</field>
<field name="kind">subflow</field>
<field name="subflow_id" search="[('name','=','account.invoice.basic')]"/>
<field name="action">action_invoice_create()</field>
</record><!-- Transistion -->
<record id="trans_router_wait_invoice" model="workflow.transition">
<field name="act_from" ref="act_router"/>
<field name="act_to" ref="act_wait_invoice"/>
</record>
<record id="trans_wait_invoice_invoice_manual" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_invoice"/>
<field name="signal">manual_invoice</field>
</record>在上述sale_workflow的flow是router->wait_invoice-> invoice, 其中activity:act_wait_invoice 并不做任何动作,Transistion:trans_router_wait_invoice也不需要任何signal触发。
但把flow改为:router->invoice,整个flow就错误了,不能走下去了。请问activity:act_wait_invoice在这边有什么特殊的作用?附:
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception']):
res = False
invoices = {}
invoice_ids = []
for o in self.browse(cr, uid, ids):
lines = []
for line in o.order_line:
if (line.state in states) and not line.invoiced:
lines.append(line.id)
created_lines = self.pool.get('sale.order.line').invoice_line_create(cr, uid, lines)
if created_lines:
invoices.setdefault(o.partner_id.id, []).append((o, created_lines))
if not invoices:
for o in self.browse(cr, uid, ids):
for i in o.invoice_ids:
if i.state == 'draft':
return i.id
picking_obj = self.pool.get('stock.picking')
for val in invoices.values():
if grouped:
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []))
for o, l in val:
self.write(cr, uid, [o.id], {'state': 'progress'})
if o.order_policy == 'picking':
picking_obj.write(cr, uid, map(lambda x: x.id, o.picking_ids), {'invoice_state': 'invoiced'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (o.id, res))
else:
for order, il in val:
res = self._make_invoice(cr, uid, order, il)
invoice_ids.append(res)
self.write(cr, uid, [order.id], {'state': 'progress'})
if order.order_policy == 'picking':
picking_obj.write(cr, uid, map(lambda x: x.id, order.picking_ids), {'invoice_state': 'invoiced'})
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (order.id, res))
return resdef action_wait(self, cr, uid, ids, *args): event_p = self.pool.get('res.partner.event.type').check(cr, uid, 'sale_open') event_obj = self.pool.get('res.partner.event') for o in self.browse(cr, uid, ids): if event_p: event_obj.create(cr, uid, {'name': 'Sale Order: '+ o.name, 'partner_id': o.partner_id.id, 'date': time.strftime('%Y-%m-%d %H:%M:%S'), 'user_id': (o.user_id and o.user_id.id) or uid, 'partner_type': 'customer', 'probability': 1.0, 'planned_revenue': o.amount_untaxed}) if (o.order_policy == 'manual'): self.write(cr, uid, [o.id], {'state': 'manual'}) else: self.write(cr, uid, [o.id], {'state': 'progress'}) self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line])
-
这是利用openerp的打印工作流插件打印的工作流图表。你仔细看看这张图,看看自己是否就能理解了。
[attach]523[/attach]