Qweb 报表代码如下:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="template_report_xhd">
<t t-call="report.html_container">
<t t-set="tablelines" t-value="8"/>
<div class="page">
<style>
table.xhd_head {
font-family: "SimSun";
font-size: 24px;
color:#000000;
border-width: 0px;
border-color: #FFFFFF;
width:100%;
}
table.xhd_head th {
border-width: 0px;
}
table.xhd_head td {
border-width: 0px;
}
</style>
<div align="center">
<h1>
<t t-esc="res_company.name"/>
</h1>
<h2>销 货 单</h2>
</div>
<table class="xhd_head">
<tr>
<td>客 户:</td>
<td colspan="3">
<t t-esc="docs[0].customer_id.long_name"/>
</td>
<td>送货单位:</td>
<td></td>
</tr>
<tr>
<td>送货地址:</td>
<td colspan="3">
<t t-esc="docs[0].customer_id.address"/>
</td>
<td>卡车号码:</td>
<td></td>
</tr>
<tr>
<td width="14%">联系电话:</td>
<td width="26%">
<t t-esc="docs[0].customer_id.tel"/>
</td>
<td width="14%">联系人:</td>
<td width="16%">
<t t-esc="docs[0].customer_id.contactor"/>
</td>
<td width="14%">出货日期:</td>
<td width="16%">
<t t-esc="docs[0].date"/>
</td>
</tr>
</table>
转换成PDF文件后,能显示中文,但PDF中的字体为 ????四个问号。由于是用针打打印,打印出来的字不清晰,好象分辨率不够。
通过PDF修改软件,把中文字体改成“SimSun"打印又变正常。
请问如何让WHtmltopdf 直接输出有是”SimSun“的中文????
请高手指教!!!!
t11t11
-
Qweb-pdf 报表中文字体的问题 -
Qweb-html 纸张设置的问题(1) 销货单纸张设置
<record id="paperformat_xhd" model="report.paperformat">
<field name="name">销货单</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">140</field>
<field name="page_width">240</field>
<field name="orientation">Portrait</field>
<field name="margin_top">15</field>
<field name="margin_bottom">0</field>
<field name="margin_left">35</field>
<field name="margin_right">35</field>
<field name="header_line" eval="False" />
<field name="header_spacing">0</field>
<field name="dpi">90</field>
</record>
(2) 销货单报表和菜单设置
<report
id="action_report_xhd"
string="销货单"
model="hm.outline"
report_type="qweb-html"
name="hm_stock.report_xhd"
file="hm_stock.report_xhd"
/>
(3) 报表与纸张关联
<record id="action_report_xhd" model="ir.actions.report.xml">
<field name="paperformat_id" ref="hm_stock.paperformat_xhd"/>
</record>
现在的问题是,report_type="qweb-pdf", 自定义纸张有用。
如果report_type="qweb-html", 在弹出的报表窗口中打印报表,纸张大小都是A4的
不想用pdf格式,因为pdf格式,要先下载再打开再打印,html直接在页面显示然后单击打印就可以 -
交流OE销售对账单报表的开发 (AEROO)附部分代码, 未完持续更新中.........Parser 文件:
初始化, 函数声明等
class Parser(report_sxw.rml_parse):
def init(self, cr, uid, name, context=None):
super(Parser, self).init(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'date': date,
'lines': self.lines,
'get_intial_balance': self._get_intial_balance,
'get_date_start': self._get_date_start,
'get_date_end': self._get_date_end,
})
设置报表环境:
def set_context(self, objects, data, ids, report_type=None):
self.datas = data['form']
self.query = " "
self.query_term = ""
self.query_date_start = ""
self.date_start = ""
self.date_end = ""
# 公司ID
user = self.pool.get('res.users').browse(self.cr, self.uid, self.uid, context=None)
self.query += "AND aml.company_id = " + str(user.company_id.id) + " "
# 日否己登账
if data['form']['target_move'] and data['form']['target_move'] == 'posted':
self.query += " AND am.state = '" + str(data['form']['target_move']) + "' "
# 科目ID
# self.query += " AND aml.journal_id = " + str(data['form']['journal_id'][0])
# 日期与时间
# 按时间生成报表.
if data['form']['filter'] and data['form']['filter'] == "filter_date":
self.query_term += " AND aml.date >= '" + str(data['form']['date_from']) + "' "
self.query_term += " AND aml.date <= '" + str(data['form']['date_to']) + "' "
self.query_date_start = " AND aml.date < '" + str(data['form']['date_from']) + "'"
self.date_start = str(data['form']['date_from'])
self.date_end = str(data['form']['date_to'])
elif data['form']['filter'] == "filter_period":
# 按会计期间生成报表.
self.cr.execute(
"select id, date_start, date_stop from account_period where id in %s" <br /> " AND company_id =%s",
((data['form']['period_from'][0], data['form']['period_to'][0]), user.company_id.id))
period_ids = self.cr.dictfetchall()
if period_ids and period_ids[0]['date_start'] and period_ids[1]['date_stop']:
self.query_term += " AND aml.date >= '" + period_ids[0]['date_start'] + "'"
self.query_term += " AND aml.date <= '" + period_ids[1]['date_stop'] + "'"
self.query_date_start = " AND aml.date < '" + str(period_ids[0]['date_start']) + "'"
self.date_start = str(period_ids[0]['date_start'])
self.date_end = str(period_ids[1]['date_stop'])
# 以前两种汇总方式的都必须找到开始时间点, 和结束时间点
domain = []
obj_partner = self.pool.get('res.partner')
if data['form']['scope'] == "selected" and len(ids) > 0:
domain = [('id', 'in', tuple(ids))]
self.partner_ids = obj_partner.search(self.cr, self.uid, domain, context=None)
objects = []
oids = []
for o in obj_partner.browse(self.cr, self.uid, self.partner_ids):
# 去除非公司的业务伙伴
if o.customer and o.is_company:
objects.append(o)
oids.append(o.id)
self.partner_ids = oids
return super(Parser, self).set_context(objects, data, self.partner_ids, report_type) -
交流OE销售对账单报表的开发 (AEROO)附部分代码, 未完持续更新中.........AEROO 报表定义:
<record id="report_cs2k_res_partner_partner_ledger" model="ir.actions.report.xml">
<field name="name">客户对账单</field>
<field name="type">ir.actions.report.xml</field>
<field name="model">res.partner</field>
<field name="report_name">report_cs2k_res_partner_partner_ledger</field>
<field name="report_type">aeroo</field>
<field name="in_format">oo-ods</field>
<field name="out_format" ref="report_aeroo_ooo.report_mimetypes_xls_odt"/>
<field name="parser_loc">cs2k/report/sales_statement_parser.py</field>
<field name="report_rml">cs2k/report/sales_statement_report.ods</field>
<field name="parser_state">loc</field>
<field name="tml_source">file</field>
</record> -
交流OE销售对账单报表的开发 (AEROO)附部分代码, 未完持续更新中.........网上好慢, 附件真难传啊.
def check_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
data = {}
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'] = self.read(cr, uid, ids,
['scope', 'target_move', 'page_split', 'filter',
'date_from', 'date_to', 'period_from', 'period_to'], context=context)[0]
if data['form']['scope'] == "selected" and data['ids'] == []:
raise osv.except_osv(_('Error!'), _(u'没有选择业务伙伴可用来对账汇总!!!\n请重新选择!!!'))
if data['form']['page_split']:
return {
'type': 'ir.actions.report.xml',
'report_name': 'report_cs2k_res_partner_partner_ledger_paged',
'datas': data,
}
else:
return {
'type': 'ir.actions.report.xml',
'report_name': 'report_cs2k_res_partner_partner_ledger',
'datas': data,
} -
交流OE销售对账单报表的开发 (AEROO)附部分代码, 未完持续更新中.........本报表参照 account\report\account_partner_ledger.py 简化制作, 不足之处,请大牛们指教.
两个菜单:
一, 从菜单中启动报表 (全部的业务伙伴), 菜单定义如下:
<record id="action_form_cs2k_partner_ledger_all" model="ir.actions.act_window">
<field name="name">客户对账单-Aeroo</field>
<field name="res_model">cs2k.partner.ledger</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_form_cs2k_partner_ledger"/>
<field name="context">{'scope':'all'}</field>
<field name="target">new</field>
</record>
<menuitem icon="STOCK_PRINT"
name="客户对账单-Aeroo"
action="action_form_cs2k_partner_ledger_all"
groups="group_sale_pub"
id="menu_cs2k_partner_ledger"
parent="menu_sale_cs2k"/>
(二) 从打印按中启动报表(当前的业务伙伴或选中的业务伙伴)
<record id="action_form_cs2k_partner_ledger_selected" model="ir.actions.act_window">
<field name="name">客户对账单-Aeroo</field>
<field name="res_model">cs2k.partner.ledger</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_form_cs2k_partner_ledger"/>
<field name="context">{'scope':'selected'}</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="ir_values_account_partner_ledger">
<field name="key2" eval="'client_print_multi'"/>
<field name="model" eval="'res.partner'"/>
<field name="name">客户对账单-Aeroo</field>
<field name="value" eval="'ir.actions.act_window,%d'%action_form_cs2k_partner_ledger_selected"/>
</record> -
One2many字段domain实现, 并使用filter视图中的变量[size=14pt]新类
class my_model(osv.osv):
_name = "my.model"
_description = 'abc'
_columns = {
'product_id': fields.many2one('product.product', u'产品'),
'move_in': fields.many2one('stock.move', u'入库记录'),
'location_id': fields.many2one('stock.location', u'在库库位'),
.........................
}
my_model()
产品类
class product_product(osv.Model):
_inherit = 'product.product'
_columns = {
'my_model': fields.one2many('my.model', 'product_id', u'my_model', domain=['&',('move_in','!=',False),('move_in.state','=','done')]),
}
product_product()
[b]本站有贴子说有one2many的domain只能在py文件中实现, 不能在xml文件中实现.[/b]
[b]视图文件不变, 现在再修改py文件如下:[/b]
class product_product(osv.Model):
_inherit = 'product.product'
_columns = {
'my_field': fields.function(_get_juan, method=True, string = u'分卷', type='one2many',relation='my_model'),
}
product_product()
def _get_juan(self, cr, uid, ids, name, arg, context=None):
res = {}
jids = []
obj = self.pool.get('my_model')
for product in self.browse(cr,uid,ids):
if context.get('location', False):
location_ids = [context['location']]
else:
location_ids = ........
args = [('product_id','=',product.id)]
args += [('location_id','in',location_ids)]
res[product.id] = obj.search(cr,uid,args)
return res[/size] -
Python2.7库的版本一直用green openerp,最近在新电脑上用了安装版的python 2.7, 又从网上下载各种包. 发现在安装的还没有绿色版的好用, 经常报各种错误. 想想是不是python包升级后与openerp不兼容或bug. 所以花了些时间把Green Openerp包和我的安装包的版本全部列了出来, 对比了一下. 发现区别还是很大.
看来, 追求最新版不一定是个好事.
库名- 绿色版- 安装版
Babel- 0.9.6- 0.9.6
distribute- 0.6.35-
Docutils- 0.1- 0.11
feedparser- 5.1.3-
gdata- 2.0.17- 2.0.18
geshi- 0.6.1- 0.6.1
Jinja2- 2.6- 2.7.1
libxml2-python-2.7.8-
lxml- 3.1.0- 3.2.4
Mako- 0.7.3- 0.9.1
markupsafe- - 0.18
mock- 1.0.1- 1.0.1
PIL- 1.1.7-
pip- 1.3.1-
psutil- 0.6.1-
psycpg2- 2.4.6- 2.5.1
PyChart- 1.39- 1.39
pycurl- 7.19.0-
pydot- 1.0.28-
pyparsing- 1.5.7-
python-dateutil-1.5- 2.2
python-ldap- 2.4.9-
python-openid- 2.2.5- 2.2.5
pytz- 2012j- 2012j
pywebdav- 0.9.8-
pywin32- 218- 218.4
PyXML- 0.8.4-
PyYAML- 3.10- 3.10
reportlab- 2.6- 2.7
setuptools- 0.6c11- 2.0.3dev
simplejson- 3.1.0- 3.3.1
Unidecode- 0.04.12-
unittest2- 0.5.1- 0.5.1
vatnumber- 1.0-
vobject- 0.8.1c-
wekzeug- 0.8.3- 0.9.4
xlwt- 0.7.4-
zsi- 2.0-rc3-
aeroolib- - 1.0.0.rc4
six- - 1.4.1 -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)CUP 是lunix系统下的打印服务, 我也没有安装成功过.
-
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)http://www.alistek.com/en/products-catalogue/4-product_single/222-aeroo-reports-for-openerp-version-7x.html
<pay with a tweet>
点击一下,帮开发做做广告就可以下载了。 可惜tweet不能直接访问,这个自己想办法吧。 -
为什么在客户付款单中不能过滤客户系统有一个记录规则 “业务伙伴 res.partner company"
['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)]
在客服组导入这个规格,没有res.partner访问限制。但不能过滤partner.
而自建的记录规则 "业务伙伴 res_partner: read access on partners of sales group"
['|','&','|',('section_id','=',user.default_section_id.id),('section_id','=',False),('customer','=',True),('id','=',user.partner_id.id)]
引入这条规则,还是出现错误:
2013-08-04 09:00:10,977 6412 WARNING ZJGCS openerp.osv.orm: Access Denied by record rules for operation: read, uid: 62, model: res.partner
2013-08-04 09:00:10,979 6412 ERROR ZJGCS openerp.netsvc: Access Denied
The requested operation cannot be completed due to security restrictions. Please contact your system administrator.
(Document type: Partner, Operation: read)
Traceback (most recent call last):
File "D:\OpenERP7\openerp\openerp\netsvc.py", line 292, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "D:\OpenERP7\openerp\openerp\service\web_services.py", line 626, in dispatch
res = fn(db, uid, *params)
File "D:\OpenERP7\openerp\openerp\osv\osv.py", line 188, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "D:\OpenERP7\openerp\openerp\osv\osv.py", line 144, in wrapper
raise except_osv(inst.name, inst.value)
except_osv: (u'Access Denied', u'The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: Partner, Operation: read)')
这是什么问题,谁帮我解决一下。 -
为什么在客户付款单中不能过滤客户非常感谢digitalsatori 在上个贴子中为我排查错误,现在又发现一个新问题
因为我们公司客服工作,包括对客户的付款在Customer Payment初始录入,并由财务审核并记账。
而一个客服服务几个客户,因此新建一个客服组,也增加规则如下:
['|','&','|',('section_id','=',user.default_section_id.id),('section_id','=',False),('customer','=',True),('id','=',user.partner_id.id)]
但是销售-销售-客户工作正常,而在会计-客户-customer payment中出错了。提示如下:
openerp.osv.orm: Access Denied by record rules for operation: read, uid: 62, model: res.partner
同样是对客户进行过滤,为什么customer payment出现错误提示: (Document type: Partner, Operation: read)
盼复!! -
产生反复调用,这个DOMAIN怎么设置???成功了,非常感谢!!!!!!!!!!!!!
-
产生反复调用,这个DOMAIN怎么设置???新建公司“客服”角色,针对“销售”-“销售”-“客户”列表视图的DOMAIN过滤设置如下:
['|','&','|',('section_id','=',user.default_section_id.id),('section_id','=',False),('customer','=',True),('id','=',user.partner_id)]
1. ('section_id','=',user.default_section_id.id)或('section_id','=',False) 取出partner的销售组ID与客服的销售组ID 相同的所有parnter, 或者是没有设置销售组的partners;
2. 当关闭搜索栏的“客户”按钮时,会出现供应商(如果供应商没有设置销售团队)和ERP登录用户,所以加一条('customer','=',True),只有客户出现才能出客户视图;
3. 问题又出现了,由于所有ERP登录用户(包括自己)都过滤掉了,因此不能在“首选项”中修改自己的时区等,再加一条('id','=',user.partner_id),这样自己不会被过虑掉了。
4. 问题是加了第三条,系统认为是迭代出错(从partner表到user表再到partner表 NotImplementedError: Iteration is not allowed on browse_record(res.partner, 63) 。
请问哪位高手有解决的方法!!!!!! -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)Extra Functions (附加的功能)
There are set of embedded functions defined for user convenience. These represent generic functionality that is commonly used for creating reports. Listing of these functions is not to be considered as complete, we may introduce more functions over time. Do not hesitate to ask, if you want some function to appear among them. All requests will be treated as a wish-list, and if the requested function will appear as commonly required item we will gladly include it in the embedded function list. You may place your motivated request on launchpad project bugs/blueprints sections. You can use our dedicated forum, if you are not familiar with launchpad. Reports with attached source code will receive somehow better attention, so may be implemented more sooner.
You may vote for functionality by donating funds to this project and naming the functionality you would like to be implemented.
For better reference we decided to split listing of functions by domains.
Language related functions
setLang - sets default language on template;
gettext - gets translation for a given text;
_ - same as gettext;
getLang - gets current effective language of template;
currency_to_text - converts floating point currency to it's written form;
Mathematical functions
sum_field - returns sum of named field from all objects in a list;
sumif - returns sum of named field from conditionally selected objects in a list;
Parameters:
list_of_objects – list of objects that have field to sum;
field_name – name of the numeric field to sum, expressed as string;
condition – condition on which objects should be selected, expressed as string;
Return Values:
-
Description
Returns sum of named field from conditionally selected objects in a list.
Statistical functions
average - returns the average (arithmetic mean) of fields from all objects in a list;
count - returns total count of objects in a list;
count_blank - returns total count of objects in a list, where named field is empty;
countif - Returns count of objects from a list, where fields meet condition;
large - returns k-th largest numeric value in a list of objects;
max_field - returns largest numeric value in a list of objects;
min_field - returns smallest numeric value in a list of objects;
small - returns k-th smallest numeric value in a list of objects;
Time related functions
dec_to_time - converts time to hh:min representation;
time - time access and conversions;
Barcode related functions
barcode - converts code to barcode image;
Helper functions
asarray - returns named field from all objects as a list;
asimage - converts binary data to image;
bool_as_icon - translates boolean value to text string;
browse - returns list of objects;
chunks - splits list of objects into chunks;
debugit - helps debugging templates;
epl2_gw - insert EPL v2 'gw' command (use on Zebra & compatible printers);
field_accuracy - returns accuracy for the OpenERP object's field;
field_size - returns maximum size for named field;
get_attachments - returns attachment(s) from an object;
get_label - returns human readable name for the field;
get_log - ;
get_name - returns string representation for object;
get_selection_item - returns human readable name for selection field's code;
html_embed_image - embeds image on html templates
html_escape - escapes HTML unsafe characters (New in v1.1.)
http_builduri - builds string of URI attributes from dictionary(ies) (New in v1.1.)
http_prettyuri - converts string URI safe format (New in v1.1.)
include_document - ;
insert-subreport - inserts Open ERP sub reports;
itemize - Appends the given array with number of usefull attributes (New in v1.1.)
safe - tries to safely evaluate expression;
search - do a search returning list of OpenERP objects;
search_ids - do a search returning only list of OpenERP object ids; -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)Loop Sections (循环篇)
Now when we want to report on several objects, we have create loop for each object in the list. For this task paired “for” directive is being used. Paired – means, one container for opening, another container for closing.
Remember example from Conditional Sections chapter. We will modify it to report all the customer names, from all selected partners.
<for each="one_partner in objects">
<if test="one_partner.customer">
<one_partner.name>
</if>
</for>
Please notice paired for directive with embedded conditional, if directive inside. Variable one_partner has been introduced, to hold temporary reference to each partner in objects list. -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)Conditional Sections (条件选择篇)
Most generic directive for using conditional sections is “if”. For marking end of the conditional section use “/if”. Remember, this is paired directive, consisting of two containers and section between them.
If we want to print conditional text if the the partner is Customer, the directive would look:
<if test="objects[0].customer">
This text is being printed when partner is a customer.
</if>
Here we can see paired directive, so you have to place two separate containers, one for the opening part of directive (if test=”objects[0].customer”), the other for closing part (/if). All that is between them will be placed on final document, when check-box named “Customer” on Partner object is marked.
Similar to if-elif-else conditional section like it is in most programming languages, there is slightly complicated structure used instead. Consisting of “choose” paired directive, at least one “when” and one “otherwise” paired directives, it is possible to create switch like constructions.
Following example shows how to create such conditional section:
<choose>
<when test="objects[0].customer">
This text is being printed when partner is a customer.
</when>
<when test="objects[0].supplier">
This text is being printed when partner is a supplier.
</when>
<otherwise>
This text is being printed in all the other occasions.
</otherwise>
</choose> -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)下面的就没有翻译了,报歉。
Retrieving Data (取出数据)
When it is more or less clear, how to place a container, you would want to know, how to retrieve real data from objects. As it is always better to learn by example, we will use Partners model as referenced data in examples. This data model is almost always present in any database, and is populated with data, when demo setup has been created.
When creating report on any model, it is common to use default parser. Default parser provides several predefined variables:
objects – hold the data you create report on. It is a list of objects, so if you want to reference on all of the data selected, you have to place a loop on this variable;
o – if you know that only one object is selected, you may use this variable directly, without creating a loop;
data – data that comes from the wizard;
user – user which requests the report;
time – standard Python library for time manipulations;
company - ;
user - ;
report_xml - ;
user_lang - ;
logo - ;
For example, if you want to report name of the first partner you have selected, code would look:
<objects[0].name>
Here we reference predefined variable objects, use list index “0” (for information reference Python documentation), then take data from name field. Those who are not familiar with OpenObject ORM, for more information, take a look at “Administration/Customization/Database Structure/Objects” OpenERP objects and their relation listing.
You can reach any data from OpenObject ORM, just drill down step by step to the data you require.
For example, let's place currency of the company. The directive would look:
<user.company_id.currency_id.code>
Here we reference predefined variable user, take field company_id, which holds reference to the company, then currency_id for the default currency. Finally take field code which is of type text, so it can be directly reported on the template. -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)Defining Template Directives(定义模板指令)
Syntax for defining template directives is a combination of Genshi template language and Python code. Still, even if you are not familiar with any of them, it is easy to create simple templates. Syntax of directives is all the same in all possible template types (OpenOffice.org Writer - odt, OpenOffice.org Calc – ods).
定义模板指令的语法是Genshi模板语言和Python语言的汇合体。然而,即使你对他们都不熟悉,建立一个简单模板还是非常简单。指令的语法对所有的模板类型(OO Writer, OO Calc)都是相同的。
There are several options, to define template directives. Because of OOo program specificity, not all of them can be used in all template types. Mainly there are three options (you may want to call them containers) to insert directives into template.
有个几种不同定义模板指令的方法,因为OOO规定,所有的他们不能用在相同的模板。主要有3个不同的方法(你可以称他们为容器)将指令插入到模板中。
Text Placeholder fields (文本占位字段)
The most common and widely used option is to use “Text Placeholder fields”. In order to insert this this type of container, you have to text placeholder field from menu “Insert/Fields/Other...”. In “Type” list select “Placeholder”, “Format” list select “Text”. In “Placeholder” field write the template directive. In “Placeholder” field write the directive. Then press “Insert” button – placeholder with specified directive will be placed at the position where the cursor was at the moment.
最常用的方法是”文件占位字段“。为插入这样的窗口,你需选择菜单“插入/字段/其他...", "功能/通配符", "格式/文字”,在“通配符”字段写入“模板指令”,在“通配符”字段写入“指令”。然后按“插入”按钮。
Hyperlink (超链接)
Unfortunately there is no Text Placeholder Field for OOo Calc document. This is why an alternative container has been chosen - “Hyperlink” field. Although you can not use placeholder on spreadsheet document template, all the syntax of directives remains the same. Menu “Insert/Hyperlink...” opens a dialog that enables you to create and edit hyperlinks. Select “Internet” as hyperlink type. In “Target” field write the directive, just like you would do for placeholder. Only difference is, that you have to prepend the directive with text “python://“ (“relatorio://” using legacy report_openoffice module). As directives may be pretty long, you may want to use “Text” field below for shorter representation of field on document – a preview. Armed by these two types of containers, you are enough to place any directive on any template, that is supported by OpenOffice.org templating engine for OpenObject (OpenERP).
不幸的是在OOO Calc文本中没有字符占位符。这就是为什么有“超链接字段”供选择。虽然你不能在电子表格中使用“通配符”,但是所有的指令语法都是相同的。 菜单“插入/超链接",在弹出菜单就允许你创建和修改”超链接“。 选择”国际互联网“作为”超链接“类型,在”目标“字段写入”语法“,就象你在”通配符“所做的一样,唯一不同是你必须在加入前缀”python://" (而“relatorio://” 用在Report_Openoffice模块). 如果“指令”相当的长,你可以使用下面的“文本”字段作为预览来缩短长度。
通过以上2个容器,你就有足够的空间在任意模板中放入任意指令。
Still if you look at both types more carefully, you would notice one major advantage and one disadvantage of hyperlinks over placeholders. Advantage is that hyperlinks may be represented with preview value, which is good for better estimating space required for text. Still it is harder to change the code. If you eventually would click on hyperlink, you would be redirected to hyperlink code as it would be ordinary Internet hyperlink.
与文本点位相比,超链接有一个优点和一个缺点。优点是可以很短的字符显示预览值;缺点是很改变代码。
Input field (输入字段)
To have advantage of preview values and overcome problems of redirection, another type of field, has been chosen - “Input field”. This field can be used on OOo Writer templates. Steps to place this container is similar to placeholder – use menu “Insert/Fields/Other...”. In “Type” list select “Input field”, and in “Reference” field write directive, just as you would for placeholder field. The only difference, you have to remember, is that you have to embrace the directive inside “<>”.
能显示预览值并能克服重定位问题的是,另一种字段——“输入字段”。 这种字段可以在OOO writer中使用。插入该字段的步骤与通配符类似。菜单“输入/字段/其他...”, “功能/输入字段“,在”提示“中输入”指令“。唯一不同的是必须将指令放入<>括号中。
Frame (图文框)
Still one question remains, how to place images on document? For placing images on templates, another method have been chosen – frames. Frames resemble more or less the same parameters as images, they have dimensions and same placement properties.
需要在报表中显示图像时,必须使用”框架“字段
For inserting an image into template, you have to add ordinary OpenOffice.org frame to document and write directive into frame's properties. To place frame on a template you use “Insert/Frame...” menu.
选择“插入/图文框“菜单。
In the form, that opens, select “Options” tab and write directive in “Name” field. Remember in order to let reporting engine know that this frame should be replaced with image, you have to add “image: ” in front of the directive. Following example directive places logo of the company.
“选项“,“名称”字段输入”指令“。为了让OOO知道显示报表的时候用“图像”代替“图文框”,必须在指令加入"image:". 指令示例如下。
image: asimage(user.company_id.logo)
Note:
You do not have to add another “image: ” to this directive. Directive have to be placed in frame's properties “Name” field, not directly inside frame as a text. -
Windows下安装UNO,配置AEROO_REPORT (Openoffice4已经升级为Python2.7.5版)最近单位要上一个OE,但OE7一天一个新更新,不知何年到头。 闲着没事写一点心得,不敢称为教程。
ubuntu是开源的,系统也稳定的,但对新手来说,liunix内核有很多不适应,又要学OE又要学ubuntu肯定麻烦,建议新手从windows入手,成熟了再移值到ubuntu下.
使用OE7,必须在系统中安装python,一般使用2.7.
AEROO_REPORT依赖于openoffice或libreoffice. 但是libreoffice 4使用的python3.3,上一个版本是2.6, openofice 3.4使用2.6. 而在导入py-uno的时侯,系统python必须和openoffice的python相同,因此选择了2.6.X作为系统python的版(注:librefoffice在生成报表时,明显比openoffice慢5秒左右,建议安装openoffice3.4.x) openoffice尽量在干净的系统上安装,安装完后不要删除再装,因为第二次安装的时侯会出现各种问题。
一、首先安装 openoffice 3.4.x
1. 启动openoffice的python,并查看系统环境
>>>import os
>>>print(os.environ['URE_BOOTSTRAP']) #3
vnd.sun.star.pathname:d:\Program Files\OpenOffice.org 3\program\fundamental.ini
>>>print(os.environ['UNO_PATH']) #4
d:\Program Files\OpenOffice.org 3\program<br />
>>>print(os.environ['PATH']) #5
d:\Program Files\OpenOffice.org 3\URE\bin;d:\Program Files\OpenOffice.org 3\Basis\program;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
2. 配置系统环境(windows7, 2008)
计算机->属性-> 高级系统设置 -> 高级 -> 环境变量 -> 系统变量 -> 新建或修改
1) 新建 URE_BOOTSTRAP = vnd.sun.star.pathname:d:\Program Files\OpenOffice.org 3\program\fundamental.ini
2) 新建 UNO_PATH = d:\Program Files\OpenOffice.org 3\program<br /> 3) 修改 PATH = d:\Program Files\OpenOffice.org 3\URE\bin;d:\Program Files\OpenOffice.org 3\Basis\program;C:\WINDOWS\system32;C:\WINDOWS...........
二、制作openoffice无窗口启动服务
1. 批处理文件 soffice.bat
instsrv OpenOfficeUNO "d:\openerp7\officeuno\srvany.exe"
(instsrv.exe 和 srvany.exe 这2个程序网很好找)
2. 注册表导入文件 soffice.reg
=======================================================
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\OpenOfficeUNO\Parameters]
"Application"="D:\Program Files\OpenOffice.org 3\program\soffice.exe"
"AppParameters"="-nologo -nofirststartwizard -headless -norestore -invisible -accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;"
=======================================================
注:中间的路径根据你安装的openoffice 位置自行修改
3. 启动服务
4. 验证安装是否成功
telnet localhost 8100
二、系统python26, 假定是d:\python26
1. 告诉系统python26的uno所在的位置
D:\Python26\Lib\site-packages\uno.pth
=================================
D:\Program Files\OpenOffice.org 3\Basis\program
=================================
3. 启动系统python26
d:\python26\python.exe
>>import uno
如何什么都不显示则导入成功。 如导入不成功则重启一次电脑再导入,还是不能导入则设置有问题。
三、安装aeroo_report
1. [检测到链接无效,已移除] 从这儿下载report_aeroo; report_aeroo_ooo; (注OE官网上的aeroo_report有问题,试过一次没有成功,官网的没问题)
2. 安装addons 则再也不会出现 找不到 uno的提示了。