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()]"
Related
It´s possible to replace a tree view and use the xpath tag with context?
For example:
<xpath expr="//tree" position="replace" condition="context.get('hide')">
<tree>...tree view...</tree>
</xpath>
Or something similar.
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>
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 defined a Many2many field for ir.attachemnt. The problem is i can' see the Add an item link to add the records.
*.py
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
*.xml
<notebook>
<page string='Attachments'>
<field name="attachment_ids"/>
</page>
</notebook>
I also tried this:
<field name="attachment_ids" widget="many2many" />
Any idea?
There is only two thing that make Odoo behave like this.
Your view is in edit mode but I think I'm seeing a place holder comments this means it's not the case
Your user is not allowed to create an ir.attachment which is more likely not the case
Your field is readonly.
If not one of this cases these is wired but if you didn't understand what happen you can force that link to appear by using embedded tree with create attribute set to true
<field..... >
<tree create='1'>
....
It'a a bug. If you have more many2many fields in the some class and for one of this you haven't right access rules, all the many2many fields are showed in readonly mode.
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