I am trying to add search input in Header Area in Odoo 10 Website. It works when visit /Shop page, but it gives Internal Error 500, on other pages.
My code in Main Layout is,
<t t-call="website_sale.search" />
Screenshot
How can I overcome this problem and make search option available from any page?
Not sure about v10, but in v14 you can remove a line in website_sale.search as a sort of quick workaround.
Comment or remove this line to avoid 500 error:
<t t-set="action" t-value="keep('/shop'+ ('/category/'+slug(category)) if category else None, search=0)"/>
It will probably look something like this in a module:
<template id="name_of_the_id" inherit_id="website_sale.search">
<xpath expr="//t/t/t[1]" position="replace">
</xpath>
</template>
Related
I want to add order ref name in receipt.Check my image.
There are multiple ways i.e. by editing from front end, or by extending the template.
Option1: From Front end
Activating Developer Mode.
Then Technical
Then Reports.
Find your desire report and edit it.
Option2: Extending The Template
<template id="report_invoice_document_inherit321" inherit_id="external_id_of_template">
<xpath expr="YOUR_XPATH_WHERE_YOU_WANT_YOUR_OUTPUT" position="after">
</xpath>
</template>
I am using Odoo 10 and I dont want the Product Internal Reference(default_code) printing on the Sales order report. I only want to remove from the report so customer cannot see the Internal Reference.
I tried below I seen on another post but it didnt work.
<!-- remove internal reference form Sales report.-->
<template id="sale_order_fields_inherit_saleorder_document" inherit_id="sale.report_saleorder_document">
<strong><span t-field="l.product_id.name"/></strong>
</template>
Inherit the sale_order_document report and replace the l.name with product_id.name here is complete code:
<template id="sale_order_fields_inherit_saleorder_document"
inherit_id="sale.report_saleorder_document">
<xpath expr="//span[#t-field='l.name']" position="replace">
<span t-field="l.product_id.name"/>
</xpath>
</template>
you can try this one !!, may be it'll help you.!
How in inherit qweb add new element after last paragraph in original report:
<p t-if="o.comment">
<strong>Comment:</strong>
<span t-field="o.comment"/>
</p>
//add after <p t-if="o.comment">
<xpath expr="??" position="after">
<p>new</p>
</xpath>
Make sure to inherit the template id as below and then after add your xpath. Hope this helps you.
<template id="report_saleorder_inherit" inherit_id="report.external_layout_footer">
<xpath expr="//p[#t-if='o.comment']" position="after">
<p>new</p>
</xpath>
</template>
You can find the last p-element in your report by using xpath like this:
<xpath expr="(//p)[position()=last()]" position="after">
The (//p) part finds all p-elements and the filter [position()=last()] selects the last of them.
I assumed that the p element is in your base report and the xpath-part is in your inherited report.
Please keep in mind that the p element exists only if your model had data in comment field. The xpath does not know if the last one is the comment or not. It just blindly takes the last one from report and in your example it does not appear in the report if the t-if="o.comment" is not true.
Hope this helped you.
Br,
Veikko
Is it possible with xpath exp in inherit qweb hide below line?
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
You have to use replace and you have to identify the correct node. So identify the node and replace it.
<xpath expr="//t[last()]" position="replace">
<!-- <t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" /> -->
</xpath>
I usually like to replace it with a commented out version of itself. Also the above will only work if the t tag is the last in the document.
You may have to capture a parent node and inject all of the existing xml with your desired t element commented out or removed. You may also be able to use these expressions or some variation of them.
expr="//div[#name='div_name']/t"
expr="//div[#name='div_name']/t[first()]"
I wanted to put an extra field in odoo while signup procedure. If admin has created multi company then user gets options to choose the company during sign up.
Demo screen
can anyone pls help me how can I achieve this Dropdown menu for company options in signup form?
<option t-esc="nb"/></t>
and
<select></select>
have no idea how it works.
TIA
You need to inherit the module you wish to modify, in your case I think this is the "web" module. If you don't know how to inherit modules, I recommend going through Odoo's developer documentation.
Inherit AuthSignupHome class in auth_signup module to fetch multi company data and inherit auth_signup.signup template to include qweb web design to for dropdow with multi company data:
try below code:
Controller.py:
class AuthSignupHome(openerp.addons.auth_signup.controllers.main.AuthSignupHome):
company_ids = request.env["res.company"].sudo().search([])
print'company_ids',company_ids
qcontext['multi_company'] = company_ids
return request.render('auth_signup.signup', qcontext)
In xml:
<template id="inherit_fields" inherit_id="auth_signup.fields" name="Sign up">
<xpath expr="//div[#class='form-group field-login']" position="before">
<div class="selection">
<select>
<t t-foreach="multi_company" t-as="company">
<option><t t-esc="company.name"/></option>
</t>
</select>
</div>
</xpath>
</template>
I think it will help you..