Look at this strange thing.
My code here works well.
<openerp>
<data>
<template id="index" inherit_id='point_of_sale.index' name="Restaurant Index"><!DOCTYPE html>
<xpath expr="//title" position="after">
<title>Odoo POS - AS</title>
</xpath>
<xpath expr="//link[#id='pos-stylesheet']" position="after">
<link rel="stylesheet" href="/pos_lapagept/static/src/css/pos_as.css" />
</xpath>
</template>
</data>
</openerp>
But if I replace by this code :
<xpath expr="//title" position="replace">
<title>Odoo POS - AS</title>
</xpath>
It DOESN'T replace the title. It does nothing... Do you understand this?
Try following,
<xpath expr="//title" position="attributes">
<attribute name="title">Odoo POS - AS</attribute>
</xpath>
Related
I have overriden account.invoice_supplier_form and I have added kanban view
<record id="invoice_supplier_form_inherit" model="ir.ui.view">
<field name="name">account.invoice.supplier.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page/field[#name='invoice_line_ids']" position="attributes">
<attribute name="mode">tree,kanban</attribute>
</xpath>
<xpath expr="//notebook/page/field[#name='invoice_line_ids']" position="inside">
<kanban class="o_kanban_mobile">
...
So now page inside notebook supports two views - tree and kanban for invoice_line_ids. I want to set kanban as default view. How do I do that?
...
Did you try this:
<xpath expr="//notebook/page/field[#name='invoice_line_ids']" position="attributes">
<!-- reverse the order here -->
<attribute name="mode">kanban,tree</attribute>
</xpath>
<!-- and here make sure the kanban is the first tag inside the field tag -->
<xpath expr="//notebook/page/field[#name='invoice_line_ids']/tree" position="before">
<kanban class="o_kanban_mobile">
....
....
I need to make a delete button invisible using attrs.
my code here.
in this code i want to put invisible delete button.
<record id="calender_event_form_id1" model="ir.ui.view">
<field name="name">calender_event</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_form_popup"/>
<field name="arch" type="xml" delete="false">
<xpath expr="//field[#name='partner_ids']" position="after">
<field name="c_is_meeting_done" string="Is Meeting Done?" readonly="1"/>
<field name="description"/>
</xpath>
<xpath expr="//field[#name='alarm_ids']" position="after">
<div name="buttons">
<button name="%(ouc_meeting_wizard_action)d" string="Close Meeting" attrs="{'invisible':[('c_is_meeting_done', '=', True)]}" type="action" class="oe_highlight" />
</div>
</xpath>
</field>
</record>
You can give "delete=1" to your particular view from xml. Like this:
<form string="Custom" delete="1"/>
I have a button which I need to show only if the user is a superuser (admin). My problem is that when I'm using xpath to include the attrs, nothing is working as expected. My code is:
<record id="wms_stock_view_move_form" model="ir.ui.view">
<field name="name">wms.stock.view.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_form" />
<field name="arch" type="xml">
<field name="location_id" position="attributes">
<attribute name="domain">[('name','!=', 'Scrapped')]</attribute>
</field>
<field name="location_id" position="after">
<field name="is_superuser"/>
</field>
<field name="location_dest_id" position="attributes">
<attribute name="domain">[('name','!=', 'Scrapped')]</attribute>
</field>
<xpath expr='//form[#string="Stock Moves"]' position='attributes'>
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
<attribute name="delete">false</attribute>
</xpath>
<xpath expr="//button[#name='action_cancel']" position="attributes">
<attribute name="attrs">{'invisible':[('is_superuser','=', True)]}</attribute>
</xpath>
</field>
</record>
here, is_superuser is a computed field, its code is:
is_superuser = fields.Boolean(compute='_is_super_user')
def _is_super_user(self):
if self._uid == SUPERUSER_ID:
self.is_superuser = True
else:
self.is_superuser = False
The original code for the button, in its original view is:
<button name="action_cancel" states="draft,assigned,confirmed" string="Cancel Move" type="object"/>
any idea, what I'm doing wrong ? Thanks in advance.
I would prefer to use Odoo's group access system for such behaviour. Just extend the button with the attribute groups and ofcourse the correct group (for example base.group_system or base.group_no_one for admins):
<field name="action_cancel" states="draft,assigned,confirmed" position="attributes">
<attribute name="groups">base.group_system</attribute>
</field>
The code that you are using should work :
first you need to put #api.depends() on the method definition, without putting any field so it will be computed every time the record is called.
second check the result of the compute field doe's it work like it should because the xml code is correct use print in console to see if the code i working is the method gets called.
I really appreciate all your help, but the above responses does not helped me. However, I found the answer for this question. Since, it has states included, we need to take that into account as well. We need to override the behavior of 'states' tag as well. so the code needs to be:
<xpath expr="//button[#name='action_cancel']" position="attributes">
<attribute name="states"></attribute>
<attribute name="attrs">{'invisible':['|', ('is_superuser','=', False), ('state', 'not in', ('draft','assigned','confirmed'))]}</attribute>
</xpath>
I've inherited a form view and made some modifications using xpath. I need a button in the header of form view to show only to admin user. But when I'm putting the groups, its giving following error :
Error details:
error_details
My code is:
<record id="wms_stock_view_move_form" model="ir.ui.view">
<field name="name">wms.stock.view.move.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_form" />
<field name="arch" type="xml">
<field name="location_id" position="attributes">
<attribute name="domain">[('name','!=', 'Scrapped')]</attribute>
</field>
<field name="location_dest_id" position="attributes">
<attribute name="domain">[('name','!=', 'Scrapped')]</attribute>
</field>
<xpath expr='//form[#string="Stock Moves"]' position='attributes'>
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
<attribute name="delete">false</attribute>
</xpath>
<xpath expr='//button[#name="action_cancel"]' position='attributes'>
<attribute name="invisible">True</attribute>
</xpath>
<button name="action_done" states="draft,assigned,confirmed" string="Process Entirely" type="object" class="oe_highlight" position="replace" groups="base.group_no_one"/>
</field>
</record>
I have to guess which button you want to set new groups to, because your error relates to action_done but your own answer to action_cancel. So let me do this abstractly. You already have the answer in your question. Use XPath to "find" the button and use position="attributes":
<xpath expr="//button[#name='button_name']" position="attributes">
<attribute name="groups">module_name.group_id</attribute>
</xpath>
I eventually solved my own question, the solution is:
<xpath expr='//button[#name="action_done"]' position='replace'>
<button name="action_done" states="draft,assigned,confirmed" string="Process Entirely" type="object" class="oe_highlight" position="replace" groups="base.group_no_one"/>
</xpath>
I have Odoo v9 installed in CentOS7 on a remote server. I copied the Ecommerce Catalog without price module folder to the addons folder, activated developer mode, updated module list, clicked on install that module. I get this error posted below and if I come back to the apps that module shows up as "Installing".
Error details:Element '<xpath expr="//del[#class='text-danger mr8']">' cannot be located in parent view
Error context:View `Suggested Products Without Catalog Price`[view_id: 924, xml_id: n/a, model: n/a, parent_id: 894]None" while parsing None:23, near<data inherit_id="website_sale.cart_lines" name="Suggested Products Without Catalog Price"> <xpath expr="//del[#class='text-danger mr8']" position="replace"> <field name="text-danger" invisible="1" nolabel="1"/> </xpath> </data>
Here is the xml view it refers to:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="products_item" inherit_id="website_sale.products_item" name="Shop Without Catalog Price">
<xpath expr="//del[#class='text-danger mr8']" position="replace">
<field name="text-danger" invisible="1" nolabel="1"/>
</xpath>
</template>
<template id="cart" inherit_id="website_sale.cart_lines" name="Shopping Cart Without Catalog Price">
<xpath expr="//del[#t-field='line.product_id.lst_price']" position="replace">
<field name="text-danger" invisible="1" nolabel="1"/>
</xpath>
</template>
<template id="product_price" inherit_id="website_sale.product_price" name="Product Page Without Catalog Price">
<xpath expr="//span[#class='text-danger oe_default_price']" position="replace">
<field name="text-danger oe_default_price" invisible="1" nolabel="1"/>
</xpath>
</template>
<template id="suggested_products_list" inherit_id="website_sale.cart_lines" name="Suggested Products Without Catalog Price">
<xpath expr="//del[#class='text-danger mr8']" position="replace">
<field name="text-danger" invisible="1" nolabel="1"/>
</xpath>
</template>
<template id="modal_cart" inherit_id="website_sale_options.modal" name="Modal Cart Without Catalog Price">
<xpath expr="//span[#t-attf-class='text-danger oe_default_price']" position="replace">
<field name="text_danger oe_default_price" invisible="1" nolabel="1"/>
</xpath>
<xpath expr="//span[#class='text-danger oe_optional']" position="replace">
<field name="text-danger oe_optional" invisible="1" nolabel="1"/>
</xpath>
</template>
</data>
</openerp>
What is going on here is that basically a ViewB tries to add something on ViewA using the //del[#class='text-danger mr8'] xpath as a hook. But this element on ViewA has probably been removed by another module. So, what you can do here is find which view uses this xpath expression and either edit it to use another expression or find the ViewA that this expression refers to and add the class='text-danger mr8' element so that ViewB can operate normally.