from odoo.tests import Form # Define a new BOM form view bom_form = Form(env, 'mrp.bom') # Set field values bom_form.product_tmpl_id = env.ref('product.product_template_1') bom_form.product_qty = 10 bom_form.product_uom_id = env.ref('uom.product_uom_unit') # Add BOM lines bom_form_lines = bom_form.bom_line_ids bom_form_lines.new(product_id=env.ref('product.product_product_1')) bom_form_lines.new(product_id=env.ref('product.product_product_2')) # Create the BOM record bom_record = bom_form.save()
from odoo.tests import Form # Retrieve an existing BOM record bom_record = env.ref('mrp.bom_1') # Update the BOM form view bom_form = Form(bom_record) bom_form.product_qty = 20 # Save the updated form to update the BOM record bom_form.save()In this example, we retrieve an existing BOM record and then update the product quantity in the form view. We then save the updated form to update the BOM record. Package library: `odoo.tests` package in Odoo.