【问题标题】:Word Wrapping in .rml Reports in OpenerpOpenerp 中 .rml 报告中的自动换行
【发布时间】:2012-05-04 17:47:39
【问题描述】:

有没有办法在openerp6.0的rml模板中换行。我已经定义了一个列宽来获取openerp的销售订单模板中的产品名称。但是当添加没有空格的长名称时,它只是穿过列单独的rml模板报告。任何人都可以为这个问题提出解决方案。

【问题讨论】:

    标签: python report openerp rml


    【解决方案1】:

    我不认为这是开箱即用的支持。我建议您向要显示的对象添加一些方法,这些方法将提供包装到给定列长度的值(小心,如​​果您使用比例字体,这会变得非常棘手,最好坚持使用固定宽度)。

    Python 标准库的textwrap 模块可用于编写这些方法。

    【讨论】:

    • rml 本身有自动换行的功能吗?
    • 我只想用例如:600 个字符来包装一个长词,而单个列没有任何空格。我找到了一个用于 python 的 break_long_words 函数我如何在我的 rml 报告中实现它?
    【解决方案2】:

    只需将单元格的内容包含在 para 标记中。这是一个例子:

    <!DOCTYPE document SYSTEM "rml.dtd" >
    <document filename="wraps.pdf">
      <template showBoundary="0">
        <pageTemplate id="main">
          <pageGraphics />
          <frame id="first" x1="150" y1="400" width="250" height="400" />
        </pageTemplate>
      </template>
      <stylesheet>
        <blockTableStyle id="blocktablestyle4">
          <!-- show a grid: this also comes in handy for debugging your tables.-->
          <lineStyle kind="GRID" colorName="green" thickness="1" start="0,0" stop="-1,-1" />
        </blockTableStyle>
        <paraStyle name="textstyle1" fontName="Helvetica" fontSize="9" textColor="blue" />
      </stylesheet>
      <story>
        <blockTable style="blocktablestyle4" colWidths="2cm,2cm">
          <tr>
            <td>cell A</td>
            <td>This doesn't wraps.</td>
          </tr>
          <tr>
            <td>cell C</td>
            <td>
              <para style="textstyle1">to see how it works. This is yet more long text to demonstrate wrapping through "para" tag.</para>
            </td>
          </tr>
        </blockTable>
      </story>
    </document>
    

    【讨论】:

    • 这适用于产品WithAVeryVeryVeryLongNameAndNoSpacesInsideWhichIsUsuallyNotSplitAsTheOriginalPosterQueriedAbout?
    • 对不起。我忘记了“没有空格的长名称”部分。无论如何,在这样的函数出现后,为了包装结果字符串,这将是必需的。
    【解决方案3】:

    我建议你像这样使用 parawrap 标签:

    <parawrap>[[o.name]]</parawrap>
    

    此示例用于显示对象的名称。

    【讨论】:

    • 这个标签给出错误。 except_orm: (u'list index out of rangeparagraph text u"LSA516.1.220.60.BR.s[[ (line.product_id.default_code and (line.product_id. default_code[0] == \'1\' 或 line.product_id.default_code[0] == \'2\')) 和 line.product_id.name 或 line.product_id.default_code ]]" 导致异常', (, IndexError('list index out of rangeparagraph text" 导致异常',), ))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-10
    • 1970-01-01
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多