Odoo - Change create button text - odoo

I am using Odoo 10e. In tree view or in form view for my particular model, i want to change the create button text to Add New User. How can we achieve this?
I tried to use Xpath for this, but as far as i know Xpath is use to inherit from a view and add something in the view not to change the item in the parent view

Create one xml file and write this below code in it.
For listview and formview it will change the name of create button as per your custom string.
Add this xml file path to qweb section in manifest file.
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery=".o_list_button_add" t-operation="replace">
<button type="button" class="btn btn-primary btn-sm o_list_button_add" accesskey="c">
<t t-if="widget.model === 'sale.order'">
Your String
</t>
<t t-if="widget.model !== 'sale.order'">
<t t-esc="widget.options.addable"/>
</t>
</button>
</t>
</t>
<t t-extend="FormView.buttons">
<t t-jquery=".o_form_button_create" t-operation="replace">
<button t-if="widget.is_action_enabled('create')" type="button"
class="btn btn-default btn-sm o_form_button_create" accesskey="c">
<t t-if="widget.model === 'sale.order'">
Your String
</t>
<t t-if="widget.model !== 'sale.order'">
Create
</t>
</button>
</t>
</t>
</templates>
I hope this answer will help you.

Simply just xpath to that button.
Then give position replace and change the string to Add New User from Create.
Try the code like this.
But remember the name of the button will be as it is.
Thanks
<xpath expr="//button[#name='action_set_create']" position="replace">
<button name="action_set_create" string="Add New User"/>
</xpath>

Related

Progressbar second sum field

I added a second sum field to the kanban progress bar view and it looks like the following.
Now I want to give the same format to the second view, instead of 24000, that shows 24k.
I’m using this code:
<templates>
<t t-inherit="web.KanbanView.ColumnProgressBar" t-inherit-mode="extension">
<xpath expr="//div[hasclass('o_kanban_counter_side')]" position="after">
<![CDATA[ ]]>
<string name = "Bs"> Bs</string>
<t t-set="total" t-value="0"/>
<t t-foreach="widget.columnState.data" t-as="data_record">
<t t-set="total" t-value="total + data_record.data.expected_revenue_1"/>
</t>
<b class="mt-0">
<t t-esc="total"/>
</b>
</xpath>
</t>
</templates>
I tried using widget: ‘monetary’, also I read the odoo cookbook but can’t find anything that helps me

how to hide the sidebar on saleorder formview odoo?

I have been trying many different ways for hiding the sidebar button. Below code is working on all forms. However, i just want to hide it on sale order form. Widget.modelName seems not working because it is before the form declaration. I also tried doc_model in [sale.order'] and not working as well. How can I solve it? thanks
<t t-jquery = ".o_cp_left" t-operation = "replace">
<t t-if = "widget.modelName == 'sale.order'">
<div class="o_cp_left hiddenManagerSO">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel toolbar"/>
<aside class="o_cp_sidebar"/>
</div>
</t>
<t t-if = "widget.modelName !== 'sale.order'">
<div class="o_cp_left hiddenManagerKOO">
<div class="o_cp_buttons" role="toolbar" aria-label="Control panel toolbar"/>
<aside class="o_cp_sidebar"/>
</div>
</t>
</t>
</t>

Hide the "Create" Button in a specific module only in odoo11

i want to hide the create and import button in the header of my treeview my Odoo version is odoo11
I tried using the inserting create="false" edit="false" in my treeview tag but it hides all the button and I also tried replacing the t-operation="after" to t-operation="replace" but it affects all the other application
<template xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="replace">
<button t-if="widget.modelName == 'hr.timeinout'" type="button" class="btn btn-primary btn-sm oe_refresh_button" accesskey="f">
Refresh List
</button>
</t>
</t>
</template>
I only want to hide the "Create" and "Import" button in that specific treeview thank you
Try this code to remove the create button:
<t t-extend="ListView.buttons">
<!-- this will hide create button for model 'hr.timeinout' -->
<t t-jquery="button.o_list_button_add" t-operation="attributes">
<attribute name="t-if">widget.modelName != 'hr.timeinout'</attribute>
</t>
<!-- this will add refresh button for model 'hr.timeinout' -->
<t t-jquery="div.o_list_buttons" t-operation="prepend">
<button t-if="widget.modelName == 'hr.timeinout'" type="button" class="btn btn-primary oe_refresh_button" accesskey="f">
Refresh List
</button>
</t>
</t>
And to remove the import button for this model:
<t t-extend="ImportView.import_button">
<!-- this will remove button import for model 'hr.timeinout' -->
<t t-jquery="button.o_button_import" t-operation="attributes">
<attribute name="t-if">widget.modelName != 'hr.timeinout'</attribute>
</t>
</t>

How to extend a qweb template in Odoo?

Im trying to extend the point of sale, template to modify the web ticket and the printed version also.... I want to put a codebar with the id numbe. But reading and testing my code doesn't work.... For testing purpuse I put a text in several parts of the template to watch if it is modify... but it's not.
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="XmlReceipt">
<t t-jquery=".receipt-change" t-operation="inner">
<div><span>hello world</span></div>
</t>
</t>
<t t-extend="PosTicket">
<t t-jquery=".receipt-orderlines .product_line" t-operation="inner">
<div><span>hello world</span></div>
</t>
</t>
<t t-extend="PaymentScreenWidget">
<t t-jquery="div.pos-payment-container" t-operation="inner">
<div>
Payment Screen Modified
</div>
</t>
</t>
</templates>
This code is in a file name pos.xml and I append it from openerp.py like this:
'qweb': ['static/src/xml/pos.xml'],
Why the XmlReceipt or the PosTicket or the payment template are not extending????
Then when I sucessfully extend the template, Im gonna try to replace the hello world with
<barcode encoding="CODE128"><t t-esc="o.id"/></barcode>
Thanks!
[EDIT]
Ok, now I'm extending the template, but I cant generate the barcode from the order.sequence_number
I'm trying like this:
<img class="img-responsive" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', order.sequence_number, 500, 100)" style="width:250px;height:50px;"/>
The barcode its not generate like this... but if I do it like this it is
<img t-att-src="'/report/barcode/Code128/*mycode*'" style="width:250px;height:50px;"/>
So I think the error is in the string rendering.....
This is how I extends the mail chatter in odoo-10 and it's working fine for me.
Take a look, may be its help if still needed.
<templates>
<!--
Chatter composer
-->
<t t-extend="mail.chatter.ChatComposer">
<!-- Insert information before the composer -->
<t t-jquery=".o_composer_suggested_partners" t-operation="replace">
<!-- List of followers -->
<div class="o_composer_suggested_partners">
<t t-foreach='widget.suggested_partners' t-as='recipient'>
<div t-attf-title="Add as recipient and follower (reason: #{recipient.reason})">
<input type="checkbox" t-att-data-fullname="recipient.full_name"/>
<t t-esc="recipient.name"/>
<t t-if="recipient.email_address">(<t t-esc="recipient.email_address"/>)</t>
</div>
</t>
</div>
</t>
</t>
</templates>

Hide EXPORT option in more button in OPENERP 7

How to hide the EXPORT Option in the more button for specific user group, and how to hide the 'MORE' button for specific user group in openerp 7.
Hide "Export in More Option"
in OpenERP-7
Create XML File Under static/src/base.xml in your module and add this code:
<templates>
<t t-extend="Sidebar">
<t t-jquery="a.oe_sidebar_action_a" t-operation="replace">
<t t-if="widget.session.uid !== 1">
<a t-if="item.label !== 'Export'" class="oe_sidebar_action_a" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/>
</a>
</t>
<t t-if="widget.session.uid === 1">
<a class="oe_sidebar_action_a" t-att-title="item.title or ''" t-att-data-section="section.name" t-att-data-index="item_index" t-att-href="item.url" target="_blank">
<t t-raw="item.label"/>
</a>
</t>
</t>
</t>
</templates>
Add this in File __openerp__.py:
'qweb': [
"static/src/base.xml",
]
Now restart the server and update your database and refresh the page.