How to check the current URL in qweb? - odoo

I would like to check current URL in qweb to change the text in a button.
I am working in an online store based in Odoo 11.0 community
<button t-if="current_URL ==/shop">Filters OFF</button>
<!--Since current_URL would be something like "/shop/category/laptops?filter=5-44" if there were any filters applied -->
<button t-else="">Filters ON</button>
I simply don't know if there is something like "current_url" or any other parameter/variable that qweb would understand and could fetch as a property of the current page or if I should try to do this all in javascript.

<button t-if="request.httprequest.url == '/shop'">Filters OFF</button>
<!--Since current_URL would be something like "/shop/category/laptops?filter=5-44" if there were any filters applied -->
<button t-else="">Filters ON</button>
ref: https://werkzeug.palletsprojects.com/en/0.15.x/wrappers/#werkzeug.wrappers.BaseRequest.url it may be helpful to find other request property

Related

How auto refresh component when data updated from api, without page refresh

I’m trying to make component like a LIKE count,
so,
i have a object is name (LIST) which i get from api, in my LIST object have property total_like which default value is 0, when i click to like button i make post request to api and in api my total_like value rising to 1 and 2 and etc.
in my view i’m displaying the like count with {{item.total_like}} everything work well to this point.
problem is item.total_like value updating only when i refresh the page, but i want to show new value of this property without refreshing page.
how can i figure out with it ?
regards
Maybe you can use the event modifiers to prevent page reloading, examples are...
<button type="submit" v-on:click.prevent="addLike" >
<button type="submit" v-on:submit.prevent="addLike">
or if you want to use the shorthand
<button type="submit" #click.prevent="addLike" >
<button type="submit" #submit.prevent="addLike">
Hope this helps.

How to include a checkbox image in a Qweb Report?

Is there way to change checkbox image in qweb report. For example i want to change standard "V" to image like this:
Is it possible?
Solution 0
Add the file to your module, for example store it in the path /module_name/static/src/img/image_name.png
Then now you can add the image to the Qweb Report:
<img t-att-src="'/module_name/static/src/img/image_name.png'" />
Note: respect the order and the type of the quotes
Solution 1
Maybe it is useful to create ul html list with all the elements you want to add:
<style>
.icon_list {
list-style-image: url('/module_name/static/src/img/image_name.png');
}
</style>
<!-- [...] -->
<ul class="icon_list" >
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
(I didn´t try it but it should work as well)
you can simply replace it with the standard Unicode character ☑ by a field that is checking the status
Please use "input type as checkbox". It worked for me.
<input type="checkbox" checked="checked"/>I agree that glasses are selected based on my indications
in odoo11
you can choose this class for checkbox
i class="fa fa-check which opening and closing tags This gives better checkbox than default in odoo

Prestashop: how to add fields to the order summary page

I'm working with Prestashop 1.6 and I need to add a checkbox and text field in the order summary page, as shown below.
I'm lost on which hooks to use to do so. These fields should be also shown in the invoice. For the hook of the invoice I believe it is the DisplayPDFInvoice hook, but for the order summary (display and get information) I don't know which hooks to use.
Can you give me some tips? Thanks for any help
You can use hook hookDisplayBeforeShoppingCartBlock to render any content on cart summary page. Don't forget to register this hook to your module.
I have tried using the same and got the results as below:
Code:
public function hookDisplayBeforeShoppingCartBlock()
{
return '<div>Text Area : </div><textarea rows="3" cols="30">This is a text area rendered from hookDisplayBeforeShoppingCartBlock</textarea><br><br><input type="checkbox" name="vehicle" value="Bike">checkbox 1<br><input type="checkbox" name="vehicle" value="Car">checkbox 2';
}
The above code is used just to show an example, you can render any template file from there. As you can see that this hook renders content above cart block so you can use javascript to move it below cart block.

ToscaWidgets - customize form

I'm using https://pypi.python.org/pypi/tgapp-resetpassword/0.1.5 which allows you to override the template used for the reset password page. Unfortunately, the actual form itself is included as a 'black box':
<div>
${reset_password_form.display(action=action)}
</div>
The form has been defined as a tw2.forms.TableForm which is not how I'd like to display it. Is it possible to have finer grain control e.g. insert custom html around each of the fields, or be more explicit about how to display certain fields?
E.g. I'd like to do something like the following (made up):
<div>
<form ${reset_password_form.attrs} class="my-own-class-name">
<py:for each="field in reset_password_form.fields">
<div class="custom-class-here">
<label for="${field.id}">
... some logic to possibly override default label else...
${field.default_label_text}
</label>
${field.render_as_input_field()}
</div>
</py:for>
<button type="submit">My own submit text</button>
<form>
</div>
Is this level of customization possible with ToscaWidgets without overriding things in Python?
As by resetpassword documentation you have a reset_password.reset_password_form option that can be used to specify an alternative tw2 form.
You just need to put there the python path (like "resetpassword.lib.forms.ResetPasswordForm") of the form you would like to use in place of the default form.
Then you own form can specify a custom template like https://gist.github.com/amol-/d2a08027d34a8c4dfa69

CheckMultiSelect - Dojo

<input data-dojo-type="dijit.form.FilteringSelect"
data-dojo-props="name: 'jobSelect', store:Practiv.Q.jobStore, searchAttr:'JobNumber'"
id="jobIdSelect" />
Currently the above code displays a drop down with items that can be selected. I currently want to add a checkbox to the drop down list. I have replaced it with the code below.
<select data-dojo-type="dojox.form.CheckedMultiSelect"
data-dojo-props="name: 'jobSelect', store:Practiv.Q.jobStore, searchAttr:'JobNumber'"
id="jobIdSelect" ></select>
Unfortunately it doesnt work. Any suggestions?
instead of setting store in data-dojo-props set like this :-
<select data-dojo-type="dojox.form.CheckedMultiSelect" store="Practiv.Q.jobStore"
data-dojo-props="name: 'jobSelect', searchAttr:'JobNumber'"
id="jobIdSelect" ></select>
first you have ensure that your store is connected to CheckMultiSelect.