加vx: alangwansui
alangwansui
- 
 电商系统需要帮忙开发Odoo
- 
 部分发货, 自动发票错误6.03 
 订单设置:
 装箱方式:部分交货
 运送方式:来自装箱单的发票
 开票一句:已运数量
 —————错误描述
 改订单出库时,直接根据发货单生成发票,部分发货时候,生成的发票数量是未处理数量,而不是理应的已处理完数量
 ---------原因
 生成发票的向导,使用的原来装箱单的id,造成发票数据错误
 —————解决方法, 新的装箱单传 发票生成动作
 file:addons/stock/wizard/stock_partial_picking
 
 - rpick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
 - return {'type': 'ir.actions.act_window_close',}
 
 + res=pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context)
 + return {'type': 'ir.actions.act_window_close','res_do_partial':res}
 file:addons\stock_invoice_directly\wizard\stock_invoice.py
 + active_id=context.get('active_ids')[0]
 + new_pick_id=result['res_do_partial'][active_id]['delivered_picking']
 + if new_pick_id: context['active_ids']=[new_pick_id]
- 
 关于一个生产单位生成多个工票现有一个需要一张生产单建了多个工票,要求每一个工票指定负责人安工票的次序进行审核,第一道工票审核了第二道工票才可以审核,不可越级审核应该怎么实现呢 
 --------------------
 工票有序列号啊,你在审批的时候加一个判断,上一个工票完成了,才能审批本工票。
 至于指定负责人,可以用工作中心指定组。
- 
 GTK 客户端按钮不响应Bug:GTK客户段一些按钮,点击后不响应 
 使用开发环境运行发现提示: \openerp-client-6.0.3\bin\widget\model\field
 line 277 if int(internal or False) != (model.value.get(self.name,False) or False):
 ValueError: invalid literal for int() with base 10
 网上搜索了下
 错误的原因为 internal 表示OE字段的readonly值,在一些readonly设置中,readonly=“False” ,对字符串直接使int报错
 解决方法, internal =eval(internal )
 同时,使用 readonly=“1” 的写法,也能避免类似错误
- 
 On2many字段如何隐藏New button或者只允许建立一条记录既然值允许一个,为什么还要用one2many字段呢? 
- 
 监控postgresql操作pg的配置文件中 logging_collector = on 
 然后重启服务
- 
 监控postgresql操作刚开始学习OE,客户端字段对应的数据库中的那个表和字段,不容易找到。 
 解决方法,开启pg的慢日志功能,运行代码,直接监视数据库的操作,
 只要在Form上动动鼠标,就能直接看到是操作了哪个表,哪个字段了。
 程序代码:
 # -- encoding: utf-8 --
 import time
 import re
 import os
 def lastfile (path):
 flage=None
 lastfile=None
 for i in os.listdir(path):
 file=path+i
 if ( os.path.isfile(file) 
 t=os.stat(file).st_ctime
 if (flage):
 if t > flage :
 lastfile=i
 else:
 flage=t
 lastfile=i
 return path + lastfile
 class tail:
 def init (self,file,match):
 self.f=open(file)
 self.match=match
 
 def auto (self,):
 f=self.f
 f.seek(0,2)
 while True :
 line=f.readline()
 if not line:
 time.sleep(0.1)
 continue
 if self.match in line:
 yield line
 
 if name == "main":
 path=r'C:\PostgreSQL\8.4\data\pg_log\'
 lastfile=lastfile(path)
 lines=tail( lastfile, 'update').auto()
 for line in lines:
 obj_re = re.search('statement:.*',line)
 print obj_re.group()
 程序代码:
- 
 深入解析OpenERP的报表开发机制在模块中添加一笔 report 记录 
 <?xml version="1.0"?>
 <terp>
 <data>
 <report id="sale_category_print"
 string="Sales Orders By Categories"
 model="sale.order"
 name="sale_category.print"
 rml="sale_category/report/sale_category_report.rml"
 menu="True"
 auto="False"/>
 </data>
 </terp>
 id :
 string:
 model:报表渲染对象
 rml rml文件路径,路径以本模块的路径开始
 menu True or False 是否在客户端上显示菜单, False 一般用语Wizard 向导是,不需要菜单,
 auto 是否利用缺省方法分析 .RML文件
 name 报表名称 (report_sxw.report_sxw 中的 第一个参数 去掉 ‘report.’)
 ==================
 sxw2rml 文件
 open用的使用的报表渲染文件,.rml。可由 openoffice 的.sxw 文件转换而来
 具体方法
 手动转换方法
 要求文件在同一个目录 openerp_sxw2rml.py , normalized_oo2rml.xsl , name.sxw
 在命令行中 : python openerp_sxw2rml.py order.sxw > order.rml
 
 =================Server PDF Output
 报表分析器
 from report import report_sxw
 import time
 class order(report_sxw.rml_parse):
 def init(self, cr, uid, name, context):
 super(order, self).init(cr, uid, name, context)
 self.localcontext.update({
 ’time’: time,
 })
 report_sxw.report_sxw(’report.sale.order’, ’sale.order’, ’addons/sale/report/order.rml’, parser=order, header=True)
 report_sxw.report_sxw参数分别为
 1:报表名称 ('report.' + ' xml中定义的name' )
 2:报表使用的对象
 3:rml文件路径 addons/
 4:报表提取方法 , 即为 报表分析器的class名 ( 缺省值 parser=order)
 5: 是否增加公司表头
 ###############sxw模板的构造方法
 数据用[[ ]] 中的python代码填充
 可以使用的对象
 object 报表使用的对象
 data 来自 wizard
 time time模块
 user res.user
 方法
 setlang('fr')
 repeatIn(list,varname)
 setTag
 removeParentNode
- 
 在一个模块下定义多个工作流,XML文档中的id要防止重复,如标题,不限于工作流,同个模块下的xml文档id要注意避免重复, 
 重复的id升级或安装时无法及时发现,后期应用排错不容易发现。