Open openerp form in a modal - odoo

I try to open an openerp form in a modal in javascript with:
create_ticket: function (event) {
event.stopPropagation();
var action = {
type: 'ir.actions.act_window',
res_model: 'abc.ticket',
view_type: 'form',
view_mode: 'form',
views: [[false, 'form']],
target: 'new',
};
instance.client.action_manager.do_action(action);
},
but unfortunately, it opens the form but it's not in edit mode, then I cannot fill the form. Did I missed something ?

In fact this piece of code works fine, the problem was a write issue on the model.

Related

Reload kanban view after a wizards closes in ODOO 8

I am trying to execute an action after a wizard action is performed, i want to reload a kanban:
Python code:
return {'type': 'ir.actions.act_close_wizard_and_reload_view', }
Javascript code: (taken from the forum, i think for version 7)
openerp.bmwe_crm = function(instance, local) {
instance.web.ActionManager = instance.web.ActionManager.extend({
ir_actions_act_close_wizard_and_reload_view: function (action,options) {
if (!this.dialog) {
options.on_close();
}
this.dialog_stop();
this.inner_widget.views[this.inner_widget.active_view].controller.reload();
return $.when();
}
});
}
All this from a forum about 7.0 version, but i am using 8.0 and it does not seems to work. I've even trying executing a default action:
return { 'type': 'ir.actions.client', 'tag': 'reload'}
Does not reload the page neither
I can solved this right now as follow
static/src/js/your_module_name.js
openerp.yout_module = function (instance) {
instance.web.ActionManager = instance.web.ActionManager.extend({
ir_actions_act_close_wizard_and_reload_view: function (action, options) {
if (!this.dialog) {
options.on_close();
}
this.dialog_stop();
this.inner_widget.active_view.controller.reload();
return $.when();
},
});
}
views/your_module_name.xml
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module_name/static/src/js/your_js_file_name.js"></script>
</xpath>
</template>
</data>
</openerp>
wizard/your_wizard.py
return { 'type' : 'ir.actions.act_close_wizard_and_reload_view' }
reference1
reference2
above the references, they are using
this.inner_widget.views[this.inner_widget.active_view].controller.reload();
but it is not working in v8. So, I modified it to
this.inner_widget.active_view.controller.reload();
Now, it is working.
To reload a view you can return a view like below. It will return & reload the desired view when wizard closes.
ir_model_data = self.env['ir.model.data']
view_id = ir_model_data.get_object_reference('module_name', 'view_name')[1]
return {
'name': 'view name',
'view_type': 'form',
'view_mode': 'kanban,tree,form',
'res_model': 'your.model.to.reload',
'view_id': view_id,
'context': self._context,
'type': 'ir.actions.act_window',
'target': 'current',
}
DISCALIMER: Not the best FIX, but it's a FIX.
NOTE: In teory odoo 8 web client engine must execute the Action that the Wizards returns in the python code function. This works in all views, except in Kanban views. So this is the workaround:
In the server, create a message in the odoo bus, every time you want to notify something happends:
bus = self.env['bus.bus']
message = {
'subject': '',
'body': 'Appointment Set',
'mode': 'notify',
}
bus.sendone('<CHANNEL-NAME>', message)
Then, in the frontend you must listen for a message on this channel:
First, register the channel (With out this, it wouldn't work)
openerp.bmwe_crm = function(instance, local) {
var bus = instance.bus.bus;
bus.add_channel("<CHANNEL-NAME>");
});
};
Second, reload the kanban when something happend in the channel:
openerp.bmwe_crm = function(instance, local) {
var bus = instance.bus.bus;
bus.add_channel("<CHANNEL-NAME>");
instance.bus.bus.on("notification", instance, function(notification){
instance.client.action_manager.inner_widget.views["kanban"].controller.do_reload();
});
};
DONE!
In my odoo this solution doesn't work...
[ironic mode on] It is one of those things I love about Odoo [ironic mode off]
To other person than the proposal solution doesn't work and need one solution, try this:
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
where you return value, or close the wizard, put this code.
Seriously , good luck.

How to submit a SmartClient DynamicForm programmatically?

I am trying to create a hidden form with some data, which needs to be submitted to a jsp page (which gets open in a new window), but all this would happen programatically, without user pressing submit button.
My Sample code
var fsquery = "abcd";
var emailId = "as#gmail.com";
var portalPsswd = "password";
var projectId = "123";
var kbUrl = "some url which will consume form post parameters";
var pv="1.2",pn="ADA";
this.kbform=isc.DynamicForm.create({
width: 300,
fields: [
{type: "hiddenitem", name: "EMAIL_ID", defaultValue:emailId },
{type: "hiddenitem", name: "PORTAL_PASSWORD", defaultValue:portalPsswd},
{type: "hiddenitem", name: "PROJECT_ID", defaultValue:projectId},
{type: "hiddenitem", name: "FSQUERY", defaultValue:fsquery},
{type: "hiddenitem", name: "PRODUCT_VERSION", defaultValue:pv},
{type: "hiddenitem", name: "PRODUCT_NAME", defaultValue:pn},
{type: "hiddenitem", name: "ORIGIN", defaultValue:"Administrator"},
{type: "submit", name: "submit", defaultValue: "submit"}
],
action: kbUrl,
target: "_blank",
method: "POST",
canSubmit: true
});
this.kbform.submit();
the last statement does not submit the form automatically, but if I click the submit button provided, it works perfectly as needed.
Please provide me a solution which will help me simulate "submit" type button functionality to submit the form.
You can try this sample code here under "text.js" tab
I'm not sure about this, but have you tried triggering the submit on a window.onload event? I don't think the form is available until the document is fully loaded. I'm sorry I don't have any examples.

Load data into detailed view from list sencha touch 2 MVC

I'm trying to use .setActiveItem to display detailed info on items in a listview (Ext.dataview.List) in a Sencha 2.1 MVC app. The problem is that I can't get the detailed view to load the data.
I've tried many different methods of getting the detailed view to show data including setData, setRecord and Update (see below for some of my latest tries).
Most of the results I keep getting when searching the forums, stackoverflow and google are for sencha apps not using the MVC model.
(Oh, using .push this works fine but due to other reasons I'm moving away from the navigation view).
From my controller:
showDetail: function(list, record) {
/*this.getMain().push({
xtype: 'labdetail',
title: record.fullName(),
data: record.getData()
});*/
//The code above works, but only as long as I stay with navigation view...
console.log("showDetail");
//Ext.getCmp('labdetail').update(record.data);
//LabDetail.update(record.data);
//Ext.fly('labdetail').setData(record.data);
//Ext.getCmp('labdetail').setData(record.data);
//Ext.component('Labblistan.view.LabDetail').destroy();
//Ext.getCmp('Labblistan.view.LabDetail').destroy();
//Ext.fly('labdetail').destroy();
//var DetailView = Ext.create('Labblistan.view.LabDetail'); //If I create the view the console complains I need to destroy previous views with the same ID, hence the different destroy() approaches above
//DetailView.setRecord(record);
Ext.getCmp('mainpanel').setActiveItem('labdetail'); //This navigates to the right view, but it's empty
},
My detailview:
Ext.define('Labblistan.view.LabDetail', {
extend: 'Ext.Panel',
xtype: 'labdetail',
id: 'labdetail',
config: {
title: '{Analysis}',
styleHtmlContent: true,
scrollable: 'vertical',
fullscreen: true,
tpl: [
'<div style=position:absolute;top:50px;><p>Info about {Analysis}</p><p>{Comment}</p></div>'
],
},
});
Don't know if this is best practice but this is how I got it working:
Ext.getCmp('mainpanel').setActiveItem({
xtype: 'labdetail',
title: 'Detaljinformation',
data: record.getData()
});

Sencha Touch 2 link UI element which can be clicked

See attachment, I want the "Forgot password" to be a link instead of a button, but I cant find any Link UI element in Sencha which listen for the click event, doesnt it exist?
You can simply use a component and define the html for it, please see the code below:
{
xtype: 'component',
html: '<a href='+'"http://abc.com"'+ '>Forgot your password?</a>',
}
You can use Sencha routes, e.g.:
Ext.define('MyApp.controller.User', {
extend: 'Ext.app.Controller',
config: {
routes: {
'forgot-password': 'forgotPassword'
}
},
forgotPassword: function() {
// Your code here
}
});
Then you can formulate the link using the route name after a hashtag e.g.:
http://myapp.com#forgot-password
More on routes here: http://docs.sencha.com/touch/2-0/#!/guide/history_support

Sencha Touch 2 : Button to push a new view in a navigationBar of a navigationView

i try to add a button in a navigationBar of a navigationView with possibility to push a new view when i tap the button. I need help because i don't understand how i can do that. My button is ok and i can log tap action in my console but i can't push a new view. I need to have a view which is docked to my tabbar...
What i want in fact is proposing to user the possibility to change the view : with the button he could switch views : navigation / list to carousel (with same datas from a store). All is ok with navigationview and my list of results but i can't add the carousel view possibility by tapping the button...
My first question would be, is it possible ? If yes then how can i do that ?
My code :
Ext.define("MyApp.view.Annuaire", {
extend: 'Ext.navigation.View',
xtype: 'annuairepanel',
requires: [
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store'
],
config: {
/*IMPORTANT : évite une erreur de clsReplace...*/
autoDestroy: false,
title: 'Annuaire',
iconCls: 'address_book',
defaultBackButtonText: 'Retour',
navigationBar: {
items: [
{
xtype: 'button',
id: 'carousel-annuaire',
iconCls: 'more',
iconMask: true,
align: 'right',
listeners: {
'tap': function() {
console.log('tap !');
}
}
}
]
},
items: [
{
xtype: 'list',
id: 'liste-annuaire',
cls: 'x-liste-annuaire',
itemTpl: [
'<div class="vignette-liste" style="background-image:url({_ann_www_pub});"></div>',
'<div class="titre-liste">{post_title}</div>',
'<div class="categories-liste">{categories}</div>'
].join(''),
title: 'Annuaire',
grouped:true,
indexBar:true,
store: 'Annuaires',
}
]
}});
Thanks for your help
Ben
Do you not confusing why NavigationView is used for? The use case for it is create a stacked pool of Panels (Ext.Panel and/or Ext.form.Panel) and do navi.push(view)/navi.pop() to easy navigating in eg. Master-Detail relation.
First it is not intended to add a List as a direct child of the Navi View.
Also the good practice is using of the Sencha MVC Controllers. I'm advising you to start with reading basic concepts in Sencha doc page:
http://docs.sencha.com/touch/2-0/#!/guide/controllers , http://docs.sencha.com/touch/2-0/#!/guide/views and other guides.
I do not say there are perfect Getting Start sources but there is something.
If you want to get more close look at Sencha buy a commercial book.
Tip, never buy Jesus Garcia's books
I'd prefer issues from Packt Publishers.
Cheers, Oleg