Skip to content

[18.0][OU-FIX] product: convert dead type defaults - #6113

Open
rrebollo wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-ou-fix-product-type-defaults
Open

rrebollo wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-ou-fix-product-type-defaults

Conversation

@rrebollo

@rrebollo rrebollo commented Nov 23, 2026 •

Copy link
Copy Markdown

Databases created in v14 may retain ir.default rows for product.template.type = "product", a selection removed in v18. This breaks new product creation. Rewrite those defaults to type = "consu" and is_storable = true in end-migration, after stock is loaded.

@BinhexTeam T26823

@OCA-git-bot OCA-git-bot added mod:openupgrade_scripts Module openupgrade_scripts series:18.0 labels Nov 23, 2026
@rrebollo
rrebollo force-pushed the 18.0-ou-fix-product-type-defaults branch 3 times, most recently from a10d86a to 40d30e4 Compare November 24, 2026 16:25
From 14 to 17, `stock` added 'product' to product.template.type; 18 removed
both the value and the field's meaning, so a DB that still carries a default
for it raises ValueError on every new product:

    ValueError: Wrong value for product.template.type: 'product'

stock/18.0.1.1/pre-migration.py converts the stored rows but leaves the
ir.default entries alone. This rewrites the dead defaults to "consu" and adds
is_storable=true at the same scope.

The script lives in end-migration on purpose: is_storable comes from stock,
whose fields are not reflected yet when product runs its post-migration.

Only rows holding the dead value are selected, so a second run is a no-op.
The test asserts the rewritten values at post_install, once the end scripts
have run.

@sergiocorato sergiocorato left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some non-blocking comments.

Assisted-by: pi.dev/deepseek-v4.1-flash


def test_product_type_defaults(self):
default = self.env["ir.default"]
self.assertEqual(default._get("product.template", "type"), "consu")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you could simply create a product.template and check its type and is_storable field.

partner.property_product_pricelist = pricelist_main
partner.with_company(company).property_product_pricelist = pricelist

env["ir.default"].set("product.template", "type", "product")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a comment to say it's a value set for test with pre-18 behaviour.



@openupgrade_test
@tagged("post_install", "-at_install")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change would modify test's condition of test_pricelist(), it's better to add a new class for the new test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:openupgrade_scripts Module openupgrade_scripts series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants