Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
566 Vistas

I'm working with GS1 barcodes that include a pack date using the (13) Application Identifier. In my system, when I scan a barcode with the structure (01)xxxxxxxxx(13)250228(10)xxxxxx, I expect the date '28/02/2025' to be automatically recorded as the pack date for the packaged item.

However, this isn't happening. The system seems to be reading the GTIN and batch number correctly, but it's not extracting or setting the pack date from the '(13)250228' segment.

I'm looking for guidance on how to configure my system (potentially Odoo, but could be another packaging/inventory system) to properly interpret the (13) AI and set the corresponding date as the pack date. Any insights, suggestions for settings to check, or potential workarounds would be very helpful.

Avatar
Descartar
Mejor respuesta

Hii,

Create a custom field on stock.production.lot (e.g., x_pack_date).

Override the barcode scanning method in your picking or lot creation to:

  • Parse the scanned barcode string with a simple regex to extract (13)YYMMDD.
  • Convert that to a date.
  • Write that date into x_pack_date on the lot.

Minimal example snippet (Python):


import re

from datetime import datetime

from odoo import models, api


class StockProductionLot(models.Model):

    _inherit = 'stock.production.lot'


    x_pack_date = fields.Date(string='Pack Date')


    @api.model

    def create_from_barcode(self, barcode):

        # Simple GS1 (13) date extraction

        match = re.search(r'\(13\)(\d{6})', barcode)

        pack_date = False

        if match:

            pack_date = datetime.strptime(match.group(1), '%y%m%d').date()


        vals = {

            'name': 'New Lot',

            'x_pack_date': pack_date,

        }

        return self.create(vals)


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
oct 21
3348
0
may 22
2539
0
jun 24
1856
1
nov 23
1453
1
mar 25
897