PDF 보고서

With Studio, you can edit existing PDF reports (e.g., invoices, quotations, etc.) or create new ones.

기본 레이아웃

보고서의 기본 레이아웃은 스튜디오 외부에서 관리합니다. 설정 으로 이동한 다음 회사 섹션에서 문서 레이아웃 설정 을 클릭합니다. 레이아웃 설정은 해당 회사 전용으로 모든 보고서에 적용됩니다.

You can see how the different settings affect the report layout in the report preview on the right, or download a sample invoice PDF by clicking Download PDF Preview.

Use the following settings:

  • Layout: Four layouts are available:

    Light report layout sample
  • Colors: Change the primary and secondary colors used to structure reports. The default colors are automatically generated based on the colors of the logo.

  • Layout background: The following backgrounds are available:

    • Blank: nothing is displayed.

    • Geometric: an image featuring geometric shapes is displayed in the background.

    • Custom: upload a custom background image.

  • Company tagline: This is displayed in the header of external reports. You can add multiple lines of text.

  • Company details: These are displayed in the header of external reports. You can add multiple lines of text.

  • 용지 서식: 보고서의 기본 용지 크기를 지정합니다. A4 (21cm x 29.7cm), US 레터 (21.59cm x 27.54cm) 또는 QR 코드 페이지 중에서 선택할 수 있습니다. 이와 같이 스튜디오용지 서식 필드에 있는 개별 보고서에 대해서도 지정할 수 있습니다.

Creating new PDF reports

새 보고서를 모델에 대해 생성하려면 모델에 액세스한 후 스튜디오 토글 버튼을 클릭한 다음 보고서 를 클릭합니다. 새로 만들기 를 클릭하고 팝업 창이 열리면 보고서 유형을 선택합니다. 이 내용은 머리글과 바닥글에 표시되는 내용을 지정하는 데에만 사용됩니다.

Once you have created the report, you can start editing it.

Editing PDF reports

모델에 사용할 수 있는 보고서에 액세스하려면, 모델 (예: 판매주문서)에 액세스한 후 스튜디오 토글 버튼을 클릭한 다음 보고서 를 클릭합니다. 기존 보고서를 선택하여 열거나 새 보고서를 만듭니다.

Alternatively, you can also open Studio, click Reports, and search for a specific report or model.

중요

표준 보고서를 복제 한 후 복제한 버전에서 변경하는 것이 좋습니다. 보고서를 복제하려면 보고서의 오른쪽 상단에 마우스 포인터를 올려놓고 세로 줄임표 아이콘 ()을 클릭한 다음 복제 를 선택합니다.

Duplicating a PDF report

옵션

Once you’ve selected or created a report, you can use the options in the left part of the screen to:

  • Change the Report name. The new name is applied everywhere (in Studio, under the Print button, and in the PDF file name).

  • Modify the Paper format. If no value is selected, the format defined in the default layout is used.

  • Show in print menu: to add the report in the Print menu available from the record.

  • 첨부 파일에서 다시 로드: 보고서가 처음 생성될 때 레코드에 첨부 파일로 저장하고 이후에는 보고서의 원본 버전을 다시 로드합니다. 청구서에 법적으로 요구되는 사항이며 주로 이 경우에 사용됩니다.

  • Limit visibility to groups: to limit the availability of the PDF report to specific user groups.

  • Edit sources: to modify the report directly in the XML file.

  • Reset report: to discard all changes made to the report and reset it to its standard version.

  • Print preview: to generate and download a report preview.

Report editor

The report editor allows you to modify the formatting and contents of the report.

  • You can Undo or Redo changes using the related buttons or the shortcuts CTRL Z and CTRL Y.

  • Changes are saved automatically when you leave the report or manually using the Save button.

  • You can reset the report to its standard version by clicking the Reset report button in the left part of the screen.

중요

Editing the header and footer of a report impacts all standard and custom reports.

Conditional blocks

The dashed rectangles represent conditional blocks (if/else statements). These are used to show/hide content based on specific conditions. Click on the block to view the conditions.

View conditions applied to a block.

Select a value to preview its corresponding output and edit it if necessary.

Preview the output of another condition.

참고

Conditions can only be edited in XML.

Other content

There are two types of text content in reports:

  • Static text, i.e., the text that’s not highlighted in blue, which can be modified directly in the editor.

  • Dynamic text, i.e., the text that’s highlighted in blue, which is replaced by field values when the report is generated, e.g., the SO number or the quotation date.

명령어를 사용하여 보고서에 콘텐츠 (예: 필드, 목록, 테이블, 이미지, 배너 등)를 추가할 수 있습니다. / 를 입력하여 파워박스 가 열리고, 여기에서 명령어 제목을 입력하거나 목록에서 선택합니다.

To add static text to the report, type the text where you want it.

For more advanced changes, you can edit the report in the XML directly.

Add a field

필드를 추가하려면 / 를 입력한 후 필드 명령어를 선택합니다. 목록이 열리면 필드를 선택하거나 검색합니다. 필요한 경우 필드명 옆에 있는 오른쪽 화살표를 클릭하면 필드 목록에 액세스할 수 있습니다. 그런 다음 기본값을 지정하고 ‘엔터’ 를 누릅니다.

관련 필드를 선택하십시오.
Add a data table

데이터 표는 관계형 항목 을 나타낼 때 사용합니다. 데이터 표를 추가하려면 / 를 입력하고 동적 표 명령을 선택한 다음 표에 표시할 관계를 선택합니다.

참고

Only relations of type one2many or many2many can be displayed as data tables.

표가 추가되면 표 도구를 사용하여 열을 추가할 수 있습니다. 열 상단에 커서를 놓은 다음 보라색 사각형을 클릭하고 항목을 선택합니다.

Add a column in a dynamic table.

그런 다음 필드 를 열에 삽입할 수 있습니다. 대화 상자가 열리면 필드의 소스 개체 (예: 태그 모델) 및 사용할 수 있는 필드 목록이 표시됩니다.

List of available fields for the Tag model.

참고

  • 기본 행으로 필드의 내용이 자동으로 반복되어 각 필드 값이 보고서에서 행으로 생성됩니다 (예: 태그당 행 하나로 생성). 표 도구를 사용하여 생성된 행 위 또는 아래에 정적 콘텐츠 행을 추가할 수 있습니다.

  • You can also add data tables by modifying the report’s XML.

서식 지정

To format text in the report, select it, then format it using the options in the Text editor.

Format text using the text editor.

Editing the report’s XML

경고

Modifying the XML directly may result in report issues during upgrades. If this happens, simply copy your changes from the old database into your upgraded database.

To edit the report’s XML, click Edit sources in the left pane.

예시

복잡한 구조로 인해 표 자체가 제대로 인식되지 않는 경우도 있습니다. 이러한 경우에도 XML 보고서에서 직접 수정할 수 있습니다. 예를 들어 판매주문서의 경우 XML에서 다음과 같은 구조를 찾을 수 있습니다 (문서화 목적으로 단순화됨).

<!-- table root element -->
<table>
    <!-- thead = table header, the row with column titles -->
    <thead>
        <!-- table row element -->
        <tr>
            <!-- table header element -->
            <th>Name</th>
            <th>Price</th>
        </tr>
    </thead>
    <!-- table body, the main content -->
    <tbody>
        <!-- we create a row for each subrecord with t-foreach -->
        <tr t-foreach="record.some_relation_ids" t-as="line">
            <!-- for each line, we output the name and price as table cells -->
            <td t-out="line.name"/>
            <td t-out="line.price"/>
        </tr>
    </tbody>
</table>

테이블을 편집하려면 각 행에 데이터 셀의 수가 동일한지 확인해야 합니다. 예를 들어, 위의 경우 헤더 섹션 (예: 열 제목)에 셀을 추가하고 본문 섹션에 필드 콘텐츠 (일반적으로 t-out 또는 t-field 지시문을 사용)를 추가해야 합니다.

<table> <!-- table root element -->
    <thead> <!-- thead = table header, the row with column titles -->
        <tr> <!-- table row element -->
            <th>Name</th> <!-- table header element -->
            <th>Price</th>
            <th>Category</th>
        </tr>
    </thead>
    <tbody>  <!-- table body, the main content -->
        <tr t-foreach="record.some_relation_ids" t-as="line">  <!-- we create a row for each subrecord with t-foreach -->
            <td t-out="line.name"/>  <!-- for each line, we output the name and price as table cells -->
            <td t-out="line.price"/>
            <td t-out="line.category_id.display_name"/>
        </tr>
    </tbody>
</table>

참고

Cells can span multiple rows or columns. For more information, go to the Mozilla Developer Network website.

For example, you can modify the Quotation/Order report to add a column to display the product category in the main table:

<table class="table table-sm o_main_table table-borderless mt-4">
    <!-- In case we want to repeat the header, remove "display: table-row-group" -->
    <thead style="display: table-row-group">
        <tr>
            <th name="th_description" class="text-start">Description</th>
            <th>Product Category</th>
            <th name="th_quantity" class="text-end">Quantity</th>
            <th name="th_priceunit" class="text-end">Unit Price</th>
[...]
            <tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
                <t t-if="not line.display_type">
                    <td name="td_name"><span t-field="line.name">Bacon Burger</span></td>
                    <td t-out="line.product_id.categ_id.display_name"/>
                    <td name="td_quantity" class="text-end">
                        <span t-field="line.product_uom_qty">3</span>
                        <span t-field="line.product_uom">units</span>
                        <span t-if="line.product_packaging_id">
Add a Product Category column in a SO.

XML 형식으로 표를 추가하려면 액세스 및 표시하려는 필드와 개체의 이름을 알아야 합니다. 예를 들어, 판매주문서의 태그에 대해 자세히 설명하는 표를 추가해 보겠습니다.

<!-- table root element -->
<table class="table">
    <!-- thead = table header, the row with column titles -->
    <thead>
        <!-- table row element -->
        <tr>
            <!-- table header element -->
            <th>ID</th>
            <th>Name</th>
        </tr>
    </thead>
    <!-- table body, the main content -->
    <tbody>
        <!-- we create a row for each subrecord with t-foreach -->
        <tr t-foreach="doc.tag_ids" t-as="tag">
            <!-- for each line, we output the name and price as table cells -->
            <td t-out="tag.id"/>
            <td t-out="tag.name"/>
        </tr>
    </tbody>
</table>
Add a data table in XML

참고

When adding tables manually, style them using Bootstrap classes, like the table class included in the example above.

If you want to show/hide content based on specific conditions, you can manually add if/else control statements in the report XML.

예를 들어 태그가 없는 경우 사용자 지정 데이터 표를 숨기려면 ‘t-if’ 속성을 사용하여 조건을 정의한 다음 ‘참’ 이나 ‘거짓’ 으로 평가할 수 있습니다. 따옴표 안에 태그가 없는 경우에는 표가 표시되지 않습니다.

<!-- table root element -->
<table class="table" t-if="len(doc.tag_ids) > 0">
    <!-- thead = table header, the row with column titles -->
    <thead>
        <!-- table row element -->
        <tr>
            <!-- table header element -->
            <th>ID</th>
            <th>Name</th>
        </tr>
    </thead>
    <!-- table body, the main content -->
    <tbody>
        <!-- we create a row for each subrecord with t-foreach -->
        <tr t-foreach="doc.tag_ids" t-as="tag">
            <!-- for each line, we output the name and price as table cells -->
            <td t-out="tag.id"/>
            <td t-out="tag.name"/>
        </tr>
    </tbody>
</table>

t-if 구문이 거짓 인 경우 다른 블록을 표시하려면 t-else 구문을 사용하여 지정할 수 있습니다. t-else 블록은 문서 구조에서 t-if 블록 바로 뒤에 위치해야 합니다. t-else 속성에 조건을 지정할 필요는 없습니다. 예를 들어 다음에서 견적서에 태그가 없음을 설명하는 간단한 메세지를 표시해 봅니다.

<!-- table root element -->
<table class="table" t-if="len(doc.tag_ids) > 0">
    <!-- thead = table header, the row with column titles -->
    <thead>
        <!-- table row element -->
        <tr>
            <!-- table header element -->
            <th>ID</th>
            <th>Name</th>
        </tr>
    </thead>
    <!-- table body, the main content -->
    <tbody>
        <!-- we create a row for each subrecord with t-foreach -->
        <tr t-foreach="doc.tag_ids" t-as="tag">
            <!-- for each line, we output the name and price as table cells -->
            <td t-out="tag.id"/>
            <td t-out="tag.name"/>
        </tr>
    </tbody>
</table>
<div class="text-muted" t-else="">No tag present on this document.</div>

By using the t-if/t-else notation, the report editor recognizes that these sections are mutually exclusive and should be displayed as conditional blocks:

Output preview if there are tags.

You can switch conditions using the editor to preview their output:

Output preview if there are no tags.

여러 가지 항목을 선택하려면 ‘t-elif’ 지시문을 사용하여 중간 조건을 추가할 수도 있습니다. 예를 들어 판매주문서 보고서의 제목은 기본 문서의 상태에 따라 변경되는 방식입니다.

<h2 class="mt-4">
    <span t-if="env.context.get('proforma', False) or is_pro_forma">Pro-Forma Invoice # </span>
    <span t-elif="doc.state in ['draft','sent']">Quotation # </span>
    <span t-else="">Order # </span>
    <span t-field="doc.name">SO0000</span>
</h2>

견적용 청구서 라는 제목은 일부 상황에서 사용하게 됩니다. 이러한 조건이 충족되지 않은 상태에서 문서 상태가 ‘초안’ 또는 ‘전송됨’인 경우에는 견적서 를 사용합니다. 이러한 조건 중 어느 것도 충족되지 않는 경우 보고서 제목은 주문서 가 됩니다.

보고서에서 이미지 작업을 하기란 쉽지 않습니다. 항상 명확하게 이미지 크기와 동작이 정교하게 제어되지 않기 때문입니다. 보고서 편집기 를 사용하여 이미지 필드를 삽입할 수 있지만 (/Field 명령어 사용), t-field 지시문과 함께 제공되는 t-options 속성을 사용하여 XML에 삽입하면 크기와 위치를 더욱 쉽게 제어할 수 있습니다.

For example, the following code outputs the field image_128 of the line’s product as a 64px-wide image (with an automatic height based on the image’s aspect ratio).

<span t-field="line.product_id.image_128" t-options-widget="image" t-options-width="64px"/>

The following options are available for image widgets:

  • width: width of the image, usually in pixels or CSS length units (e.g., rem) (leave empty for auto-width).

  • height: height of the image, usually in pixels or CSS length units (e.g., rem) (leave empty for auto-height).

  • class: CSS classes applied on the img tag; Bootstrap classes are available.

  • alt: alternative text of the image

  • style: style attribute; it allows you to override styles more freely than with Bootstrap classes.

These attributes must contain strings, i.e., text enclosed within quotes within quotes, e.g., t-options-width="'64px'" (or, alternatively, a valid Python expression).

참고

The image widget cannot be used on an img tag. Instead, set the t-field directive on a span (for inline content) or div (for block content) node.

For example, let’s add a column with the product image in the quotation table:

<table class="table table-sm o_main_table table-borderless mt-4">
    <thead style="display: table-row-group">
        <tr>
            <th>Image</th>
            <th name="th_description" class="text-start">Description</th>
            <th>Product Category</th>
            <th name="th_quantity" class="text-end">Quantity</th>
            <th name="th_priceunit" class="text-end">Unit Price</th>
[...]
        <t t-foreach="lines_to_report" t-as="line">
            <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
            <tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
                <t t-if="not line.display_type">
                   <td>
                       <span t-field="line.product_template_id.image_128"
                             t-options-widget="'image'"
                             t-options-width="'64px'"
                             t-options-class="'rounded-3 shadow img-thumbnail'"
                           />
                   </td>
                    <td name="td_name"><span t-field="line.name">Bacon Burger</span></td>
                    <td t-out="line.product_id.categ_id.display_name"/>

The t-options-width attribute restricts the image width to 64 pixels, and the Bootstrap classes used in t-options-class create a thumbnail-like border with rounded corners and a shadow.

Add a column with the product image in the quotation table.