[FIX] mrp_bom_cost: compute price from bom ensure one fail
[FIX] mrp_bom_cost: compute price from bom ensure one fail

- Activate mrp bom cost.
- Create a BoM for a product
- The Compute "Price from BoM" button appear on the product template
below the Cost field.
- Click the button.

Before this commit:

Probably because dynamic variant creation is activated and there is
no variants, the ensure_one fails with 0 records actually passed to
the function.

Additionally, if all the BoM are for variants and there is no BoM for
the template, then there is a division by 0 exception.

After this commit:

A test is performed to avoid calling the function with 0 records.
A test is performed to avoid a division by 0 exception.

closes odoo/odoo#36761

Opw: 2064884
X-original-commit: 42264002070c8acbb781bd111d8a0c31e2ad9716
Signed-off-by: Nicolas Martinelli (nim) <771435c469f83f6aa9c405ac5e1ed06314a94f2d@odoo.com>

ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo