This question has been flagged
4 Replies
2500 Views

If i create a product for sale with a UoM, after i create a Bill of Materials, the BoM will assume the product's UoM. But... i can the product's UoM. If i do that, and add the product to a quote, when i confirm the quote, i get an error, and it can be hard to track. Sometimes i have more than 50 products in a quotation.

Is there a way to prevent changing a product's UoM after creating the BoM, thus preventing the error?

It doesn't make sense that one can change back the UoM after the BoM is created.

Avatar
Discard

It might now make sense to you, that doesn't mean it is not something other users have requested from us.

Why are you changing the Product UoM? 

A Bill of Materials isn't "completed" like other kinds of records in Odoo - so is more challenging to define "after the BoM is created" in Odoo. 

You can setup an Automated Action that triggers ON UPDATE of the Bill of Materials and prevents Users from saving the BoM if there is a change to the Unit of Measure. 

This will prevent BoM's from evolving over time though.  If you learn how to make a product in larger quantities (normally happens as you grow your company) you will need a new BoM for the new Unit of Measure and will now need to choose which BoM to use on a Manufacturing Order (or delete the old one).  This creates extra work downstream.

So ... back to the start ... Why are you changing the Product UoM? 

You cannot change the UoM after you buy, make or sell the product but you CAN before hand. You can always setup an automated action that prevents a UoM change in any situation after a Bill of Materials is created - requiring you to delete all BoM's before doing so.

Author

Hello again Ray. Can't comment on your reply...

Sorry i took so long to reply.... Quarantine happened. Oh well...

I can only guess that the guys responsible for registering the products changed the UoM because they selected a wrong one the first time.

All my products for sale are basically one of-a-kind. I hardly make the same product twice, so preventing the BoM from changing wouldn't be a problem. But... my problem is to prevent the users from changing the product's UoM after que BoM is created. Because if i change the UoM of a product that is already in a quote, i get an error when confirming the quote, which prevents me from generating purchase requests, manufacturing orders, etc.

Is this possible?

Best Answer

Create the following Automated Action, or one like it (I quickly tested and it seemed to work):


for record in records:
raise Warning("You cannot change the UoM of this product until you delete the BoM!")
Avatar
Discard
Author

Thanks again Ray. Almost there... however, this way doesn't check if the BoM already exists. So whether the BoM exists or not, the warning will appear.

Add this in the before Update Domain

Author

Great! I made it On Update only, removed Routes and added BoM Is Defined in before Update Domain.

Works a treat!

Thank you so much Ray!