I am trying to replace a <t> element using xpath, but it contains a single quote inside the condition.
here is what I tried.
<xpath expr="//t[#t-if='receipt.client and env.pos.company.country and env.pos.company.country.code == 'IN'']" position="replace"/>
How can I do it?
There are two solutions for this.
First :
<xpath expr="//t[#t-if="receipt.client and env.pos.company.country and env.pos.company.country.code == 'IN'"]" position="replace"/>
Second :
<xpath expr="//t[contains(#t-if,"receipt.client and env.pos.company.country and env.pos.company.country.code == 'IN'")]" position="replace"/>
Consider using this form instead :
<xpath expr="//t[#t-if][1]" position="replace"/>
Related
I got problem while using many2many in attrs, it's fine with domain but got error while using in attrs. Do we have any solution or workaround for this issue?
<field name="visible_fields" widget="many2many_tags"/>
<field name="create_uid" attrs="{'invisible': [('id','not in', visible_fields or False)]}"/>
I don't think the 'or operation' inside the right branch can be parsed. I would try something like this:
<field name="create_uid" attrs="{'invisible': ['|',('id','not in', visible_fields), ('id','=',False)]}"/>
Please, i need to customize fields to print from rapport of sale module, so I created a new module and installed it (odoo 12). I have created an XML file, but have this error:
odoo.tools.convert.ParseError: "Error while validating constraint
Element '<xpath expr="//table[#class='table table-condensed']//thead//tr">' cannot be located in parent view
Error context:
View `report_quotation_inherit_demo`
[view_id: 1603, xml_id: n/a, model: n/a, parent_id: 649]
None" while parsing None:5, near
<data inherit_id="sale.report_saleorder_document">
<!-- Finds the first table with as class table table-condensed and gives the ability to modify it
This will replace everything withing tr (including tr)-->
<xpath expr="//table[#class='table table-condensed']//thead//tr" position="replace">
<tr style="background-color:lightgray;">
<th>Description</th>
<th class="text-right">Price</th>
</tr>
</xpath>
<!-- This will search for the 4'th td element (in the tbody with class sale_tbody) and will remove it. -->
<!-- Important: if you would start with element 2, then do 3 and then do 4 you will see strange behaviour.
The first statement would remove element 2 making all other elements move in numbering too. -->
<xpath expr="//tbody[#class='sale_tbody']//tr//td[4]" position="replace">
</xpath>
<xpath expr="//tbody[#class='sale_tbody']//tr//td[3]" position="replace">
</xpath>
<xpath expr="//tbody[#class='sale_tbody']//tr//td[2]" position="replace">
</xpath>
</data>
You can also define xpath like this:
<xpath expr="//table//thead//tr[1]" position="replace">
From this, it is necessary to have only one table in that template and one thead in that table.
If there are multiple than you can define number like as I given example tr[1]
I added a new field in account.config.settings model. It displays the new field in settings page and can enter the value. But when i reopen the page the value is not there. I know the Transient model won't store values for long.
But rest of the values still there, how can i achieve this?
Below is my code.
*.py
class AccountSettings(models.TransientModel):
_inherit='account.config.settings'
#api.one
def _get_header(self):
header = fields.Char('Header')
*.xml
<record id="view_account_config_settings_inherit" model="ir.ui.view">
<field name="name">view.account.config.settings.inherit.form</field>
<field name="model">account.config.settings</field>
<field name="inherit_id" ref="account.view_account_config_settings"/>
<field name="arch" type="xml">
<xpath expr="//group[#name='accounting']" position="after">
<group string="Reports" name="reports">
<field name="header" class="oe_inline"/>
</group>
</xpath>
</field>
</record>
In account.config.settings Model you can save your value by using this :
class AccountSettings(models.TransientModel):
_inherit='account.config.settings'
header = fields.Char('Header')
#api.multi
def set_header_defaults(self):
return self.env['ir.values'].sudo().set_default(
'account.config.settings', 'header', self.header)
Try this code:
class AccountSettings(models.TransientModel):
_inherit='account.config.settings'
#api.one
def _get_header(self):
header = fields.Char('Header',config_parameter='header.configuration')
you can name the attribute config_parameter anything you want. And it will be used to get the value of header from other models.
example:
test = self.env['ir.config_parameter'].get_param('**header.configuration**', '').strip()
test will return the temporary stored value in account.config.settings.
Good Day! is the limit parameter/tag not working on a One2many Fields?
I've try the tag but it doesn't work here is my sample code
<notebook>
<page string ="Employee's Attendance">
<field name="employee_ids" string ="Employee Attendance Information">
<tree create = "false" limit="200">
<field name="attendance_status"
<field name="regular_days_work" />
<field name="absent"/>
<field name="leaves"/>
<field name="tardiness"/>
<field name="straight_duty"
</tree>
</field>
</page>
</notebook>
Please I need some help! Thanks
In this document you can see there is no limit attribute in tree view in odoo 8
https://www.odoo.com/documentation/8.0/reference/views.html#lists
AFAIK it doesn't work. Same situation like order by name(or other orderable field) on view.
Perhaps this help to you.
Quick solution:
Setting-->Custumization-->Windows action-->edit limit from 80 to 200.
But this setting is effect to all of views.
Guys thanks and sorry for the late reply as #Döme said this is where i find the javascript code to add the limit of Tree View Parameter in Odoo
in /web/static/src/js/view_list.js
limit: function () {
if (this._limit === undefined) {
this._limit = (this.options.limit
|| this.defaults.limit
|| (this.getParent().action || {}).limit|| 250 /*This value must be change*/); /*default 80*/
}
Line code is 115 to 121
Like i have one field in product.template with the field name squ_meter which i need to copy this value in custom field of purchase order line with same field name i.e squ_meter and i want to apply onchange on purchase order line field
Any kind of help would be much appreciated. Thanks in advance
Here's my code
class purchase_order_line(osv.osv):
_inherit = 'purchase.order.line'
_columns ={'squ_meter' : fields.float('Square Meter'),
}
purchase_order_line.xml
<field name="name">purchase.order.inherit</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Products']//field[#name='order_line']//field[#name='product_qty']" position="after">
<field name="squ_meter"/>
</xpath>
</field>
Related Fields
Related field is useful when you want to keep the values of any relational fields except it's reference then it would be easier way to do it.
OLD API
_columns ={
'squ_meter': fields.related('product_id','squ_meter', type='float', relation='product.product', string='Square Meter', readonly=True),
}
Where:
The first set of parameters are the chain of reference fields to
follow, with the desired field at the end.
type is the type of that desired field.
Use relation if the desired field is still some kind of reference. relation is the table to look up that reference in.
NEW API
There is not anymore fields.related fields.
Instead you just set the name argument related to your model:
squ_meter = Fields.Float(string='Square Meter', related='product_id.squ_meter' , readonly=True)
purchase_order_line.xml
<field name="name">purchase.order.inherit</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Products']//field[#name='order_line']//field[#name='product_qty']" position="after">
<field name="squ_meter" readonly="1" />
</xpath>
</field>