تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3593 أدوات العرض

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
ديسمبر 20
50
0
ديسمبر 15
13180
2
أغسطس 24
6393
1
أكتوبر 22
24129
2
سبتمبر 21
12820