(odoo10) how to add product attributes in pdf invo

2019-08-24 10:02发布

问题:

pls advice how to add product attributes into pdf invoice. Currently we printing product SCU:

                    <tr t-foreach="o.invoice_line_ids" t-as="l">
                    <td><span t-field="l.product_id.default_code"/></td>
                    <td class="hidden"><span t-field="l.origin"/></td>
                    <td class="text-right">

and it looks a bit ugly on invoice. pls advice how to add product template like l.product_id.name + attributes, like:

also, could you pls advice how to put attributes below product name? here is my code now:

        <tbody class="invoice_tbody">
            <tr t-foreach="o.invoice_line_ids" t-as="l">
                <td><span t-field="l.product_id.name"/></td>
                <t t-esc="', '.join(['%s: %s' % (attribute_value.attribute_id.name, attribute_value.name) for attribute_value in l.product_id.attribute_value_ids])"/>
                <td class="hidden"><span t-field="l.origin"/></td>

i'd like to have it like that: many thanks in advance!

回答1:

You will need to do something like this to output the product attributes name and value:

<t t-esc="', '.join(['%s: %s' % (attribute_value.attribute_id.name, attribute_value.name) for attribute_value in l.product_id.attribute_value_ids])"/>:


标签: pdf odoo odoo-10