Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Pass data to Window Action to create a new product

By
Habib
on 2/18/15, 3:56 AM 772 views

I'm creating a google map module which allows a user to create a product by right-clicking the map

the right click event is caught and fires the following:

dispatchNewProductAction: function() {

console.log('called dispatch action');

this.do_action({

type: 'ir.actions.act_window',

res_model: "product.template",

views: [[false, 'form']],

context: {}

});

},

The product form view is displayed... How can I pass the co-ordinates into the form view?

Another question... If I use

target: 'new'

the save button is no longer available, how can I allow the popup form to save a new product record?

1
Habib
On 2/18/15, 4:32 AM

I have managed to pass data using the context field, but the model property needs to be prepended with the word "default_"

dispatchNewProductAction: function(lat, long) {

console.log('called dispatch action');

this.do_action({

type: 'ir.actions.act_window',

res_model: "product.template",

views: [[false, 'form']],

context: {'default_latitude': lat, 'default_longitude': long}

});

},

1
Samuel Lefever
On 2/18/15, 4:43 AM

To pass default data in create form view, you have to prepend fields name with "default_".

For the target="new" save problem, you have to manage the buttons yourself when you use that type of target.
Add a button that call an action on your object to save the information.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 2/18/15, 3:56 AM
Seen: 772 times
Last updated: 4/14/15, 8:11 AM