Odoo 19→20 销售(sale)订单节行新增数量与单位

Odoo 19→20 销售差异 01

结论:Odoo 20 给销售订单的节行加了自己的数量与单位,节不再只是纯文本标题。改节数量会按比例缩放整节明细。

场景

服务报价常按阶段分节,如“实施 3 套”。19 只能在每行明细填数量;20 可直接在节上录数量和单位,一次调整整节。

Odoo 19 的写法

19 的节相关字段只有 parent_id、collapse_prices、collapse_composition,没有数量概念。

# Odoo 19 · sale/models/sale_order_line.py
    # Section-related fields
    parent_id = fields.Many2one(
        string="Parent Section Line",
        comodel_name='sale.order.line',
        compute='_compute_parent_id',
    )  # The section or subsection this line belongs to.
    collapse_prices = fields.Boolean(
        string="Collapse Prices",
        copy=True,
        default=False,
    )  # Whether this section's lines' prices will be hidden in reports and in the portal.

Odoo 20 的写法

20 新增 section_qty 与 section_uom_id(默认 1 与 Units,可编辑存储),并加 _section_fields_null 约束,非节行不许带这两个值。

# Odoo 20 · sale/models/sale_order_line.py
    section_qty = fields.Float(
        string="Section Quantity",
        digits="Product Unit",
        compute="_compute_section_qty",
        precompute=True,
        store=True,
        readonly=False,
    )  # The total quantity of the section
    section_uom_id = fields.Many2one(
        comodel_name="uom.uom",
        string="Section Unit of Measure",
        compute="_compute_section_uom_id",
        precompute=True,
        store=True,
        readonly=False,
    )  # The unit of measure of the section

迁移清单

  1. 检查自有模块是否已有同名 section_qty、section_uom_id,避免冲突。
  2. 批量写 sale.order.line 时非节行不要传这两个字段,否则违反约束。
  3. 自定义 PDF 仅在 section_qty 不等于 1 或单位非默认时显示节数量。
  4. 前端二开注意节行已由 SectionLineRecord 接管,改数量会按比例重算明细。

小结

节行变成带量纲的分组,报价更顺手,升级时记得清洗非节行数据。

关于我们

​我们致力于帮助中小企业实现数字化转型,我们的团队由一群充满激情和创新思维的专业人士组成,他们具备丰富的行业经验和技术专长。

扫一扫获取顾问以及手册

登录 留下评论
Odoo 19→20 采购(purchase)订单行单位字段更名 uom_id
Odoo 19→20 采购差异 01