Remove currency symbol odoo 11 - qweb

I changed thousands separator to ' instead of ,.
Now when I try to remove the currency symbol, the thousand separator also be removed.
I have tried those code:
<span t-field="l.price_subtotal" t-field-options="{'widget':'False'}"/>
and
<span t-field="l.price_subtotal"
t-field-options="{"widget": "False"}"/>
Can you help me to display the price as 1'542 without currency
Thank you

Please try these
<span t-esc="'{:,.2f}'.format(l.price_subtotal)" >

You can use this <span t-esc="float(object.field_name)"/>

Just write
<span t-field="l.price_subtotal" widget="monetary"/>

Related

Scrapy cannot extract text

i m using learning scrapy but i m stuck at something
website i use is https://wordpress.org/plugins/tags/category-image/
i am extracting certain text on webpage
i use fallowing commands
fetch("https://wordpress.org/plugins/tags/category-image/")
response.xpath('//*[#class="plugin-author"]').extract_first()
Output :
'<span class="plugin-author">\n\t\t\t<i class="dashicons dashicons-admin-users"></i> Muhammad Said El Zahlan\t\t</span>'
i need to extract Muhammad Said El Zahlan
response.xpath('//*[#class="plugin-author"]/text()').extract_first()
Output:
'\n\t\t\t'
response.xpath('//*[#class="plugin-author"]/#span/text()').extract_first()
response.xpath('//*[#class="plugin-author"]/#span').extract_first()
response.xpath('//*[#class="plugin-author"]/#text()').extract_first()
Get me some clue
use
response.xpath('//*[#class="plugin-author"]/text()')[1].extract()
Output:
' Muhammad Said El Zahlan\t\t'
Here's youre xml tree:
<span class="plugin-author">
<i class="dashicons dashicons-admin-users">
</i> Muhammad Said El Zahlan\t\t
</span>
In other words you want span/i/text():
response.xpath('//span[#class="plugin-author"]/i/text()').extract()
or span//text: (any text under span)
response.xpath('//span[#class="plugin-author"]//text()').extract()

Twig date formatting

I'm trying to format a date and place each item (month, day and year) inside a div or span. I'm using a SaaS platform which provide a date like so:
2015-03-07 22:54:00
What I try to do is format this date into 3 separate items and place them in a div like so:
<span class="day">07</span>
<span class="month">March</span>
<span class="year">2015</span>
Therefore I need to strip everything behind a - and call it inside a div like so:
<span class="day">{{ article.date | split('-')[2] }}</span>
<span class="month">{{ article.date | split('-')[1] }}</span>
<span class="year">{{ article.date | split('-')[0] }}</span>
This gives me an output like:
<span class="day">07 22:54:00</span>
<span class="month">03</span>
<span class="year">2015</span>
Where I get stuck is to remove the time after the day and change the month into a textual representation.
I know it can be done with PHP date functions but I can't get that to work. The problem I'm facing is that the date needs to be stripped after each -.
Is there anybody who can help me with that?
You can use the date() function, and then the date filter
NB: they are 2 really different things!!!
{% set dateTime = date(article.date) %}
<span class="day">{{ dateTime | date('d') }}</span>
<span class="month">{{ dateTime | date('F') }}</span>
<span class="year">{{ dateTime | date('Y') }}</span>
First, the date() function converts your string dates to a DateTime object.
Then, the date filter makes you do the equivalent of the DateTime::format PHP function, so you can use a separate notation for the desidered output.
If you need to translate the name of the month to a locale, you can pipe the trans filter, but it must be enabled first.

How to add a new CSS class to a Link Badge if the value is 0?

I'm using the small module Link Badges to display a badge with the amount of flagged nodes next to a link to the View in question. It works great and I've styled the badge to my needs. This is the current HTML code:
<a class="menu__link menu__link link-badge-wrapper">
<span class="link-badge-text">My View</span>
<span class="link-badge-badge-wrapper">
<span class="link-badge link-badge-menu_badges_execute_view">0</span>
</span>
</a>
Now, I'd like to display the badge a little bit differently (other colors etc.) when the value is 0. I thought about doing this by adding a new CSS class link-badge-zero to the value.
<a class="menu__link menu__link link-badge-wrapper">
<span class="link-badge-text">My View</span>
<span class="link-badge-badge-wrapper">
<span class="link-badge link-badge-zero link-badge-menu_badges_execute_view">0</span>
</span>
</a>
How can I achieve this?
If you just want to add a class if the value inside your span is "0", give this a try
JQuery:
if($(".link-badge").text() == "0"){
$(".link-badge").addClass("link-badge-zero");
}
Here is a fiddle

How to highlight spaces in a tag? (CSS only)

I have the tag
<span class="block" style="width:12px;height:17px"> tttt ttt ttttt</span>
I want to highlight only . How can I do it using only CSS?
Well there is no such way to select the space, but if for some reason you really want to do it then, you can try something like this:
<span class="block" style="width:12px;height:17px"><span style="background-color:#F00;"> </span>tttt<span style="background-color:#F00;"> </span>ttt ttttt</span>
Put the within a span like
<span style="background-color:#F00;"> </span>
You can't do this with only CSS; you will need to wrap each non-breaking space in a span and give that span a background color. Wikipedia does this in their article for example:
In Unicode, it is encoded as <span class="nowrap">U+00A0</span> <span class="unicode" style="background:lightblue"> </span> <span class="smallcaps" style="font-variant:small-caps;">no-break space</span>

Condition depending other field

i have 2 fields (fieldA and fieldB)
what i want :
- if the fieldA contains something then the fieldB should not be displayed
what i try :
<span tal:replace="here/getFieldA" />
<span tal:omit-tag="here/getFieldA" tal:replace="here/getFieldB" />
so it doesn't work
thanks for your help
What you are looking for is tal:condition, possibly combined with the not: and exists: prefixes:
<span tal:replace="here/getFieldA" />
<span tal:condition="not:exists:here/getFieldA" tal:replace="here/getFieldB" />
Alternatively, you can use the | operator, which acts like an if operator, testing existence of the first element. If it doesn't exist, it'll use the next expression, and so on:
<span tal:replace="here/getFieldA | here/getFieldB" />
The tal:omit-tag attribute means something very different. If it's expression evaluates to True, then the tag, and only the tag itself, is omitted from the output. This is best illustrated with an example:
<span tal:omit-tag="">
<i>This part will be retained</i>
</span>
Rendering that piece of pagetemplate results in:
<i>This part will be retained</i>
The surrounding <span> tag was omitted, but the contents were preserved.
Try
<span tal:condition="here/getFieldA" tal:replace="here/getFieldB" />
The Zope Page Templates Reference http://docs.zope.org/zope2/zope2book/AppendixC.html
This is a refinement of the original answer, based on the comments:
<tal:block
tal:define="zone here/getZoneintervention;
thezone python:', '.join(zone);
dep here/getDepartements;
thedep python:', '.join(dep)">
<span tal:condition="zone" tal:replace="thezone" />
<span tal:condition="not:zone" tal:replace="thedep" />
</tal:block>

Resources