期待第六章
jimmy_zjw
-
OpenERP应用和开发基础(第二版)开班了 -
Sale.order.basic 的workflow中有一段activity不明白作用什么?这个很难解释?
-
Sale.order.basic的workflow的activity中添加server action后发生:ImportError[size=99px]我在sale.order.basic的workflow的activity:act_cus_confirm中加入了一个server action.出现错误:ImportError: No module named text, 不知是什么原因[/size]
Traceback (most recent call last):
File "netsvc.pyo", line 244, in dispatch
File "netsvc.pyo", line 73, in call
File "serviceweb_services.pyo", line 577, in exec_workflow
File "osvosv.pyo", line 59, in wrapper
File "osvosv.pyo", line 136, in exec_workflow
File "osvosv.pyo", line 129, in exec_workflow_cr
File "workflowwkf_service.pyo", line 81, in trg_validate
File "workflowinstance.pyo", line 50, in validate
File "workflowworkitem.pyo", line 62, in process
File "workflowworkitem.pyo", line 175, in _split_test
File "workflowworkitem.pyo", line 183, in join_test
File "workflowworkitem.pyo", line 42, in create
File "workflowworkitem.pyo", line 54, in process
File "workflowworkitem.pyo", line 110, in execute
File "workflowwkf_expr.pyo", line 64, in execute_action
File "C:Program FilesOpenERP AllInOneServeraddonsbaseirir_actions.py", line 552, in run
File "toolsmisc.pyo", line 310, in email_send
File "email__init.pyo", line 79, in getattr
ImportError: No module named text -
Sale.order.basic 的workflow中有一段activity不明白作用什么?谁来解一下我这个节
-
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 WEB端源码框架分析(逐步更新中...)很抢手的文章
-
Sale order 的workflow改过之后,不能自动产生采购单我觉得是跟process有关系的问题,是从一个flow转到另一个flow的
-
Sale order 的workflow改过之后,不能自动产生采购单我在sale order的demo下做的时候,销售的Supply method=buy的product,workflow从state=draft -> state=manual系统自动会产生采购单的,可是我改了sale orderd的workflow过后,仍旧调用原来的function:action_wait(),但采购单不能自动生成了
demo的workflow:
<record id="act_draft" model="workflow.activity">
<field name="wkf_id" ref="wkf_sale"/>
<field name="flow_start">True</field>
<field name="name">draft</field>
</record>
<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="trans_draft_router" model="workflow.transition">
<field name="act_from" ref="act_draft"/>
<field name="act_to" ref="act_router"/>
<field name="signal">order_confirm</field>
</record>
改过之后的workflow:
<record id="act_bmapprove" model="workflow.activity">
<field name="wkf_id" ref="wkf_sale"/>
<field name="name">bm_approve</field>
<field name="kind">function</field>
<field name="action">write({'state':'bm_approved'})</field>
</record>
<record id="act_gmapprove" model="workflow.activity">
<field name="wkf_id" ref="wkf_sale"/>
<field name="name">gm_approve</field>
<field name="action">action_wait()</field>
<field name="split_mode">OR</field>
</record>
<record id="trans_bmapprove_gmapprove" model="workflow.transition">
<field name="act_from" ref="act_bmapprove"/>
<field name="act_to" ref="act_gmapprove"/>
<field name="signal">gm_approve</field>
</record>action_wait的function没有改过:
def 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]) -
修改sale.order.basic的workflow后,approve可以,但refuse无效,不知道为什么找到原因了
<record id="trans_bmapprove_bmrefuse" model="workflow.transition">
<field name="act_from" ref="act_bmapprove"/>
<field name="act_to" ref="act_bmrefuse"/>
<field name="signal">bm_refuse</field>
</record>
其中的act_from 应该是assignGM refuse也是这个原因
-
修改sale.order.basic的workflow后,approve可以,但refuse无效,不知道为什么重新设置了workflow sale.order.basic,draft->customer confrim -> assign -> bm approve -> gm approve 流程正常。可是在BM refuse与GM refuse的时候workflow就无效了,不能refuse。哪位有时间帮忙看下,问题出在哪边?
sale_workflow.xml文件内容如下
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wkf_sale" model="workflow">
<field name="name">sale.order.basic</field>
<field name="osv">sale.order</field>
<field name="on_create">True</field>
</record><!-- Activity --> <record id="act_draft" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="flow_start">True</field> <field name="name">draft</field> </record> <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">write({'state':'cus_confirmed'})</field> </record> <record id="act_assign" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">assigned</field> <field name="kind">function</field> <field name="action">write({'state':'assigned'})</field> </record> <record id="act_bmapprove" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">bm_approve</field> <field name="kind">function</field> <field name="action">write({'state':'bm_approved'})</field> </record> <record id="act_bmrefuse" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="flow_stop">True</field> <field name="name">bm_refuse</field> <field name="kind">function</field> <field name="action">write({'state':'bm_refused'})</field> </record> <record id="act_gmapprove" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">gm_approve</field> <field name="kind">function</field> <field name="action">write({'state':'gm_approved'})</field> </record> <record id="act_gmrefuse" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="flow_stop">True</field> <field name="name">gm_refuse</field> <field name="kind">function</field> <field name="action">write({'state':'gm_refused'})</field> </record> <record id="act_done" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">done</field> <field name="flow_stop">True</field> <field name="kind">function</field> <field name="action">write({'state':'done'})</field> <field name="join_mode">AND</field> </record> <record id="act_cancel" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">cancel</field> <field name="flow_stop">True</field> <field name="kind">stopall</field> <field name="action">action_cancel()</field> </record> <record id="act_cancel2" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">cancel2</field> <field name="flow_stop">True</field> <field name="kind">stopall</field> <field name="action">action_cancel()</field> </record> <record id="act_cancel3" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">cancel3</field> <field name="flow_stop">True</field> <field name="kind">stopall</field> <field name="action">action_cancel()</field> </record> <!-- Transistion --> <record id="trans_draft_router" model="workflow.transition"> <field name="act_from" ref="act_draft"/> <field name="act_to" ref="act_router"/> <field name="signal">order_confirm</field> </record> <record id="trans_draft_cancel" model="workflow.transition"> <field name="act_from" ref="act_draft"/> <field name="act_to" ref="act_cancel"/> <field name="signal">cancel</field> </record> <record id="trans_rounter_assgin" model="workflow.transition">
<field name="act_from" ref="act_router"/>
<field name="act_to" ref="act_assign"/>
<field name="signal">assign</field>
</record><record id="trans_assign_bmapprove" model="workflow.transition">
<field name="act_from" ref="act_assign"/>
<field name="act_to" ref="act_bmapprove"/>
<field name="signal">bm_approve</field>
</record><record id="trans_bmapprove_gmapprove" model="workflow.transition">
<field name="act_from" ref="act_bmapprove"/>
<field name="act_to" ref="act_gmapprove"/>
<field name="signal">gm_approve</field>
</record><record id="trans_bmapprove_bmrefuse" model="workflow.transition">
<field name="act_from" ref="act_bmapprove"/>
<field name="act_to" ref="act_bmrefuse"/>
<field name="signal">bm_refuse</field>
</record><record id="trans_gmapprove_router" model="workflow.transition">
<field name="act_from" ref="act_gmapprove"/>
<field name="act_to" ref="act_router"/>
<field name="signal">gm_refuse</field>
</record><record id="trans_gmapprove_gmrefuse" model="workflow.transition">
<field name="act_from" ref="act_gmapprove"/>
<field name="act_to" ref="act_gmrefuse"/>
<field name="signal">gm_refuse</field>
</record></data>
</openerp>
sale.py 文件中state字段的field selection如下:
'state': fields.selection([
('draft', 'Quotation'),('cus_confirmed','Customer Confirmed'), ('assigned','Assigned'), ('bm_approved','BM Approved'), ('gm_refused','GM Refused'), ('gm_approved','GM Approved'), ('done', 'Done'), ('cancel', 'Cancelled') ], 'Order State', readonly=True, help="Gives the state of the quotation or sale order. The exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the packing list process (Shipping Exception). The 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Date Ordered'.", select=True), 'date_order': fields.date('Date Ordered', required=True, readonly=True, states={'draft': [('readonly', False)]}),
sale_view.xml 中button设置为:
<group col="13" colspan="4">
<field name="state" select="2"/>
<button name="order_confirm" states="draft" string="Customer Confirm" icon="gtk-execute"/>
<button name="cancel" states="draft" string="Cancel Order" icon="gtk-cancel"/><button name="assign" states="cus_confirmed" string="Assign"/> <button name="bm_approve" states="assigned" string="BM Approve"/> <button name="bm_refuse" states="assigned" string="BM Refuse"/> <button name="gm_approve" states="bm_approved" string="GM Approve"/> <button name="gm_refuse" states="bm_approved" string="GM Refuse"/>
</group>
详细文件
[attach]460[/attach]
-
修改sale order的workflow后发生错误 DataError[quote]原帖由 [i]wjfonhand[/i] 于 2010-3-24 11:07 发表 www.shine-it.net/redirect.php?goto=findpost&pid=4508&ptid=961
我怀疑orm在根据model定义table的时候,field的长度按selection的最大长度
shipping_except这个最长,16位
你py文件里新加个20位的,table里field没扩大,就出错了
你pgadmin去看看table sale.order里status的长度 ... [/quote]恩,的确是这个问题
-
修改sale order的workflow后发生错误 DataErrorsale.py
'state': fields.selection([
('draft', 'Quotation'),
('waiting_date', 'Waiting Schedule'),
('manual', 'Manual In Progress'),
('progress', 'In Progress'),
('shipping_except', 'Shipping Exception'),
('invoice_except', 'Invoice Exception'),
('done', 'Done'),
('cancel', 'Cancelled')
], 'Order State', readonly=True, select=True),
'date_order': fields.date('Date Ordered', required=True, readonly=True, states={'draft': [('readonly', False)]}),改为
'state': fields.selection([
('draft', 'Quotation'),
('customer_confirmed','Customer Confirmed'),
('assigned','Assigned'),
('bm_approve','BM Approved'),
('gm_refuse','GM Refused'),
('done', 'Done'),
('cancel', 'Cancelled')
], 'Order State', readonly=True,
'date_order': fields.date('Date Ordered', required=True, readonly=True, states={'draft': [('readonly', False)]}), -
修改sale order的workflow后发生错误 DataError修改sale order的workflow后发生错误
Traceback (most recent call last):
File "netsvc.pyo", line 244, in dispatch
File "netsvc.pyo", line 73, in call
File "serviceweb_services.pyo", line 577, in exec_workflow
File "osvosv.pyo", line 59, in wrapper
File "osvosv.pyo", line 136, in exec_workflow
File "osvosv.pyo", line 129, in exec_workflow_cr
File "workflowwkf_service.pyo", line 81, in trg_validate
File "workflowinstance.pyo", line 50, in validate
File "workflowworkitem.pyo", line 62, in process
File "workflowworkitem.pyo", line 175, in _split_test
File "workflowworkitem.pyo", line 183, in _join_test
File "workflowworkitem.pyo", line 42, in create
File "workflowworkitem.pyo", line 54, in process
File "workflowworkitem.pyo", line 108, in _execute
File "workflowwkf_expr.pyo", line 68, in execute
File "workflowwkf_expr.pyo", line 58, in _eval_expr
File "<string>", line 1, in <module>
File "osvorm.pyo", line 168, in <lambda>
File "C:Program FilesOpenERP AllInOneServeraddonssalesale.py", line 344, in write
File "osvorm.pyo", line 2458, in write
File "sql_db.pyo", line 76, in wrapper
File "sql_db.pyo", line 120, in execute
DataError: value too long for type character varying(16)所修改的文件如下:
[attach]459[/attach] -
OpenERP应用和开发基础(第二版)开班了老肖写作能力不是一般的
-
新手请进(openERP应用和开发基础)第六章有点货的哦
-
新手请进(openERP应用和开发基础)感动ing啊:)
-
新手请进(openERP应用和开发基础)热顶热顶热顶热顶