forked from erp-dev/erp
beta
This commit is contained in:
@@ -244,14 +244,15 @@ def get_production_assignment_for_merchant(*, merchant, assignment_id: int) -> P
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def create_production_assignment(*, merchant, device: Device, content_type: ContentType, object_id: int,
|
||||
def create_production_assignment(*, merchant, device: Device | None = None,
|
||||
content_type: ContentType, object_id: int,
|
||||
assigner, production_quantity: int, assignee=None, created_by=None, operator=None,
|
||||
status: int = ProductionAssignmentStatusEnum.DRAFT, extra=None) -> ProductionAssignment:
|
||||
_assert_employee_belongs_to_merchant(employee=assigner, merchant=merchant, role='指派者')
|
||||
if assignee is not None:
|
||||
_assert_employee_belongs_to_merchant(employee=assignee, merchant=merchant, role='被指派人')
|
||||
_assert_employee_belongs_to_merchant(employee=operator, merchant=merchant, role='操作人')
|
||||
if device.merchant_id != merchant.id:
|
||||
if device is not None and device.merchant_id != merchant.id:
|
||||
raise ValueError('设备不属于当前商户')
|
||||
_validate_content_object_merchant(content_type=content_type, object_id=object_id, merchant=merchant)
|
||||
assignment = ProductionAssignment(
|
||||
@@ -277,7 +278,7 @@ def update_production_assignment(*, assignment: ProductionAssignment, operator,
|
||||
_assert_employee_belongs_to_merchant(employee=operator, merchant=assignment.merchant, role='操作人')
|
||||
assignment.operator = operator
|
||||
if device is not UNSET:
|
||||
if device.merchant_id != assignment.merchant_id:
|
||||
if device is not None and device.merchant_id != assignment.merchant_id:
|
||||
raise ValueError('设备不属于当前商户')
|
||||
assignment.device = device
|
||||
if assignee is not UNSET:
|
||||
|
||||
Reference in New Issue
Block a user