Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
623 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
0
Okt 21
3373
0
Mei 22
2617
0
Jun 24
1910
1
Nov 23
1515
1
Mar 25
959