Features: 1) Add is_updatable field to Product model with migration; 2) Introduce check_updatable method in AbstractVendor to validate product updatability; 3) Define ProductUnapdatableError for handling non-updatable product logic;

Fixes: none;

Extra: none;
This commit is contained in:
Egor Pavlovich Gorbunov 2025-12-18 21:19:01 +03:00
parent 160b35a591
commit e852d6adf2
3 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,21 @@
# Generated by Django 5.2.9 on 2025-12-18 18:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("core", "0052_alter_stock_system_attributes"),
]
operations = [
migrations.AddField(
model_name="product",
name="is_updatable",
field=models.BooleanField(
default=True,
help_text="indicates whether this product should be updated from periodic task",
verbose_name="is product updatable",
),
),
]

View file

@ -628,6 +628,15 @@ class Product(ExportModelOperationsMixin("product"), NiceModel):
blank=False, blank=False,
null=False, null=False,
) )
is_updatable = BooleanField(
default=True,
help_text=_(
"indicates whether this product should be updated from periodic task"
),
verbose_name=_("is product updatable"),
blank=False,
null=False,
)
name = CharField( name = CharField(
max_length=255, max_length=255,
help_text=_("provide a clear identifying name for the product"), help_text=_("provide a clear identifying name for the product"),

View file

@ -83,6 +83,10 @@ class VendorInactiveError(VendorError):
pass pass
class ProductUnapdatableError(VendorError):
pass
class AbstractVendor: class AbstractVendor:
""" """
Abstract class defining vendor-related operations and handling. Abstract class defining vendor-related operations and handling.
@ -578,6 +582,10 @@ class AbstractVendor:
return av return av
def check_updatable(self, product: Product):
if not product.is_updatable:
raise ProductUnapdatableError("Product %s is not updatable", product.sku)
def update_stock(self) -> None: def update_stock(self) -> None:
pass pass