odoo/industry#1869

Created by Ashutosh Sharma (assh)
Merged at 39e55b58e771df2b522e89a70c10ad90e18a4618

Statuses:

label
odoo-dev:19.0-sentry-7339061587-work-items-assh
head
ef5b32295eb0f1eb3aba5719503ea46eee5260b1
merged
1 week 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