From 738682e4967a53a0c3e9c3a7a34ad5f4768200f7 Mon Sep 17 00:00:00 2001 From: Aleksandr Meshchriakov Date: Tue, 28 Apr 2026 23:17:32 +0200 Subject: [PATCH] fix(parsers): widen industrial product code fields --- .../0021_widen_industrial_product_codes.py | 31 +++++++++++++++++++ src/apps/parsers/models.py | 4 +-- tests/apps/parsers/test_models.py | 11 +++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/apps/parsers/migrations/0021_widen_industrial_product_codes.py diff --git a/src/apps/parsers/migrations/0021_widen_industrial_product_codes.py b/src/apps/parsers/migrations/0021_widen_industrial_product_codes.py new file mode 100644 index 0000000..99e94a5 --- /dev/null +++ b/src/apps/parsers/migrations/0021_widen_industrial_product_codes.py @@ -0,0 +1,31 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("parsers", "0020_merge_20260428_2300"), + ] + + operations = [ + migrations.AlterField( + model_name="industrialproductrecord", + name="okpd2_code", + field=models.CharField( + blank=True, + help_text="Код по ОКПД2", + max_length=255, + verbose_name="код ОКПД2", + ), + ), + migrations.AlterField( + model_name="industrialproductrecord", + name="tnved_code", + field=models.CharField( + blank=True, + help_text="Код по ТН ВЭД", + max_length=255, + verbose_name="код ТН ВЭД", + ), + ), + ] diff --git a/src/apps/parsers/models.py b/src/apps/parsers/models.py index 71dba17..04d6111 100644 --- a/src/apps/parsers/models.py +++ b/src/apps/parsers/models.py @@ -318,13 +318,13 @@ class IndustrialProductRecord(TimestampMixin, models.Model): ) okpd2_code = models.CharField( _("код ОКПД2"), - max_length=20, + max_length=255, blank=True, help_text=_("Код по ОКПД2"), ) tnved_code = models.CharField( _("код ТН ВЭД"), - max_length=20, + max_length=255, blank=True, help_text=_("Код по ТН ВЭД"), ) diff --git a/tests/apps/parsers/test_models.py b/tests/apps/parsers/test_models.py index 099a2b4..a266024 100644 --- a/tests/apps/parsers/test_models.py +++ b/tests/apps/parsers/test_models.py @@ -199,3 +199,14 @@ class IndustrialProductRecordModelTest(TestCase): self.assertIsNotNone(product.created_at) self.assertIsNotNone(product.updated_at) + + def test_product_codes_allow_source_specific_long_values(self): + """Test source code fields accept official registry combined values.""" + self.assertEqual( + IndustrialProductRecord._meta.get_field("okpd2_code").max_length, + 255, + ) + self.assertEqual( + IndustrialProductRecord._meta.get_field("tnved_code").max_length, + 255, + )