Odooers论坛

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Product weight calculation based on BoM

1 备注
形象
丢弃
形象
odoo
-

4 years later and I am faced with the same question, maybe it is badly elaborated:
So let's go:
in a product with a BOM and a manufacturing route, can I not obtain the weight and, why not, also the volume automatically?
product C Weight = component A + component B weight
is it so hard to automatically calculate and provide this information in an integrated system?

6 答案
0
形象
odoo
最佳答案

There is no law of conservation of mass in Odoo manufacturing :) 

If your UoM of every product is Kg here then you take care of it while creating products/ BoM. But if you are working through different units and still want to act on "law of conservation of weight" you've got to figure out a customized solution or consult an expert.

Thanks

Vishal

1 备注
形象
丢弃
形象
odoo
-

Thanks, but why the system does not sum all the BOM products weights automatically?

0
形象
odoo
最佳答案

I have slightly improved the code by inserting UOM conversion


for product in records:

    bom = product.bom_ids and product.bom_ids[0] or False

    if not bom:

        continue

    bom_lines = bom.bom_line_ids

    if not bom_lines:

        continue

    total_weight = 0.0

    for line in bom_lines:

        component = line.product_id

        component_uom=component.uom_id.relative_factor

        quantity = line.product_qty  # Quantity in units

        line_uom = line.product_uom_id.relative_factor

        component_weight = component.weight or 0.0  # Weight in kg

        weight_contribution = line_uom/component_uom * component_weight * quantity

        total_weight += weight_contribution

    product.write({'weight': total_weight})


形象
丢弃
0
形象
odoo
最佳答案

Hello Ricardo,



  Odoo doesn't automatically calculate and update the weight of a manufactured product based on its Bill of Materials (BoM) components. This is because the system treats each product's weight as an independent attribute, primarily for simplicity and performance reasons. However, you can achieve your goal through customization or by implementing a module that extends the Manufacturing app's capabilities. Here are the steps to manually update the weight for a manufactured product:

  1. Go to the Manufacturing app and select the product you are working with.

  2. Calculate the total weight of the product manually by adding the weights of all components listed in the BoM.

  3. Update the product's weight in the Inventory tab under the product form.

  4. Ensure that the delivery slip template is configured to display the product weight. This might require adjusting the report template if it's not showing by default.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

形象
丢弃
0
形象
odoo
最佳答案

A simple solution to this question could be the creation of the following server action (image from Odoo version 18):

hope it helps!

code:

for product in records:
    bom = product.bom_ids and product.bom_ids[0] or False
    if not bom:
        continue
    bom_lines = bom.bom_line_ids
    if not bom_lines:
        continue
    total_weight = 0.0
    for line in bom_lines:
        component = line.product_id
        quantity = line.product_qty  # Quantity in units
        component_weight = component.weight or 0.0  # Weight in kg
        weight_contribution = component_weight * quantity
        total_weight += weight_contribution
    product.write({'weight': total_weight})
   
形象
丢弃
0
形象
odoo
最佳答案

Hi,

You can check this community module : https://www.odoo.com/apps/modules/10.0/product_weight/

This will help you to get the weight of a product as the sum of its component products. Have a look at the module.


Then regarding the weight in delivery slip you can inherit the report template and access the weight of the product from the product master and add to it.


Thanks

形象
丢弃
0
形象
odoo
最佳答案

Thanks for the reply, but I still have not found a solution for Odoo 11

形象
丢弃