You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法编辑Odoo 15.0库存模块stock.picking优先级字段问题排查

问题原因

你仅重写了stock.picking的priority字段,但Odoo 15中PROCUREMENT_PRIORITIES常量定义在stock.move模型里,库存模块的多处业务逻辑(如数据验证、库存预留规则、stock.move与stock.picking的优先级同步)都会直接依赖这个全局常量。原常量仅包含('0', 'Normal'), ('1', 'Urgent'),所以即使你扩展了picking的选项,系统底层验证时仍会判定'2'、'3'为非法值,抛出ValueError。

解决方案

需要同时重写stock.move中的PROCUREMENT_PRIORITIES常量,确保所有依赖该常量的模块逻辑都使用13.0版本的优先级选项,步骤如下:

1. 重写stock.move的优先级常量

在自定义模块的models/stock_move.py中添加以下代码:

# -*- coding: utf-8 -*-
from odoo import models

class StockMove(models.Model):
    _inherit = 'stock.move'

    # 替换为13.0版本的优先级选项
    PROCUREMENT_PRIORITIES = [('0', 'Not urgent'), ('1', 'Normal'), ('2', 'Urgent'), ('3', 'Very Urgent')]

2. 同步更新stock.picking的priority字段

修改models/stock_picking.py,直接引用更新后的常量(保持全局一致性):

# -*- coding: utf-8 -*-
from odoo import fields, models
from odoo.addons.stock.models.stock_move import StockMove

class Picking(models.Model):
    _inherit = 'stock.picking'

    priority = fields.Selection(
        StockMove.PROCUREMENT_PRIORITIES,
        default='1',  # 对应13.0的默认"Normal"
        string='Priority',
        help="Products will be reserved first for the transfers with the highest priorities."
    )

3. 确保模块依赖正确

在自定义模块的__manifest__.py中声明依赖stock模块:

{
    'name': 'Restore Legacy Picking Priorities',
    'version': '15.0.1.0.0',
    'category': 'Inventory',
    'depends': ['stock'],
    'installable': True,
    'auto_install': False,
}

4. 重启服务并升级模块

完成代码修改后,重启Odoo服务,在后台升级你的自定义模块,之后即可正常设置2或3级优先级。

内容的提问来源于stack exchange,提问作者Jerome

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 01:13:59