Odoo 19→20 产品(product)is_storable 字段下沉 stock→product

Odoo 19→20 Product Differences 01

Odoo 20 moves is_storable from the stock module to the product module, and renames the compute method to _compute_is_storable.The field name stays the same, but its ownership and the method name have changed, so override points must be updated.

Scene

Custom developments often inherit product.template in the stock module, override the computation that tracks inventory, or use is_storable to filter and build dashboards. Once the ownership or method name changes, the override no longer applies after an upgrade.

How it looks in Odoo 19

In 19, both the field and the compute method are in the stock module, compute points to compute_is_storable, and the method has no underscore prefix.

# Odoo 19 · stock/models/product.py
    is_storable = fields.Boolean(
        'Track Inventory', store=True, compute='compute_is_storable', readonly=False,
        default=False, precompute=True, tracking=True, help='A storable product is a product for which you manage stock.')

    @api.depends('type')
    def compute_is_storable(self):
        self.filtered(lambda t: t.type != 'consu' and t.is_storable).is_storable = False

How it looks in Odoo 20

In 20, the field has moved to the product module and the method is renamed to _compute_is_storable, so modules that depend only on product can use it directly.

# Odoo 20 · product/models/product_template.py
    is_storable = fields.Boolean(
        'Track Inventory', store=True, compute='_compute_is_storable', readonly=False,
        default=False, precompute=True, tracking=True,
        help='A storable product is a product for which you manage stock.')

    @api.depends('type')
    def _compute_is_storable(self):
        self.filtered(lambda t: t.type != 'consu' and t.is_storable).is_storable = False

Migration checklist

  1. Change inheritance that overrides compute_is_storable to _compute_is_storable.
  2. Modules that depend only on product can use is_storable directly, with no need to depend on stock.
  3. The is_storable field name in search domains and views is unchanged, so no changes are needed.
  4. Run migration scripts that filter by is_storable after stock is installed.
  5. Regression-test the track inventory product computation and dashboards.

Summary

Module ownership has moved down a layer and the method has been renamed, while the field name remains stable. The key point is that override points and dependency declarations must be adjusted accordingly.

关于我们

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

扫一扫获取顾问以及手册

Sign in to leave a comment
Odoo 19→20 Accounting (account) payment state machine refactor: in_process changed to reconciled
Odoo 19→20 Accounting Differences 01