0

I'm using "Odoo 16.0+e (Enterprise Edition)" and I premise that I'm not a software engineer but in the past I successfully managed to modify the Qweb code that generates the invoices and the sale/purchase orders pdf documents.

I have an indentation problem with the Worksheet of the Field Service Module.

As you can see from the picture attached everything that I type in the "comments" section of the worksheet report (the only section of my report) gets shrinked into the right half of the page, making the writings very tiny and the overall indentation rather unpleasant to be shown to a customer.

I tried to modify the code in the QWeb view "worksheet_custom_page" but the problem is either not there or there is some inheritance issue that goes beyond my knowledge.

How can I solve the problem?

Here the picture of how the pdf is indented: PDF

Here is the code of the Qweb view:

<t t-name="industry_fsm.worksheet_custom_page">
                <div class="page">
                    <div class="row">
                        <div t-attf-class="{{'col-6' if report_type == 'pdf' else 'col-md-6 col-12'}}">
                            <t t-foreach="doc.user_ids" t-as="user">
                                <div class="mb-3">
                                    <div><strong>Worker: </strong></div>
                                    <div t-out="user" t-options="{                                         &quot;widget&quot;: &quot;contact&quot;,&quot;fields&quot;: [&quot;name&quot;, &quot;address&quot;, &quot;phone&quot;, &quot;email&quot;]}"/>
                                </div>
                            </t>
                        </div>
                        <div t-attf-class="{{('col-6' if report_type == 'pdf' else 'col-md-6 col-12') + ' mb-3'}}">
                            <t t-if="doc.partner_id">
                                <div><strong>Customer: </strong></div>
                                <div t-out="doc.partner_id" t-options="{                                     &quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;name&quot;, &quot;address&quot;, &quot;phone&quot;, &quot;email&quot;]}"/>
                            </t>
                        </div>
                    </div>
                    <div name="worksheet_task_timesheet">
                        <t t-set="is_uom_day" t-value="doc.timesheet_ids._is_timesheet_encode_uom_day()"/>
                        <t t-if="doc.allow_timesheets and doc.timesheet_ids">
                            <h2>Timesheets</h2>
                            <div t-attf-class="#{'table-responsive-sm' if report_type != 'pdf' else ''}">
                            <table class="table table-sm o_main_table">
                                <thead>
                                    <tr>
                                        <th class="text-start">Date</th>
                                        <th class="text-start">Worker</th>
                                        <th class="text-start">Description</th>
                                        <th t-if="is_uom_day" class="text-end">Days Spent</th>
                                        <th t-else="" class="text-end">Hours Spent</th>
                                    </tr>
                                </thead>
                                <tbody class="sale_tbody">
                                    <t t-foreach="doc.timesheet_ids" t-as="line">
                                        <tr t-att-style="'background-color: #F1F1F1;' if line_index % 2 == 0 else ''">
                                            <td>
                                                <span t-field="line.date"/>
                                            </td>
                                            <td>
                                                <span t-field="line.employee_id.name"/>
                                            </td>
                                            <td class="text-start">
                                                <span t-field="line.display_name"/>
                                            </td>
                                            <td class="text-end">
                                                <t t-if="is_uom_day">
                                                    <span t-out="line._convert_hours_to_days(line.unit_amount)" t-options="{&quot;widget&quot;: &quot;timesheet_uom&quot;}"/>
                                                </t>
                                                <t t-else="">
                                                    <span t-out="line.unit_amount" t-options="{'widget': 'float_time'}"/>
                                                </t>
                                            </td>
                                        </tr>
                                    </t>
                                </tbody>
                            </table>
                            <div class="row justify-content-end">
                                <div t-attf-class="#{'col-sm-2' if report_type == 'pdf' else 'col-auto'}">
                                    <table class="table table-sm">
                                        <tr class="border-black o_total">
                                            <td colspan="4" class="text-end">
                                                <strong class="me-2">Total</strong>
                                                <t t-if="is_uom_day">
                                                    <t t-out="line._convert_hours_to_days(doc.effective_hours)"/>
                                                </t>
                                                <t t-else="">
                                                    <span t-field="doc.effective_hours" t-options="{&quot;widget&quot;: &quot;float_time&quot;}"/>
                                                </t>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>
                        </t>
                    </div>
                    <div name="worksheet_map" t-if="doc.comment" style="page-break-inside: avoid">
                        <h2>Worksheet</h2>
                        <div class="row mb-2 col-12" style="page-break-inside: avoid">
                            <div class="col-12">
                                <t t-out="doc.comment"/>
                            </div>
                        </div><br/>
                    </div>
                    <div t-if="doc.worksheet_signature">
                        <div t-if="report_type == html" class="ribbon" style=" position: absolute; right: 0px; top: 0px;                             z-index: 1; overflow: hidden; width: 75px; height: 75px;  text-align: right;">
                            <span style="  font-size: 10px; color: #fff;  text-transform: uppercase;  text-align: center; font-weight: bold; line-height: 20px; transform: rotate(45deg);  width: 100px; height: auto; display: block;  background: green; position: absolute;  top: 19px; right: -21px; left: auto; padding: 0;">
                                Signed
                            </span>
                        </div>
                        <div t-attf-class="#{'col-12 col-lg-3' if report_type != 'html' else 'col-sm-7 col-md-4'} ms-auto text-end" style="page-break-inside: avoid">
                            <h5>Signature</h5>
                            <img t-att-src="image_data_uri(doc.worksheet_signature)" style="max-height: 6rem; max-width: 100%; color:black;"/><br/>
                            <span t-field="doc.worksheet_signed_by"/>
                        </div>
                    </div>
                </div>
        </t>

I tried tinkering with the code and I tried asking Gemini Pro (which has prooved able to solve problems in other views like the Invoice one) but nothing changed how the comments section is indented in this one, I don't know if there is some inheritance issue or some interaction with other files in the module that go beyond my knowledge but it might as well be the case.

1
  • The bootstrap col in the same classList as row is likely not a good idea try <div class="row mb-2" style="page-break-inside: avoid"> instead of <div class="row mb-2 col-12" style="page-break-inside: avoid"> Commented Oct 17 at 13:29

1 Answer 1

0

Replace the misformated block (containing div with wrong classes-combination: row col-12) by this one:

<div name="worksheet_map" t-if="doc.comment" style="page-break-inside: avoid">
    <h2>Worksheet</h2>
    <div class="row mb-2" style="page-break-inside: avoid">
        <div class="col-12">
            <t t-out="doc.comment"/>
        </div>
    </div>
    <br/>
</div>

If it does not solve your issue: create a view that inherit DIRECTLY: industry_fsm.worksheet_custom_page and replace the worksheet_map div using xpath:


    <template id="worksheet_custom_page_fix" inherit_id="industry_fsm.worksheet_custom_page">
        <xpath expr="//div[@name='worksheet_map']" position="replace">
            <div name="worksheet_map" t-if="doc.comment" style="page-break-inside: avoid">
                <h2>Worksheet</h2>
                <div class="row mb-2" style="page-break-inside: avoid">
                    <div class="col-12">
                        <div style="white-space: pre-wrap; text-align: justify;">
                            <t t-out="doc.comment"/>
                        </div>
                    </div>
                </div>
                <br/>
            </div>
        </xpath>
    </template>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.