Skip to Content
Menú
This question has been flagged
1 Respondre
597 Vistes

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
Best Answer

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
Related Posts Respostes Vistes Activitat
0
d’oct. 21
3365
0
de maig 22
2587
0
de juny 24
1887
1
de nov. 23
1470
1
de març 25
938