Odoo Help

2

1
6 Answers
4
Avatar

Temur Georgia

--Temur--

3375
| 7 5 9
Tbilisi, Georgia
--Temur--
Programmer
Temur Georgia
5/27/15, 4:01 AM

you have to remove ids parameter from your function definition, or pass ids from javascript. in first case, your function definition will become:

def mrp_Order(self, cr, uid, context=None): 

-note that ids parameter is NOT present.

otherwise, when you need to have ids parameter in your function, then you've to pass ids from javascript, as first element of argument list, in your case you can pass empty array of ids (but as you don't use ids anyway in your python function, better to use above posted option):

new instance.web.Model("pos.order").call("mrp_Order", [[]]); 

-used array of argument list and it's first element is list of ids, that's going to be value of ids parameter in your python function.


4
Virali India
6/17/15, 2:41 AM

For this you can use:

new instance.web.Model('pos.order').call("mrp_Order",[ [SPECIFY IDS IN LIST] ]);

1
Avatar

Shameem Babu @ iWesabe Saudi Arabia

--Shameem Babu @ iWesabe--
GLOBAL CREATIVE CONCEPTS TECH CO LTD
http://www.iwesabe.com
1600
| 6 3 9
KHOBAR, Saudi Arabia
--Shameem Babu @ iWesabe--

  

 iWesabe - ODOO ERP IMPLEMENTATION & CUSTOMIZATION SAUDI ARABIA.



For Queries : pks.shameem@gmail.com ,shameem@iwesabe.com

Activities     :    Youtube

                           Stackoverflow 

Experience

           iWesabe                                ◉

           Axon Communications        ❍

           Cybrosys Technologies        ❍


Shameem Babu @ iWesabe Saudi Arabia
3/15/17, 7:51 AM


In Javascript

odoo.define('custom_module.my_javascript', function (require) {"use strict"; 
var Model = require('web.Model')

var custom_model = new Model('custom.model')
custom_model.call('my_function')

});

In Python

from odoo import models, fields, api 

class CustomModel(models.Model):
_name = 'custom.model'
     # .............

@api.model
def my_function(self):
        print 'fooooooooooooooo'
Watch this on YouTube !

It is working in Odoo 10


1 Comment
LaoThai Vietnam
12/14/18, 1:45 AM

But not in odoo 11, because Odoo 11 doesn't have web.Model. Any suggest for Odoo 11?

0
Ranga Dharmapriya Sri Lanka
5/27/15, 5:03 AM

 

1 Comment
Temur Georgia
5/27/15, 8:24 AM

interesting... it does nothing? you've had wrong call of python function, I corrected it for you and I think you have no more the error posted in your question. actually you are asking new question on the same thread, that's "how to show popup in pos?" it's a bit different then "Call Python function from JavaScript". I suggest to open new thread with "how to show popup in pos?" title, or something more close to your requirements. because of question asked and error log provided I have not read your code line by line, but I found the source of error. whereas as I see now, after you clarified your requirement to open popup... the problem is that this is not a way to open popup. I investigated your code more deeply, you simply call "mrp_Order" function, but you do nothing with result of this call. you can use such call(and do not handle result in "then()") if it does something at server side and returns nothing, i.e. for "void" functions. but if you've to handle returned value, then you should use "then()" as follows:

new instance.web.Model("pos.order").call("mrp_Order").then(function(result){
        //here result contains whatever is returned from mrp_Oder function, in your case
        //result contains: {'name': "mrpOrder", 'view_mode': 'form', 'view_type': 'form', 'res_model': 'mrp.production', 'type': 'ir.actions.act_window', 'nodestory': True, 'target' : 'new', 'context' : context,}
        //that's all. try this:
        console.log(result)
    }); 
you see? you can do whatever you want with result(returned value) of mrp_Oder function in then() part, but if you expect the mrp_Order to open popup window at client side just because you call it, then I'm afraid to disappoint you, but that's not going to happen.
one more side note, I'm not familiar with pos module but pos is implemented to work independently in case of internet connection interruption. probably adding RPC call can compromise this ability, as RPC can't be done in offline mode. maybe you need something like https://github.com/odoo/odoo/blob/2ac4a3854be846a178972ecc6ee5a6318bce3995/addons/point_of_sale/static/src/js/screens.js#L359-L383 ?
Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now