Odoo employee image is not been showed on website template - odoo

I'm trying to show the employee's picture (fields: hr_employee.image) on a website template. But the template just show the default picture for employees instead of the loaded image.
I tried this:
<span t-field="employee.image" t-options="{'widget': 'image', 'style': 'height:200px;width:200px;'}"/>
And also, tried this:
<div t-field="employee.image" t-options="{'widget': 'image', 'style': 'height:200px;width:200px;'}"/>
And this:
<img t-field="employee.image" t-options="{'widget': 'image', 'style': 'height:200px;width:200px;'}"/>
Template just show this:

I'm afraid accessing images isn't as simple as that since you need sudo access to get them. If you're accessing the built-in employee module then the base model already provides this sudo access for you. Instead use the following:
<img t-att-src="image_data_uri(employee.image_1920)" style="max-height:85pt;max-width:90%"/>
The 1920 refers to the image's size. You can also use employee.image_1024, employee.image_512, employee.image_256 or employee.image_128
If you're trying to access images from your own custom module then you'll need to update the .py file to access the image and provide its public url.

You can use website.image_url to define the image src attribute.
<img t-att-src="website.image_url(employee, 'image_medium')" class="img shadow rounded" alt="Employee"/>
The above code is taken from website_hr
module (aboutus template)

Related

How to display image url in vue.js

So This is correct way to display image in vue
<img class="cur-img" src="~#/assets/img/test.png" alt="temp-img">
However, the following way is incorrect, if templateImg is a string represent by "~#/assets/img/test.png"
<div v-for="(item,index) in items" :key="index">
<img :src="item.templateImg" alt="template-img">
</div>
Is there any way to fix it?
Usually, you will want to import the asset in your JS code. For example:
<template>
<img :src="image" />
</template>
<script>
import testImage from "#/assets/img/test.png"
export default {
image: testImage
}
</script>
Use the following:
<img :src="require(item.templateImg)">
When we are binding src to a variable, it is giving its raw value to the img tag, which means it's expecting a full resource URL. It's up to us to provide a complete data URL to that resource, which means creating a corresponding absolute resource URL out of the relative asset path that we're using.
Thus, we need to fetch it using require(). If you are using an absolute path like a base64 data image URL, or compete image URLs, then in such cases you don't need require(), and your current code will work just fine.

how to customize sitefinity's default mvc form widget's thank you message as html?

I have created a test form and displayed using sitefinity's default mvc form widget and when submitting the form it displays thank you message(directly as text) without any html. I want to add some html with it so that i can style it as per my liking.
Change the form on the page to use UseAjaxSubmit from the widget designer model. After this go to "\ResourcePackages\Bootstrap\MVC\Views\Form\Index.cshtml" and find this piece of code.
if (Model.UseAjaxSubmit)
{
<h3 data-sf-role="success-message" style="display: none;">
#Model.SuccessMessage
<div>my customized message</div>
</h3>
You can change the rendering directly in the default template but I would recommend you to create a new template for the widget and keep the default one.
The Sitefinity Knowledgebase contains workarounds to override this when using AjaxSubmit or not.
If using AjaxSubmit is not enabled:
Create a new file under the Form folder (again, ResourcePackages > Bootstrap > MVC > Views > Form) with the following name: "Form.SubmitResultView.cshtml"
Use the following to display the styled text:
#Html.Raw(HttpUtility.HtmlDecode(ViewBag.SubmitMessage))
I ended up having to add my Form.SubmitResultView.cshtml under Mvc > Views > Forms and used the following markup as I needed a consistent wrapper div:
<div class="some-class">
#ViewBag.SubmitMessage
</div>

Foundation equalizer plug + BS 3.2?

Trying to use equalizer plug, but id doesn't work, and no errors. It`s look like http://goo.gl/OvKy1g. Here is a page http://goo.gl/INMqUL. Do i need include some css for it.
You can use the Foundation Equalize plugin along with Twitter Bootstrap, but you need to do a couple of things to make it work.
DEMO
First, your principle issue is that foundation.js is looking for the corresponding foundation.css. Since you're using Twitter Bootstrap as your base styles, you probably don't want to have to deal with all of the potential style conflicts or having your users download another large css file. Really all that is needed is a reference to the Foundation version and namespace, so just add the following to your css:
meta.foundation-version {
font-family: "/5.4.5/";
}
meta.foundation-data-attribute-namespace {
font-family: false;
}
The second issue is with your markup. You have the data-equalizer-watch attribute applied to the containing .col-sm-4 element, but you have your border on the child element with the class latest-news-item. So change your markup to be:
<div class="row" data-equalizer>
<div class="col-sm-4" >
<div class="latest-news-item" data-equalizer-watch>
<!--Your content here-->
</div>
</div>
<div class="col-sm-4" >
<div class="latest-news-item" data-equalizer-watch>
<!--Your content here-->
</div>
</div>
<div class="col-sm-4" >
<div class="latest-news-item" data-equalizer-watch>
<!--Your content here-->
</div>
</div>
</div>
As you can see in the demo, I was able to get your test page to work with these changes, but I was also able to dramatically reduce the foundation.js file size by using the Custom option on the Foundation Download page and just building a js version with the equalize plugin only. The minified version was 31K. If you're not planning to use any of the other foundation plugins, you might consider using a custom file.
That said, for folks that are looking for an alternative lighter-weight approach, it might be just as easy to write your own jQuery such as by adding a class to the row you want to equalize (I called it 'equalize') and then add:
var row=$('.equalize');
$.each(row, function() {
var maxh=0;
$.each($(this).find('div[class^="col-"]'), function() {
if($(this).height() > maxh)
maxh=$(this).height();
});
$.each($(this).find('div[class^="col-"]'), function() {
$(this).height(maxh);
});
});
Wrap it in a function and you can call it on resize as well if that is important to you.

Image not displayed in xe:basicContainerNode from Extension Library in XPages

I have the following code for a popupmenu from Extension library
<xe:popupMenu id="pop">
<xe:this.treeNodes>
<xe:basicContainerNode image="/vwicn148.gif" label="Container">
<xe:this.children>
<xe:basicLeafNode label="Child" image="/vwicn148.gif"></xe:basicLeafNode>
</xe:this.children>
</xe:basicContainerNode>
</xe:this.treeNodes></xe:popupMenu>
<xp:link escape="true" text="Open popup" id="link1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.openMenu(thisEvent,#{javascript:getComponent('pop').getMenuCtor()})]]></xp:this.script>
</xp:eventHandler>
</xp:link>
The result looks like this
As you can see the image for the basic containerNode is not displayed but the image for the basicLeafNode is displayed.
I want to add an arrow to the container node so that users know it has sub items, how can I do that?
Using firebug I can see that the image icon for the basicContainerNode has the class "dijitNoIcon" added to it, which sets "display:none" for the icon image. Whereas the leaf node does not have that dijiNoIcon class added. (I might need to look into that further as a possible defect)
But, as a workaround you could use some custom CSS to override what dijitNoIcon is doing.
<xe:basicContainerNode image="/vwicn148.gif" label="Container" styleClass="showIcon">
And add a custom css file to your application with the following:
.showIcon .dijitNoIcon{
display: block;
}

WinJS binding to nested control

I am trying to implement semantic zoom control in my application. Here is a fragment of one of my pages:
<div id="semanticZoomDiv" data-win-control="WinJS.UI.SemanticZoom">
<div id="zoomedInListView"
class="win-selectionstylefilled"
data-win-control="WinJS.UI.ListView"
data-win-bind="winControl.itemDataSource: groupedList.dataSource; winControl.groupDataSource: groupedList.groups.dataSource;"
data-win-options="{
itemTemplate: select('#mediumListIconTextTemplate'),
groupHeaderTemplate: select('#headerTemplate'),
selectionMode: 'none',
tapBehavior: 'none',
swipeBehavior: 'none'
}">
</div>
<div id="zoomedOutListView"
data-win-control="WinJS.UI.ListView"
data-win-bind="winControl.itemDataSource: groupedList.groups.dataSource;"
data-win-options="{
itemTemplate: select('#semanticZoomTemplate'),
selectionMode: 'none',
tapBehavior: 'invoke',
swipeBehavior: 'none'
}">
</div>
</div>
The problem is, that semanticZoomDiv is empty.
However, if I remove attribute
data-win-control="WinJS.UI.SemanticZoom"
from semanticZoomDiv two ListViews render and are correctly filled with data. It seems like WinJS has problems with binding data to nested controls? (ListView controls are inside SemanticZoom control - after removal of outer SemanticZoom control data binds correctly).
I managed to make semantic zoom work using binding to global namespace via data-win-options, but I want to provide data for my page through view model, hence my trials to use data-win-bind.
I believe this is an object scoping issue, but am not on Win8 at the moment to verify. If I'm right, you can expose groupedList from your JavaScript code similarly to this.
WinJS.Namespace.define("YourApp", {
groupedList: groupedList,
});
and then change your declarative binding to include the YourApp namespace. That way your data is not in the global namespace.
Alternatively, you can do the data binding in the .js file
zoomedInListView.winControl.itemDataSource = groupedList.dataSource;
zoomedInListView.winControl.groupDataSource = groupedList.groups.dataSource;
zoomedOutListView.winControl.itemDataSource = groupedList.groups.dataSource;