跳至内容
菜单
此问题已终结
1 回复
3585 查看

I got this function in python :

def picking_lot_scanned(self, barcode):
        self.ensure_one()

        picking_id = self.env['stock.picking'].browse(self.id)
        if picking_id.state in ['draft']:
            lot_id = self.env['stock.production.lot'].search([('name','=',str(barcode))], limit=1)

            if not lot_id:
                raise ValidationError("Le lot/numéro de série {} n'existe pas.".format(barcode))

            if lot_id:
                product_id = lot_id.product_id

                action = self.env.ref('elosys_picking_lot_scanner.action_lot_scanned_qty_wizard').read()[0]
                action['context'] = {
                    'default_picking_id': picking_id.id,
                    'default_product_id': product_id.id,
                }
                return action
        return False

it returns an action of wizard view ,now i want to call this action in a js function , i tried doing this :

odoo.define('ndjma_picking_camera.Nedjma', function(require) {
    "use strict";
$(document).ready(function(){
    let selectedDeviceId;
    var rpc = require('web.rpc');
    var core = require('web.core');
    
    function decodeOnce(codeReader, selectedDeviceId) {
        
        var self = this;

        codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video').then((result) => {
            
            var url = window.location.href;
            url = url.match(new RegExp('id=' + "(.*)" + '&'));
            url = String(url);
            var start_pos = url.indexOf('=') + 1;
            var end_pos = url.indexOf('&', start_pos);
            var id = url.substring(start_pos, end_pos);

            $('input[name="sh_invoice_barcode_mobile"]').val(result.text);
            $('input[name="sh_invoice_barcode_mobile"]').change();

            var barcode = result.text;
            alert(result.text);

            var res = rpc.query({
                model: 'stock.picking',
                method: 'picking_lot_scanned',
                args: [parseInt(id), barcode],
            }).then(function(result) {
                    if (result) {
                        self.do_action(result, {
                            on_close: function () {
                                self.trigger_up('reload');
                            }
                        });
                    }
                });

.......

and i keep getting error self in undefined ,i can't find another solution to this problem Any idea of what could be the problem!


形象
丢弃
最佳答案

Hi

do you find any solution

i need Some Help can you help me ?

形象
丢弃

Hi, is the error coming from .js file of from .py file?

相关帖文 回复 查看 活动
0
12月 20
50
0
12月 15
13164
2
8月 24
6372
1
10月 22
24112
2
9月 21
12798