修改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] -
sale.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)]}), -
[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]恩,的确是这个问题
-
顺便找了找 5.0.7 orm.py 中, 关于 selection 类型字段的 字段长度处理部分的代码.
[code] if isinstance(f.selection, list) and isinstance(f.selection[0][0], (str, unicode)): f_size = reduce(lambda x, y: max(x, len(y[0])), f.selection, f.size or 16) elif isinstance(f.selection, list) and isinstance(f.selection[0][0], int):
f_size = -1
else:
f_size = (hasattr(f, 'size') and f.size) or 16if f_size == -1:
f_type = ('int4', 'INTEGER')
else:
f_type = ('varchar', 'VARCHAR(%d)' % f_size)[/code]