feat: article now is not required
This commit is contained in:
		@@ -8,7 +8,7 @@ class Product(BaseModel):
 | 
			
		||||
    __tablename__ = 'products'
 | 
			
		||||
    id = Column(Integer, autoincrement=True, primary_key=True, index=True)
 | 
			
		||||
    name = Column(String, nullable=False, index=True)
 | 
			
		||||
    article = Column(String, nullable=False, index=True)
 | 
			
		||||
    article = Column(String, nullable=False, default='', server_default='', index=True)
 | 
			
		||||
 | 
			
		||||
    client_id = Column(Integer, ForeignKey('clients.id'), nullable=False, comment='ID сделки')
 | 
			
		||||
    client = relationship('Client', back_populates='products')
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ from models import ProductBarcode
 | 
			
		||||
# region Entities
 | 
			
		||||
class BaseProductSchema(CustomModelCamel):
 | 
			
		||||
    name: str
 | 
			
		||||
    article: str
 | 
			
		||||
    article: str | None = ''
 | 
			
		||||
    client_id: int
 | 
			
		||||
    barcodes: list[str]
 | 
			
		||||
    barcode_template: BarcodeTemplateSchema | None = None
 | 
			
		||||
 
 | 
			
		||||
@@ -14,14 +14,14 @@ class ProductService(BaseService):
 | 
			
		||||
 | 
			
		||||
    async def create(self, request: ProductCreateRequest) -> ProductCreateResponse:
 | 
			
		||||
        # Unique article validation
 | 
			
		||||
        existing_product_query = await self.session.execute(
 | 
			
		||||
            select(Product)
 | 
			
		||||
            .where(Product.client_id == request.client_id,
 | 
			
		||||
                   Product.article == request.article)
 | 
			
		||||
        )
 | 
			
		||||
        existing_product = existing_product_query.first()
 | 
			
		||||
        if existing_product:
 | 
			
		||||
            return ProductCreateResponse(ok=False, message='Товар с таким артикулом уже существует у клиента')
 | 
			
		||||
        # existing_product_query = await self.session.execute(
 | 
			
		||||
        #     select(Product)
 | 
			
		||||
        #     .where(Product.client_id == request.client_id,
 | 
			
		||||
        #            Product.article == request.article)
 | 
			
		||||
        # )
 | 
			
		||||
        # existing_product = existing_product_query.first()
 | 
			
		||||
        # if existing_product:
 | 
			
		||||
        #     return ProductCreateResponse(ok=False, message='Товар с таким артикулом уже существует у клиента')
 | 
			
		||||
 | 
			
		||||
        # Creating product
 | 
			
		||||
        product_dict = request.dict()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user