Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3523 Widoki

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!


Awatar
Odrzuć
Najlepsza odpowiedź

Hi

do you find any solution

i need Some Help can you help me ?

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
0
gru 20
50
0
gru 15
13046
2
sie 24
6256
1
paź 22
23982
2
wrz 21
12665