Is there any way to control views depending on user groups in Qweb?
I try to change the visibility of the "new message" button in the chatter. The button should only be visible if the user is in debug mode.
<templates>
<t t-extend="mail.Chatter">
<t t-jquery="button[class='btn btn-sm btn-primary o_chatter_button_new_message']" t-operation="replace">
<button type="button" groups="base.group_no_one" class="btn btn-sm btn-primary o_chatter_button_new_message"
title="Send a message">
New message
</button>
</t>
</t>
The attribute groups="base.group_no_one" doesn't work. I also tried t-if conditions but got no success.
Related
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>
I have this bootstrap button group with radio buttons:
<div id="MyField" data-toggle="buttons" class="btn-group">
<label class="btn btn-primary btn-sm"><input type="radio" name="MyField" value="Val1" autocomplete="off">First</label>
<label class="btn btn-primary btn-sm active"><input type="radio" name="MyField" value="Val2" autocomplete="off" checked="">Second</label>
<label class="btn btn-primary btn-sm"><input type="radio" name="MyField" value="Val3" autocomplete="off">Third</label>
<label class="btn btn-primary btn-sm"><input type="radio" name="MyField" value="Val4" autocomplete="off">Fourth</label>
</div>
If I select the value using the mouse, everything works fine. However, if I move to the group using the tab key and select another option using the keyboard arrow keys, the following happens:
The active button changes visually as expected
The change javascript event (handled using jQuery $('#MyField').change(...)) is fired as expected
When the form is submitted, the original value of the default selected radio button is sent to the backend.
Any ideas on why this is and how to fix it?
Turns out this is a bug in bootstrap 3.3.4 which is fixed in 3.3.7. After an update, everything works fine.
My fix was to just include an onfocus attribute to the inputs.
<label class="btn btn-primary btn-sm"><input type="radio" name="MyField" value="Val1" autocomplete="off" onfocus="$(this).click();">First</label>
i am learning angular can someone please help me on following :
I have one form which save user (i call api on this submit click). i need to use same form for update user , for that i took two buttons i show "submit" button if user is new (i managethis new and old user from ge api call in OnInit()) and another button is "update" button, i show and hide this buttons depending on Get api call for user in onInit().
form demo code :
<form class="form-area" (ngSubmit)="ngSubmit(applicant)" name="applicantForm" #applicantForm="ngForm" ngNativeValidate>
<div> some fileds</div>
<div class="row" style="content:center">
<div class="col-md-12">
<div class="form-row">
<div class="form-group">
<button *ngIf="submitStatus" type="submit" class="btn btn-info" [disabled]="!applicantForm.form.valid">
<i class="fa fa-send-o"></i> Submit</button>
<button *ngIf="updateStatus" type="submit" class="btn btn-info" [disabled]="!applicantForm.form.valid">
<i class="fa fa-send-o"></i> Update</button>
</div>
</div>
</div>
</div>
</form>
question :
i call (ngSubmit)="ngSubmit(applicant)" method on submit button call to save user, but i confused in how i differentiate this both operation to call ngSubmit(applicant).
i need to perform both operation in single function call from controller.
thanks
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>
Disclaimers first :
1) First question ever, I hope I'm doing this right, apologies if it's not the case.
2) English is not my native language, so sorry for any mistakes.
3) Made a search and couldn't find an answer.
Trying to explain in words will mean many words while a bootply can say it all :
http://www.bootply.com/EBIMFQ5jEC
Basically, what I want is almost working except for this : I would like that clicking on "title 3" for instance (after you've clicked on "title 1" or "title 2") hides the "first/second column(s)" so that the "third column" is the only one shown (and vice-versa of course). I hope this is clear.
I tried a few things with data-parent (such as this: http://www.bootply.com/pgoT2IPG8D which has data-parent="#collapse1" added for the first three buttons) but couldn't achieve anything...
Thanks in advance for any help !
To get what you want you will indeed have to set the `data-parent', but also notice that this also require a '.panel' class. From the docs:
If a selector is provided, then all collapsible elements under the
specified parent will be closed when this collapsible item is shown.
(similar to traditional accordion behavior - this is dependent on the
panel class)
demo: http://www.bootply.com/qhs4dQbFZK
So you should wrap you collapsible item in a .panel class (or change the plugin). See also: https://github.com/twbs/bootstrap/issues/15341
Then a collapsible item will look that shown below:
<div class="panel">
<div class="col-md-2 collapse" id="collapse1">
<div class="btn-group-vertical btn-block" data-toggle="buttons">
<button class="btn btn-default btn-lg" href="">First subtitle column</button>
<button type="button" class="btn btn-default btn-lg" data-toggle="collapse" href="#collapse1-1"><input type="radio" name="subtitle" id="st11">Subtitle 1-1</button>
<button type="button" class="btn btn-default btn-lg" data-toggle="collapse" href="#collapse1-2"><input type="radio" name="subtitle" id="st12">Subtitle 1-2</button>
<button type="button" class="btn btn-default btn-lg" data-toggle="collapse" href="#collapse1-3"><input type="radio" name="subtitle" id="st13">Subtitle 1-3</button>
</div>
</div>
</div>
Your button should get a data-parent attribute:
<button type="button" class="btn btn-default btn-lg" data-toggle="collapse" data-parent="#menurow" href="#collapse1"><input type="radio" name="title" id="title1">Title 1</button>
And your items should be wrapped inside the id set before (#menurow):
<div class="row" id="menurow"></div>
Notice that the .panel class also set some style rules, which should be overrules (undo) for your situation, for instance: .panel {margin-bottom: 0;}