internal reference of the product did not add to the invoice report in odoo 10 - odoo-10

I add internal reference of product to the sale form and I want it in the invoice report also
the sale code is :
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
_name = 'sale.order.line'
x_field = fields.Float('Unit cost')
internal_ref=fields.Char(related='product_id.default_code',string='Internal
reference product',store=True,default=100)
partner_name=fields.Many2one('res.partner','partner_id.name')
this is my code but did not work
the python code:
class invoiceLineField(models.Model):
_inherit='account.invoice.line'
internal_ref=fields.Char(related='product_id.default_code',string='Internal
reference product',store=True)
and this is xml report:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_invoice_document_itemnumber"
inherit_id="account.report_invoice_document">
<xpath expr="//div[contains(#class, 'page')]/table[1]/thead/tr/th[1]"
position="before">
<th>Internal reference</th>
</xpath>
<xpath expr="//div[contains(#class, 'page')]/table[1]/tbody/tr/td[1]"
position="before">
<td>
<span t-field="l.internal_ref"/>
</td>
</xpath>
</template>
</data>
</odoo>
no error but the internal reference of product did not appear in the result

If you want the 'default_code' field just to print in report then you can achieve it by 'product_id.default_code'.
<span t-field="l.product_id.default_code"/>

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 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>

field inheritance in POS (Odoo)

I've added the field 'limit' in 'res.partner' model in 'Sales'. Now, I want to inherit the same in my POS module during the Customer Creation.
I've included all my files(xml and js) in manifest.py with proper syntax.
My '.js' file is working completely fine. The problem shows in 'static/src/xml/pos.xml' file.
Here's my code of pos.xml file. No syntax error, still cant get 'limit' field in POS.
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template_test" xml:space="preserve">
<t t-extend="ClientDetailsEdit">
<t t-jquery=".client-details-right" t-operation="append">
<div class='client-detail'>
<span class='label'>Limit</span>
<input class='detail limit' name='limit' value="5000" readonly="True" t-att-value='partner.limit || ""'></input>
</div>
</t>
</t>
</templates>
Please, tell me if anything is wrong or missing!

Purchase Order - Supplier Code

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>

Resources