Ciao, vorrei lanciare in ambiente Barcode UI la stampa in automatico di un etichetta alla lettura di un codice con lettore.
Prima di creare un modulo ad hoc ho tentato la funzione modificando il file odoo/addons/stock/stock.py
def process_barcode_from_ui(self, cr, uid, picking_id, barcode_str, visible_op_ids, context=None):
'''This function is called each time there barcode scanner reads an input'''
lot_obj = self.pool.get('stock.production.lot')
package_obj = self.pool.get('stock.quant.package')
product_obj = self.pool.get('product.product')
stock_operation_obj = self.pool.get('stock.pack.operation')
stock_location_obj = self.pool.get('stock.location')
answer = {'filter_loc': False, 'operation_id': False}
#check if the barcode correspond to a location
matching_location_ids = stock_location_obj.search(cr, uid, [('loc_barcode', '=', barcode_str)], context=context)
if matching_location_ids:
#if we have a location, return immediatly with the location name
location = stock_location_obj.browse(cr, uid, matching_location_ids[0], context=None)
answer['filter_loc'] = stock_location_obj._name_get(cr, uid, location, context=None)
answer['filter_loc_id'] = matching_location_ids[0]
return answer
#check if the barcode correspond to a product
matching_product_ids = product_obj.search(cr, uid, ['|', ('ean13', '=', barcode_str), ('default_code', '=', barcode_str)], context=context)
if matching_product_ids:
# Inizio test
return self.pool.get('report').get_action(cr, uid, matching_product_ids, 'product.etichetta_29mm', context=context)
# Fine test
Il sistema non genera il report e non restituisce errori anche se la stampa del Qweb report avviene regolarmente se richiamata dal modulo product.
Dove sbaglio?