Purchase Order - Supplier Code - odoo-10

I am trying to get Supplier code to show on the Purchase order.
I am able to make it show, as long as there is only a single vendor associated with the product, but if there is more I get the error: Unexpected singleton
<xpath expr="//table[#class='table table-condensed']//tbody//tr" position="replace">
<td>
<span t-f="line.product_id.seller_ids.product_code"/>
</td>
</xpath>
Is there a way to get the default or first seller code to show, if there is more than 2 vendors on the product?

The following is the simple way, using and operator.
Ex:
<xpath expr="//table[#class='table table-condensed']//tbody//tr" position="replace">
<td>
<span t-field="line.product_id.seller_ids and line.product_id.seller_ids[0].product_code"/>
</td>
</xpath>

Related

Odoo15: resize invoice logo

I need to change size of logo on invoice header only. At first attempt I tried this for selected layout:
<template id="external_layout_bold_ksp" inherit_id="web.external_layout_bold">
<xpath expr="//div[#t-attf-class='header o_company_#{company.id}_layout']/div/div/div/img"
position="replace">
<img t-if="company.logo" style="max-width: 350px;max-height: 190px;"
t-att-src="image_data_uri(company.logo)" alt="Logo"/><br/>
</xpath>
</template>
it worked but it is changing all logos of all pdf reports for bold layout, unable to find logo path in report template report_invoice_document. I need to resize only invoice report's logo
I have applied something like that in Odoo 11 and it will work on other versions.
To resize the logo in invoice report only, you need to pass value through context from invoice report and then check it in the external layout bold template.
I have added change_logo_size Boolean context value from invoice report and set it to true as below:
<template id="report_invoice_document_logo" inherit_id="account.report_invoice_document">
<xpath expr="//t[#t-call='web.external_layout']" position="before">
<t t-set="o" t-value="o.with_context(change_logo_size= True)"/>
</xpath>
</template>
hen in the inheritance of external layout bold, I have checked the value from the context and if it's true then apply the replace for image, otherwise leave it as its:
<template id="external_layout_bold_ksp" inherit_id="web.external_layout_bold">
<xpath expr="//div[#t-attf-class='header o_company_#{company.id}_layout']/div/div/div/img" position="replace">
<t t-if=" o and o.env and 'change_logo_size' in o.env.context and o.env.context.get('change_logo_size',False)">
<img t-if="company.logo" style="max-width: 350px;max-height: 190px;"
t-att-src="image_data_uri(company.logo)" alt="Logo"/>
</t>
<t t-else="">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" alt="Logo"/>
</t>
</xpath>
</template>

How do I bind a value to a TCustomAttribute in Aurelia?

I'm trying to achieve the following result: I have a set of values that are coming from an array which I iterate over in order to populate an HTML table. As well I have an icon that user can hoover-over and can see data in there coming from the array and a translation key coming from translation files.
I want to bind a second argument to the TCustomAttribute in order to display to the user another data that was edited by them.
How do I achieve this in Aurelia?
<template>
<table>
<thead>
<th><span>Id</span></th>
<th><span>Name</span></th>
<th><span>Description</span></th>
<th><span>Date</span></th>
</thead>
<tbody>
<tr repeat.for="item of data">
<td><span>${item.Id}</span></td>
<td><span>${item.Name}
<a data-toggle="popover" t="[data-content]pending_name ${data.Name}" data-trigger="hover">
<i class="fa fa-info-circle"></i>
</a>
</span></td>
<td><span>${item.Description}</span></td>
<td><span>${item.Date}</span></td>
</tr>
</tbody>
</table>
</template>
Take a look at the t-params attribute which allows you to pass in additional parameters. More about that in the official guide http://aurelia.io/docs/plugins/i18n#using-the-plugin

How to set font size or bold on description record row on Qweb sale report?

<?xml version="1.0" encoding="utf-8"?><odoo> <data>
<template id="id_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//tbody[#class='sale_tbody']//tr//td[1]" position="replace">
<t t-esc="layout_category['name']" style="font-weight: bold;"/>
</xpath>
</template> </data></odoo>
the following code doesn't work for me,please any suggestion thanks
Got a solution
<xpath expr="//div[hasclass('row','mt32','mb32')]/div[#t-if='doc.user_id.name']/p" position="attributes">
<attribute name="style">font-weight: bold;color:red;</attribute>
</xpath>
You can not use style attribute in <t t-esc> tag.
If you want to use style attribute then you must need to use any HTML tag like div, p, span
Here is an example.
<span style="font-weight: bold;"><t t-esc="layout_category['name']"/></span>
Try to use above code. Hope it will work fine. Upvote if the suggestion is working.

Xpath in current view with inherit_id

I'm using Odoo V12 CE and my issue is I try to edit a PageA view.
Have some PageA, PageB and more, inherit ParentPage.
I want to inherit ParentPage into PageA to add some content and, PageB must be: PageB = ParentPage(without modifications from PageA) + PageB.
Helps please and thanks for all!!
<template id="tpml_id" inherit_id="parent.tpml_parent_id" name="Posts">
<xpath expr="//ul[#id='post-list']" position="after">
<span>This is my posts list for all page (MyPage and all page inherits ParentPage). It's so bad. </span>
</xpath>
</template>
<!-- I want this -->
<template id="tpml_id" copy_inherit_id="parent.tpml_parent_id" name="Posts">
<xpath expr="//ul[#id='post-list']" position="after">
<span>This is my post list for this page only. </span>
</xpath>
</template>
If you want to inherit view but do not want to add anything in parent.tpml_parent_id then you can write as following :
<template id="tpml_id" inherit_id="parent.tpml_parent_id" name="Posts" primary="True">
<xpath expr="//ul[#id='post-list']" position="after">
<span>This is my post list for this page only. </span>
</xpath>
</template>

How to remove 'product_code' field in sale order report qweb in Odoo-9?

In Odoo system, If you set the product_code (interal reference) in product template, the note also be showed on the qweb report. I would like to get only the product's name in sale order qweb report, Is it possible to remove(or hide) the product_code field report? If it is, please help me to specific the right steps to solve it. Thank you
my qweb code :
</tr>
<t t-set="index" t-value="0"/>
<t t-set="product" t-value="0"/>
<t t-foreach="doc.handle_orderline(doc.order_line)" t-as="product_line">
<t t-set="product_num" t-value="0"/>
<t t-set="index" t-value="index + 1"/>
<t t-foreach="product_line" t-as="l">
<t t-set="product_num" t-value="product_num+1"/>
<t t-if="not l.product_uom_qty">
<t t-set="index" t-value="index - 1"/>
</t>
<tr t-if="l.product_uom_qty">
<t t-if="product_num == 1">
<td class="text-center" t-att-rowspan="len(product_line)">
<span t-esc="index"/>
</td>
<td class="text-center" t-att-rowspan="len(product_line)">
<strong><span t-field="l.name"/></strong>
<br/>
<t t-if="l.width_id">( <span style="font-style:italic" t-field="l.width_id.name"/> )</t>
</td>
</t>
In sale.order.line object name field store value in combination of product name and code. name field value set on onchange of Product field.
So in QWEB report, we need to get value from product_id field to display product name.
Replace following code:
<strong><span t-field="l.name"/></strong>
with
<strong><span t-field="l.product_id.name"/></strong>

Resources