Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
630 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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)


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
paź 21
3378
0
maj 22
2621
0
cze 24
1912
1
lis 23
1521
1
mar 25
969