Can we use Qweb templates inside normal views (such as form view) - odoo

I'm trying to make some debugging in a Form view, I wrote something like this inside the notebook section of a form view:
<page string="test">
<template>
<t t-esc="Logging!"/>
<t t-log="Logging!"/>
<t t-raw="Logging" > </t>
</template>
</page>
But nothing happens as if the section doesn't exist.
Can't we use Qweb template inside other views?

template tag will not render in form view. You can check this answer for more details
You can use templates in Activity, Gantt and Kanban views

Related

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>

How to bind data to layout page in asp mvc 4

how to write controller code to shared layout page,
i want to get menu from database to layout,
am able to get menu in normal view page,
this is my layout page
<pre lang="html"> <div style="width:1230px">
<script type="text/ng-template" id="treeMenu">
{{menu.Name}}
<ul ng-if="(SiteMenu | filter:{ParentID : menu.Id}).length > 0">
<li ng-repeat="menu in SiteMenu | filter:{ParentID : menu.Id} : true" ng-include="'treeMenu'"></li>
</ul>
</script>
<ul class="main-navigation">
<li ng-repeat="menu in SiteMenu | filter:{ParentID : 0} : true" ng-include="'treeMenu'"></li>
</ul>
You should isolate this in Partial and use RenderAction in your layout page
Steps in nutshell :
Create Action in some controller "let say CommonController" called SiteMenu for example.
Put the code that will bring the Data from Database and map it to suitable ViewModel to represent your Menu items.
The Action should return PartialView instead of View.
Consider this Action regardless of your main layout. So just create a special view for it and put the logic of Html in that view.
In suitable place in your main layout just use #Html.RenderAction("SiteMenu ","Common")
for more information read about RenderPartial vs RenderAction vs Partial vs Action in MVC

HIde delete button from export data form view in odoo

I want to hide delete button from Export Data form view in odoo. Button that i want to hide also highlighted in attached image.
I'll be very thankful...
You will need to override Odoo's QWeb templates for such customizations.
Create a xml under mymodule/static/src/xml (e.g. your_customization.xml) with following content:
<template>
<t t-extend="Exists.ExportList">
<t t-jquery="button[id|='delete_export_list']" t-operation="replace" />
</t>
</template>
And then don't forget to call that file in your manifest (__openerp__.py) like
{
# other things like author, name, data
'qweb': ['static/src/xml/your_customization.xml'],
}

how to access custom module using t-if condition in xml odoo

I have a custom module test and created pages called test_1, test_2, test_3.
I have inherited calendar view and wrote a condition in js like all the calendar changes should be reflected to test_1. And that is working fine.
Now i need to remove Day and Month button from test_1 page -> Calendar view.
So i am trying to write t-if condition. I dont have idea how to call model. i tried below code but it is not working.
<template>
<tr t-extend="CalendarView.quick_create">
<t t-if="widget.model=='test_1'">
<t t-jquery=".form-group" t-operation="after">
<div class="form-group">
<h3>Example - put fields here </h3>
</div>
</t>
</t>
</tr>
</template>
It is not working throws an TypeError: Cannot read property 'model' of undefined
How to access model in t-if condition?

Durandal: Showing a 'LOADING...' during composition

I can easily show a loading message while the activate method is doing its thing like so:
<div data-bind="compose:ActiveVm">
<div class="text-center" style="margin : 75px">
<i class="fa fa-spinner fa-spin"></i>
</div>
</div>
However if I then update my ActiveVm property with a different viewmodel, the splash content does not show. I understand that the splash content is only designed to show on 'initial' load, but what options do I have for displaying such a message when transitioning from one viewmodel to another?
Note that this composition does not participate in routing...
Update: Related durandal issue here which might be of value to future visitors: https://github.com/BlueSpire/Durandal/issues/414
This begs for a comment of 'what have you tried?' but given that I could see the benefit of this for future users I wanted to throw in my $0.02 -
The splash displays on your screen until Durandal loads up the application and replaces the div with id="applicationHost" 's content with the shell view and the subsequent views that are loaded. If you wanted to make this a re-usable component one thing that you could do is to take that Html.Partial view that is being loaded and create your own view inside of your app folder in your Durandal project.
For example you would create a new HTML view inside of your app folder -
splashpage.html
<div class="splash">
<div class="message">
My app
</div>
<i class="icon-spinner icon-2x icon-spin active"></i>
</div>
And then compose it from your shell -
<div data-bind="if: showSplash">
<!-- ko compose: 'splashpage.html' -->
<!-- /ko -->
</div>
And in your view model you would toggle the observable showSplash whenever you want to show / hide it -
var showSplash = ko.observable(false);
var shell = {
showSplash: showSplash
};
return shell;
And you could call that from your activate methods inside your other view models like this -
define(['shell'], function (shell) {
function activate() {
shell.showSplash(true);
// do something
shell.showSplash(false);
}
});
This sounds to me like a scenario where a custom transition may be useful. When the composition mechanism switches nodes in and out of the DOM, it can use a transition.
This page, under Additional Settings>Transition (about halfway down) describes a custom transition: http://durandaljs.com/documentation/Using-Composition/