fix(shipping-notice): 通知准备就地编辑放宽OT实体守卫

- 根因:update-notice-line 等四个编辑路由挂 _require_formal_notice,
  通知准备阶段(Notice 未建)行内编辑必报 FORMAL_NOTICE_REQUIRED
- 新增 _require_editable_task:Notice/OT 均可进入编辑写路径,
  权限仍由服务层状态制闸门裁决(Excel 冻结+忙碌锁+Schema 反向锁)
- 覆盖 update-notice-fields/update-notice-line/add/remove 四路由;
  confirm-uploaded 与 export 保持正式 Notice 严格守卫
- 新增 OT 无 Notice 就地编辑全链路测试(编辑→有效视图→重匹配口径)
This commit is contained in:
hugo committed 2026-09-18 16:05:54 +08:00
1 parent f57bfc3bee
commit 95488db656
2 files changed
+53 -4

No files matched your search

+19 -4
View File
@@ -154,6 +154,21 @@ def _require_formal_notice(task: Any) -> ShippingNotice:
return task
def _require_editable_task(task: Any) -> Any:
"""订单编辑写接口的实体守卫:正式 Notice 或建单前 OT 均可。
核心逻辑:订单字段/行的编辑权限由服务层状态制闸门裁决
(Excel ready 硬冻结 + 活动 Attempt 忙碌锁 + Schema 反向锁),
与实体类型无关——通知准备阶段(Notice 未建)编辑履约字段是受支持场景。
"""
if not isinstance(task, (ShippingNotice, ShippingOrderTask)):
raise ValidationError(
'Formal shipping notice is required for this operation',
code='SHIPPING.FORMAL_NOTICE_REQUIRED',
)
return task
@workspace_shipping_notice_bp.route('/shipping-tasks', methods=['GET'])
def workspace_shipping_tasks():
"""分页列出当前用户可见的发货任务,可按处理状态过滤。"""
@@ -660,7 +675,7 @@ def workspace_update_shipping_notice_fields(task_no: str):
task = get_task_for_user(task_no, user.id)
if not task:
raise NotFoundError('Not found')
task = _require_formal_notice(task)
task = _require_editable_task(task)
data = request.get_json(silent=True) or {}
fields = data.get('fields')
if not isinstance(fields, dict) or not fields:
@@ -707,7 +722,7 @@ def workspace_update_shipping_notice_line(task_no: str):
task = get_task_for_user(task_no, user.id)
if not task:
raise NotFoundError('Not found')
task = _require_formal_notice(task)
task = _require_editable_task(task)
data = request.get_json(silent=True) or {}
try:
line_index = int(data.get('line_index'))
@@ -796,7 +811,7 @@ def workspace_add_shipping_notice_line(task_no: str):
task = get_task_for_user(task_no, user.id)
if not task:
raise NotFoundError('Not found')
task = _require_formal_notice(task)
task = _require_editable_task(task)
data = request.get_json(silent=True) or {}
line = data.get('line')
if not isinstance(line, dict) or not line:
@@ -822,7 +837,7 @@ def workspace_remove_shipping_notice_line(task_no: str):
task = get_task_for_user(task_no, user.id)
if not task:
raise NotFoundError('Not found')
task = _require_formal_notice(task)
task = _require_editable_task(task)
data = request.get_json(silent=True) or {}
try:
line_index = int(data.get('line_index'))