从javascript调用python函数

时间:2015-05-27 05:12:52

标签: javascript python-2.7 odoo odoo-8

我在pos视图中为视图mrp生成表单创建了名为mrp_Order的函数,并在单击req按钮时调用此函数。 但我得到了这个错误。

Odoo Server Error
Traceback (most recent call last):
File "D:\Odoo\odoo-v8-osm\openerp\http.py", line 530, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "D:\Odoo\odoo-v8-osm\openerp\http.py", line 567, in dispatch
result = self._call_function(**self.params)
File "D:\Odoo\odoo-v8-osm\openerp\http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "D:\Odoo\odoo-v8-osm\openerp\service\model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "D:\Odoo\odoo-v8-osm\openerp\http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "D:\Odoo\odoo-v8-osm\openerp\http.py", line 796, in __call__
return self.method(*args, **kw)
File "D:\Odoo\odoo-v8-osm\openerp\http.py", line 396, in response_wrap
response = f(*args, **kw)
File "D:\Odoo\odoo-v8-osm\addons\web\controllers\main.py", line 935, in      call_kw
return self._call_kw(model, method, args, kwargs)
File "D:\Odoo\odoo-v8-osm\addons\web\controllers\main.py", line 927, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "D:\Odoo\odoo-v8-osm\openerp\api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
TypeError: mrp_Order() takes at least 4 arguments (3 given)

如何解决此错误?

Python代码

            def mrp_Order(self, cr, uid, ids, context=None):
                result = {
                    'name': "mrpOrder",
                    'view_mode': 'form',
                    'view_type': 'form',
                    'res_model': 'mrp.production',
                    'type': 'ir.actions.act_window',
                    'nodestory': True,
                    'target' : 'new',
                    'context' : context,
               }
               return result

JavaScript代码

            function openerp_restaurant_reqbill(instance,module){
                var QWeb = instance.web.qweb;
                var _t = instance.web._t;

                module.PosWidget.include({
                    build_widgets: function(){
                        var self = this;
                        this._super();

                        if(this.pos.config.iface_raqbill){
                            var reqbill = $(QWeb.render('PrintReqButton'));

                            reqbill.click(function(){
                                var order = self.pos.get('selectedOrder');

                                if(order.get('orderLines').models.length > 0){
                                    var receipt = order.export_for_printing();
                                    self.pos.proxy.print_receipt(QWeb.render('BillReceipts',{
                                        receipt: receipt, widget: self,
                                    }));
                                }
                                new instance.web.Model("pos.order").call("mrp_Order");
                            });

                            reqbill.appendTo(this.$('.control-buttons'));
                            this.$('.control-buttons').removeClass('oe_hidden');

                        }

                    },

                });

            }

*

0 个答案:

没有答案