Skip to Content
Menú
This question has been flagged
3 Respostes
1284 Vistes

Hi, 

I'm trying to create a new field for a list view that simply multiplies the "shipping_weight" field by 0.4536


Reason is that I have 2 businesses on the database, no.1 primarily uses pounds as the weight and no.2 uses Kg. 
Unfortunately Odoo doesn't allow each company to use a different primary UoM.
When arranging freight for company no.2 its in Kg with the haulier so I just want to multiply the "shipping_weight" * 0.4536 to roughly convert Lb to Kg.


I have created a floating field in studio called "x_studio_weight_kg_1" and thought it would be something simple in the compute field like;
result = shipping_weight * 0.45359 
or
for record in self: 

                        record[x_studio_weight_kg_1] = shipping_weight * 0.45359

but evidently its something else, any help would be appreciated.

Avatar
Descartar
Best Answer

you are missing the "record." when getting the  shipping_weight 


try this:

for rec in self:

    rec['x_studio_new_shiping_weight'] = rec.shipping_weight * 0.45359



Avatar
Descartar
Autor Best Answer

perfect, thanks for your help. :)

Avatar
Descartar
Best Answer

Hello Raphael,

In the computed field formula, enter the following code:

for record in self:
    record['x_studio_weight_kg_1'] = record['shipping_weight'] * 0.4536

Make sure to add the x_studio_weight_kg_1 field to the list/form view to ensure the conversion is reflected correctly. Also, don't forget to set shipping_weight as a dependency for the x_studio_weight_kg_1 field, so it updates automatically when the shipping weight changes.

This will correctly compute the weight in kilograms by multiplying the shipping_weight by 0.4536.

I have attached a screenshot for your reference to help clarify the setup.



Let me know, if it helps :)

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
d’oct. 23
3891
0
de juny 22
23
4
de juny 25
3526
0
de des. 23
1248
0
de nov. 23
1203