转自 :http://blog.sina.com.cn/s/blog_7cb52fa80101ngt8.html
差不多用了2个星期的闲余事件,对于openerp v7.0进行了学习和应用开发。细节总结如下
安装Openoffice
在openoffice中安装openerp report designer插件(openerp 7.0中自带)
OpenErp学习
安装Openoffice
在openoffice中安装openerp report designer插件(openerp 7.0中自带)
1.保存openoffice文件在英文路径下。如果不保存,send to server的时候会没有反应
2. 主要类
osv openerp/osv/osv.py
在文件中 osv = Model
所以osv.osv和osv.Model其实是一样的
osv.Model定义在orm.py中
report_sxw openerp/report/report_sxw.py
logging python库自带
import logging
_logger = logging.getLogger(__name__)
_logger.error("IntegrityError", exc_info=True)
raise osv.except_osv(‘xinquanda_product‘, "_modify_quantity 0"%(record[0][‘quantity‘]))
3.使用openerp report design + openoffice 3.4 + openerp 7.0
在send to server的时候会提示UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte
通过在addons\base_report_designer\base_report_designer.py添加如下三行代码解决
注意默认使用空格缩进。如果增加的代码使用tab缩进会产生unexpected indent错误
import sys
def upload_report(self, cr, uid, report_id, file_sxw, file_type, context=None):
‘‘‘
Untested function
‘‘‘
reload(sys)
sys.setdefaultencoding(‘utf8‘)
4.python 一个 *.py就是一个package
osv.osv就是osv.py文件内的osv对象
5.使用parent_id的时候,使用toolbar产生问题
6.selection里面使用中文内容,需要在前面增加u, 比如u‘供货商‘。否则插入的时候会判断出错
7.使用7.0 form如果没有sheet和group,会不显示filed string
8.使用openerp report designer自动生成rml会使用in作为object名。会导致在7.0下面无法解析。提示 cannot eval ‘xxxx‘之类的。修改名字解决问题
9.Win7的字体安装直接拖进去是不行的。文件名会变成xxx_1 xxx_2这样(用cmd查看)。所以需要使用cmd的xcopy命令进行放置。否则会安装了新字体,但是还是乱码。使用xcopy进去以后,虽然图形界面看不到该字体安装成功了。但是重启oe之后可以解决乱码问题。如果还不行尝试重启一下系统吧。
10.一个工程中存在相同的view_id导致了显示不出来同名menu
11.
View生成的时候调用的初始化函数
def view_init(self, cr, uid, fields_list, context=None):
使用菜单栏的导出功能,导出Field数据时调用
def export_data(self, cr, uid, ids, fields_to_export, context=None):
加载数据时调用,返回一个id list.代表需要加载的数据
def load(self, cr, uid, fields, data, context=None):
"""
Attempts to load the data matrix, and returns a list of ids (or
``False`` if there was an error and no id could be generated) and a
list of messages.
The ids are those of the records created and saved (in database), in
the same order they were extracted from the file. They can be passed
directly to :meth:`~read`
#
# Overload this method if you need a window title which depends on the context
#
def view_header_get(self, cr, user, view_id=None, view_type=‘form‘, context=None):
return False
// 获取名字,返回名字列表
def name_get(self, cr, user, ids, context=None):
// 根据参数进行名字查找.返回 (id, name)的tuple列表.相当于先用search进行搜索,然后再用name_get获取名字列表
def name_search(self, cr, user, name=‘‘, args=None, operator=‘ilike‘, context=None, limit=100):
// 仅仅使用name创建record
def name_create(self, cr, uid, name, context=None):
create
read
返回的是dict组成的list
write
unlink
def search(cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
cr.execute
cr.fetchall
// 定义了
def func_search(self, cr, uid, obj, name field, args, context):
12. pgsql的备份与恢复
pg_dump.exe -f d:/backup/1234.backup -F t -h 127.0.0.1 -p 5432 -U openerp -b Erp
pg_restore.exe -F t -h 127.0.0.1 -p 5432 -U openerp -d tt d:/backup/1234.backup
13.
c:\>for /f "tokens=1-3 delims=- " %1 in ("?te%") do @echo %1%2%3
c:\>for /f "tokens=1-3 delims=.: " %1 in ("%time%") do @echo %1%2%3
http://www.jb51.net/article/30539.htm
14.
report name一样导致了report对应的model调用错误
15.
select ‘cp‘ || right(cast(pow(10, 10) as varchar) || id, 10) as sn, customer_id as name, ‘付款‘ as operation, pay_value as value, date, note from xinquanda_customer_payment
union
select ‘co‘ || right(cast(pow(10, 10) as varchar) || id, 10) as sn, customer_id as name, ‘退货‘ as operation, price_totle as value, date , ‘‘ as note from xinquanda_product_customer_out
union
select ‘ci‘ || right(cast(pow(10, 10) as varchar) || id, 10) as sn, customer_id as name, ‘供货‘ as operation, price_totle as value, date , ‘‘ as note from xinquanda_product_customer_in;
16.有关于view视图的创建与显示
1.在.py的对象创建里面定义_auto = False
2.所有_column都需要有readonly=True的属性
3._sql设定视图创建sql语句或者在__init__(self, cr)函数里面创建具体视图
如果调用视图的action使用了tree type进行显示,可能会在报错
2013-06-19 01:36:24,151 2392