Skip to Content
Menu
This question has been flagged
2 Replies
3509 Views

Hi. 

I'm having trouble importing the bill of materials in version 12 of Odoo. Both the environment with version 11 and 12 are the same.

insert or update on table "mrp_bom_line" violates foreign key constraint "mrp_bom_line_product_id_fkey" DETAIL: Key (product_id)=(19313) is not present in table "product_product". na linha 2


Note. ID 19313 is from the product_template table. The correct ID on product_product table is 9352.

Fields

  • id
  • product_tmpl_id/id
  • product_qty
  • product_uom_id/id
  • active
  • bom_line_ids/product_id/id
  • bom_line_ids/product_qty
  • bom_line_ids/product_uom_id/id

 

help :)

Avatar
Discard

Which field does 19313 appear in? What are the values in your other fields?

Author

The value 19313 is the template ID in the product_template table. I think Odoo instead of looking for the product by the ID (product_id - 9352) is looking for the template ID (product__tmpl_id - 19313). The problem is related to the product of the csv file field -> bom_line_ids / product_id / id.

"id";"product_tmpl_id/id";"product_qty";"product_uom_id/id";"active";"bom_line_ids/product_id/id";"bom_line_ids/product_qty";"bom_line_ids/product_uom_id/id";"BoM Lines/Product"

"mrp_bom_1099";"product.product_1099";"1";"uom.product_uom_unit";"1";"product.product_664";0.738;"uom.product_uom_kgm";"CHAPA DE ACO 1/4"" FF 6,35 MM - 49,848 KG/MT"

I don't see 19313 in your file anywhere. I think you have left out the line with that id in it?? I also don't see 9352 in your file. Can you post the entire file on a filesharing site and link to it?

Author

19313 and 9352 are internal IDs. The External ID is product.product_664

https://pastebin.com/fEEM7zSy

Author

External ID: product.prodcut_664

Internal Product ID: 9352

Internal Template ID: 19313

Author

Note. When i remove "Bom Lines / Component/ External ID" and use the component name on "BoM Lines / Component" Odoo import file.

Author Best Answer

The value 19313 is the template ID in the product_template table. I think Odoo instead of looking for the product by the ID (product_id - 9352) is looking for the template ID (product__tmpl_id - 19313). The problem is related to the product of the csv file field -> bom_line_ids / product_id / id.

"id";"product_tmpl_id/id";"product_qty";"product_uom_id/id";"active";"bom_line_ids/product_id/id";"bom_line_ids/product_qty";"bom_line_ids/product_uom_id/id";"BoM Lines/Product"

"mrp_bom_1099";"product.product_1099";"1";"uom.product_uom_unit";"1";"product.product_664";0.738;"uom.product_uom_kgm";"CHAPA DE ACO 1/4"" FF 6,35 MM - 49,848 KG/MT"


Avatar
Discard