Skip to Content
Menu
This question has been flagged
1 Reply
2927 Views

Hi everyone,

I am trying to customize the PDF RFQ and PO with editing the standard code withing Odoo CE 10. Default Odoo prints 3 fields: Description, Date, and Quantity. Now I would also like the Product name to be added because often we change the description field with custom text for our supplier to understand better so we still need the product name to be printed too. So far I've been able to change it almost to my liking but there are some issues still.

Here's my customized code:

<h2>Request for Quotation <span t-field="o.name"/></h2>
    <table class="table table-condensed">
        <thead>
        <tr>
            <th class="text-left"><strong>Product Name</strong></th>
            <th class="text-left"><strong>Description</strong></th>
            <th class="text-left"><strong>Expected Date</strong></th>
            <th class="text-left"><strong>Qty</strong></th>
       </tr> 
       </thead> 
    <tbody>
        <tr t-foreach="o.order_line" t-as="order_line">
            <td>
                <span t-field="o.product_id.name"/>
            </td>
                <td class="text-left">
                    <span t-field="order_line.name"/>
                </td>
                <td class="text-left"> 
                   <span t-field="order_line.date_planned"/> 
                </td> 
                <td class="text-left">
                    <span t-field="order_line.product_qty"/>
                    <span t-field="order_line.product_uom"/> 
                </td>
        </tr>
    </tbody>
</table>

So as you can see I added "Product Name" to the header and I've also added "<span t-field="o.product_id.name"/>" to the code. I know there is something wrong with this approach because the result does not give me what I'm looking for.

In \this link you can see the result of the generated PDF. So the layout is perfect but the product name is not refreshed per line. I'm sure it's something simple in the code but I could not figure it out...

Additional questions:

- How can I make the "Product Name" text also automatically translatable by Odoo? as you can see now it's in English while the rest is in Indonesian...
- How can I make the date field only show the date without the time?
- How can I show the unit only once?

Thanks for your help!


Avatar
Discard
Best Answer

This is my first ever post on ODOO's forum, so here goes..

Solution to your 1st doubt about not being able to see the product name:

Write:

 <td>
<span t-field="order_line.product_id.name" />
</td>

in place of :

<td>
        <span t-field="o.product_id.name"/> 
</td> 

To answer your datetime field related query:

Replace: 

<span t-field="order_line.date_planned"/> 

With the below code:

<span t-field="order_line.date_planned" t-options="{'widget': 'date'}" />
Not too sure about the below ( last answer ) one, but you can perhaps remove the below part:
 <span t-field="order_line.product_uom"/>
from your code and change the label of 'Qty' in <th> to 'Qty(unit(s))' i.e.
<th class="text-right"><strong>Qty(Unit(s))</strong></th>

All above code is tested in ODOO 11 enterprise.

Hope that helps a bit, not so sure yet about your remaining translation related doubt. 


Avatar
Discard
Author

Thanks a lot Rishi, it works! You should post more :) Still my additional questions are still a mystery, any idea? Or someone else?...