Add basic model, status enum for PendingProduct

This commit is contained in:
Lance Edgar 2021-11-10 12:38:21 -06:00
parent 7782555078
commit 229f9ab5ed
4 changed files with 134 additions and 1 deletions

View file

@ -0,0 +1,56 @@
# -*- coding: utf-8; -*-
"""add pending_product
Revision ID: 43b9e0a6c14e
Revises: 8856f697902d
Create Date: 2021-11-09 18:08:48.252950
"""
from __future__ import unicode_literals
# revision identifiers, used by Alembic.
revision = '43b9e0a6c14e'
down_revision = '8856f697902d'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import rattail.db.types
def upgrade():
# pending_product
op.create_table('pending_product',
sa.Column('uuid', sa.String(length=32), nullable=False),
sa.Column('user_uuid', sa.String(length=32), nullable=False),
sa.Column('created', sa.DateTime(), nullable=False),
sa.Column('upc', rattail.db.types.GPCType(), nullable=True),
sa.Column('scancode', sa.String(length=14), nullable=True),
sa.Column('item_id', sa.String(length=50), nullable=True),
sa.Column('item_type', sa.Integer(), nullable=True),
sa.Column('department_name', sa.String(length=30), nullable=True),
sa.Column('department_uuid', sa.String(length=32), nullable=True),
sa.Column('brand_name', sa.String(length=100), nullable=True),
sa.Column('brand_uuid', sa.String(length=32), nullable=True),
sa.Column('description', sa.String(length=255), nullable=True),
sa.Column('size', sa.String(length=30), nullable=True),
sa.Column('case_size', sa.Numeric(precision=9, scale=4), nullable=True),
sa.Column('regular_price_amount', sa.Numeric(precision=8, scale=3), nullable=True),
sa.Column('special_order', sa.Boolean(), nullable=True),
sa.Column('notes', sa.Text(), nullable=True),
sa.Column('status_code', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['brand_uuid'], ['brand.uuid'], name='pending_product_fk_brand'),
sa.ForeignKeyConstraint(['department_uuid'], ['department.uuid'], name='pending_product_fk_department'),
sa.ForeignKeyConstraint(['user_uuid'], ['user.uuid'], name='pending_product_fk_user'),
sa.PrimaryKeyConstraint('uuid')
)
def downgrade():
# pending_product
op.drop_table('pending_product')

View file

@ -54,7 +54,7 @@ from .vendors import Vendor, VendorPhoneNumber, VendorEmailAddress, VendorContac
from .products import (UnitOfMeasure, Brand, Tax, Product, ProductImage, ProductCode,
ProductCost, ProductFutureCost, ProductPrice,
ProductInventory, ProductStoreInfo, ProductVolatile,
InventoryAdjustmentReason)
PendingProduct, InventoryAdjustmentReason)
from .ifps import IFPS_PLU
from .purchase import (PurchaseBase, PurchaseItemBase, PurchaseCreditBase,
Purchase, PurchaseItem, PurchaseCredit)

View file

@ -981,6 +981,74 @@ class ProductVolatile(Base):
""")
class PendingProduct(Base):
"""
A "pending" product record, used for new product entry workflow.
"""
__tablename__ = 'pending_product'
__table_args__ = (
sa.ForeignKeyConstraint(['user_uuid'], ['user.uuid'], name='pending_product_fk_user'),
sa.ForeignKeyConstraint(['department_uuid'], ['department.uuid'], name='pending_product_fk_department'),
sa.ForeignKeyConstraint(['brand_uuid'], ['brand.uuid'], name='pending_product_fk_brand'),
)
uuid = uuid_column()
user_uuid = sa.Column(sa.String(length=32), nullable=False)
user = orm.relationship(
'User',
doc="""
Reference to the :class:`~rattail:rattail.db.model.User` who
first entered the record.
""")
created = sa.Column(sa.DateTime(), nullable=False,
default=datetime.datetime.utcnow, doc="""
Timestamp when the record was first created.
""")
# Product fields
upc = sa.Column(GPCType(), nullable=True)
scancode = sa.Column(sa.String(length=14), nullable=True)
item_id = sa.Column(sa.String(length=50), nullable=True)
item_type = sa.Column(sa.Integer(), nullable=True)
department_name = sa.Column(sa.String(length=30), nullable=True)
department_uuid = sa.Column(sa.String(length=32), nullable=True)
department = orm.relationship(Department)
brand_name = sa.Column(sa.String(length=100), nullable=True)
brand_uuid = sa.Column(sa.String(length=32), nullable=True)
brand = orm.relationship(Brand)
description = sa.Column(sa.String(length=255), nullable=True)
size = sa.Column(sa.String(length=30), nullable=True)
case_size = sa.Column(sa.Numeric(precision=9, scale=4), nullable=True)
regular_price_amount = sa.Column(sa.Numeric(precision=8, scale=3), nullable=True)
special_order = sa.Column(sa.Boolean(), nullable=True)
notes = sa.Column(sa.Text(), nullable=True)
# workflow fields
status_code = sa.Column(sa.Integer(), nullable=True, doc="""
Status indicator for the new product record.
""")
@property
def full_description(self):
return make_full_description(self.brand_name,
self.description,
self.size)
def __str__(self):
if six.PY2:
return self.full_description.encode('utf8')
return self.full_description
if six.PY2:
def __unicode__(self):
return self.full_description
@six.python_2_unicode_compatible
class InventoryAdjustmentReason(Base):
"""

View file

@ -249,6 +249,15 @@ PENDING_CUSTOMER_STATUS = OrderedDict([
])
PENDING_PRODUCT_STATUS_PENDING = 1
PENDING_PRODUCT_STATUS_READY = 2
PENDING_PRODUCT_STATUS = OrderedDict([
(PENDING_PRODUCT_STATUS_PENDING, "pending"),
(PENDING_PRODUCT_STATUS_READY, "ready"),
])
PHONE_TYPE_HOME = 'home'
PHONE_TYPE_MOBILE = 'mobile'
PHONE_TYPE_OTHER = 'other'