Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

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. http://www.alistek.com/  从这儿下载report_aeroo; report_aeroo_ooo; (注OE官网上的aeroo_report有问题,试过一次没有成功,官网的没问题)
    2. 安装addons 则再也不会出现 找不到 uno的提示了。



  • 最近单位要上一个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. http://www.alistek.com/  从这儿下载report_aeroo; report_aeroo_ooo; (注OE官网上的aeroo_report有问题,试过一次没有成功,官网的没问题)
    2. 安装addons 则再也不会出现 找不到 uno的提示了。



  • 高,
    去年折腾过
    没在 windows 安装成功



  • 不错... 主要就是系统的环境变量了吧...

    不知道 UNO 使用的什么协议. 如果有相关的协议文档就相当不错了.



  • 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.



  • 下面的就没有翻译了,报歉。

    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.



  • 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>



  • 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.



  • 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;


  • 管理员

    非常好,谢谢楼主分享



  • 请问楼主,report_aeroo; report_aeroo_ooo;是从网站的哪个位置下载的?怎么一直没有找到呢?



  • http://www.alistek.com/en/products-catalogue/4-product_single/222-aeroo-reports-for-openerp-version-7x.html

    <pay with a tweet>

    点击一下,帮开发做做广告就可以下载了。 可惜tweet不能直接访问,这个自己想办法吧。



  • 谢谢楼主哦。



  • 超赞的分享,收藏!

    -nologo -nofirststartwizard -headless -norestore -invisible -accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;
    这个启动参数看不懂,记录一下:
    http://wiki.openoffice.org/wiki/Framework/Article/Command_Line_Arguments
    http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Opening_a_Connection
    http://wiki.openoffice.org/wiki/Uno/Remote/Specifications/Uno_Remote_Protocol




  • 请教楼主:按楼主的步骤过了一遍,当然我的是openoffice4的,步骤有一些变通。安装report_aeroo和reprot_aeroo_sample两个模块皆无问题。但是安装reprot_aeroo_direct_print和openoffice Help Addons时报错:[b]Warning! Unmet python dependencies!No module named cups[/b];
    谢谢



  • CUP 是lunix系统下的打印服务, 我也没有安装成功过.



  • 没有安装Gnome 则openoffice可以安装吗?


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待