odoo/industry#1875

Created by fw-bot
Merged at 69aa4ce4053ed5b705dccfc5427b0758a64dcc48

Statuses:

label
odoo-dev:saas-19.1-19.0-sentry-7339061587-work-items-assh-508561-fw
head
2064a30a48c463b48b2e9f1a79eedd18cc23e4b8
merged
2 weeks ago by Industry, Vallaeys Valentin (vava)
odoo/industry
19.0 #1869
saas-19.1 #1875
saas-19.2 #1876
master #1878

[FIX] construction_developer: mark uom of WI required if no product

Currently, an error occurs when a user creates a work item.

Steps to Reproduce:

  • Install the construction_developer.
  • Go to Sales > Products > Work Items.
  • Create a new record by entering only the name and save.

Error:

ValueError: ValueError('NotNullViolation(\'null value in column "uom_id" of relation "product_template" violates not-null constraint\\n
DETAIL:  Failing row contains (83, 1, null, null, null, null, 2, 2, service, no, null, {"en_US": "sadsa"}, null, null, null, null, 0.0, null, null, f, t, t, t, null, null, null, 2026-03-17 06:18:40.850849, 2026-03-17 06:18:40.850849, null, null, 15, null, {"1": 2}, null, null, null, null, null, null, purchase, null, null, null, manual, no, order, null, null, null, null, null, null, null, 0.9).\\n\') 
while evaluating\n\'for wi in records:\\n    new_product = env[\\\'product.product\\\'].create({\\n        \\\'name\\\': wi.x_name,\\n        \\\'default_code\\\': wi.x_reference,\\n        \\\'type\\\': \\\'service\\\',\\n        \\\'service_policy\\\': "delivered_manual",\\n        \\\'list_price\\\': wi.x_unit_price,\\n        \\\'standard_price\\\': wi.x_unit_cost,\\n        \\\'uom_id\\\': wi.x_unit_custom_id.id,\\n    })\\n    wi.write({\\\'x_product_id\\\': new_product.id})\'') while evaluating
'record.x_unit_cost'

This error occurs because when a product is not set on the work item, a new product
is created using the work item name. During this process, the system tries to assign
uom_id from x_unit_custom_id 1, which is empty if the user has not selected any unit,
causing the error.

This commit ensures that the field x_unit_custom_id is set as required
at the view level.

[2]- https://github.com/odoo/industry/blob/92cd04cc4f35007e232ae1bddafc75a3fe1b4732/construction_developer/data/ir_ui_view.xml#L156

sentry-7339061587

Forward-Port-Of: #1869