Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
307 Vistas

I wanna configure a one
When I set this barcode to product 2700002 if I scanned this one  2700002999993
I wanna this be weight 99999 and the last digit 3 is be a number ,
How to configure it ?

Avatar
Descartar
Autor Mejor respuesta

Many Thanks Cybrosys Team🙏

Avatar
Descartar
Mejor respuesta

Hi,

To configure Odoo to interpret your specific barcode format (where a scanned barcode like 2700002999993 for product 2700002 sets the quantity to 99999 and uses the last digit '3' as a specific number), you'll need a custom solution. This involves developing custom barcode scanning logic in Python to intercept the scanning event, extract the product ID, quantity, and last digit from the barcode. The code then updates the product quantity in the relevant operation (like a sales order or inventory transfer) and optionally stores the last digit in a custom field. While Odoo's barcode nomenclature can be used, it's unlikely to be flexible enough for this specific format, making custom code essential.


Here's a breakdown of the steps:


1- Custom Barcode Scanning Logic (Requires Development):


You'll need to create a custom module or modify an existing one to intercept the barcode scanning event. This will involve writing Python code that:from odoo import models, fields, api


class CustomBarcodeHandler(models.Model):

    _inherit = 'stock.picking'  # Or 'sale.order', depending on where you're scanning


    @api.model

    def process_barcode_scan(self, barcode):

        if len(barcode) == 13 and barcode.startswith('2700002'):  # Example format check

            product_id = self.env['product.product'].search([('barcode', '=', barcode[:7])], limit=1)  # Assuming first 7 digits are the product barcode

            if product_id:

                quantity = int(barcode[7:-1])  # Extract quantity (99999)

                last_digit = int(barcode[-1])   # Extract last digit (3)


                # Update the quantity on the current line (example for a stock picking)

                for move_line in self.move_ids_without_package:

                    if move_line.product_id == product_id:

                        move_line.qty_done = quantity

                        # Optionally store the last digit in a custom field

                        move_line.last_digit = last_digit  # Assuming you've added a custom field 'last_digit'


                return {'success': True, 'message': 'Quantity updated from barcode'}

            else:

                return {'success': False, 'message': 'Product not found'}

        else:

            return {'success': False, 'message': 'Invalid barcode format'}

2- Custom Field (Optional):


If you need to store the last digit (3) for further processing, create a custom field on the product.product model or the sale.order.line model. This field could be used to represent a variant, a quality grade, or any other attribute.


3-Barcode Nomenclature (Odoo Configuration):


Go to Inventory > Configuration > Barcode Nomenclature.

Create a new barcode nomenclature or modify an existing one.

You'll need to define a rule that matches your specific barcode format. However, Odoo's built-in barcode nomenclature is unlikely to be flexible enough to handle the extraction of the quantity and the last digit. This is why custom code is necessary.



Hope it helps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
sept 25
697
0
dic 24
18
0
nov 24
3329
0
nov 23
2547
1
feb 23
3307