Skip to Content
Menu
This question has been flagged
1 Reply
562 Views

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
Discard
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
Discard
Related Posts Replies Views Activity
0
Oct 21
3345
0
May 22
2535
0
Jun 24
1851
1
Nov 23
1445
1
Mar 25
896