Skip to Content
Menu
This question has been flagged
4 Replies
5316 Views

I want to change Product Type on a product from "Storable Product" -> "Consumable". However that product has been sold earlier so a warning comes up.


You cannot change the product's type because it is already used in sales orders.

Is there any way to by-pass this restriction? I don't like the idea of creating new duplicate products only because of this minor change.


We are on v14 enterprise.



Avatar
Discard

Hi Rickard,

I think you should use sql statement to update. For example: self.env.cr.execute("""Update product_template set type = 'consu' where id = 1 """)

It's a nice shortcut, it works fine for situations where you don't have to be careful.

So still Inventory Valuation is an issue. It sees the quantity of the consumable product but it doesn't appear in quantity on hand. If you try to do inventory adjustment it dublicates the quantity and eventually the amount.

Best Answer

Hi Rickard,

You can follow these steps to change this data from UI:
Step 1: Go to menu Settings => Technical => Actions => Server Actions (To access this menu you need to enable debug mode by adding the letter "?debug=true" after the word "web" on the address e.g "localhost:8169/web" to "localhost:8169/web?debug=true").
Step 2: Create an action with the following information:
+ Name: Update product type by sql
+ Model: Server Action (or  ir.actions.server)
+ Action To Do: Execute Python Code
+ Python Code: env.cr.execute("""Update product_template set type = 'consu' where id = id_of_product_template """)
Step 3: Click Run button.

P/s: Because I can't edit the comment, I posted an answer so the content is a bit similar.

Avatar
Discard
Author

Hi Thuy
That worked like a charm. Thanks you very much, you made my day :)

Hi Rickard,

I'm happy to hear your issue has been resolved.

Hi Thuy
like Rickard but in reverse, I want to change Product Type on a product from "Consumable" -> "Storable Product".
I tried your solution by copying the code but I got an error message.
I'm a beginner in coding, so I followed your steps and copied your line.
I just modified 'consu' by 'product' and put the name of my product in place of id_of_product_template .
did I make a mistake somewhere?

Hi keredine arif,

If you want to use name property please replace where id = id_of_product_template to where name = 'name_of_product_template'

Thuy, would this still be the same process for v.17?

Thanks you for your help and you make me happy bro

Best Answer

Hi good people, I have the same query but need to change from Consumable --> Storable - could you please let me know what they python code line should now look like?

eg. 

+ Python Code: env.cr.execute("""Update product_template set type = 'storable' where id = id_of_product_template """)

My confusion is exactly what value to set the type to.

Thank you very much.

Avatar
Discard

Ahh - sorted it out - I now know that I need to set type = 'product'.
Used and it works well.

Author Best Answer

Thanks for your help Thuy.

Unfortunately  I do not have access to the database so I can't try that out. I was hoping there was a way to change this data from UI or studio.

I can't understand why there is such a restriction on this field. In my experience this is a field that is quite often changed on products over time.

Avatar
Discard

Hi Rickard,

You can follow these steps to change this data from UI:
Step 1: Go to menu Settings => Technical => Actions => Server Actions.
Step 2: Create an action with the following information:
+ Name: Update product type
+ Model: Server Action
+ Action To Do: Execute Python Code
+ Python Code: env.cr.execute("""Update product_template set type = 'consu' where id = id_of_product_template """)
Step 3: Click Run.

Best Answer

I'd buy you a beer if you had a solution.

I've had this case several times and each time I've created a duplicate - corrected it and archived the old one. Terribly tedious. The same thing happens with the product category, by the way. I understand the reason why this is not easy to do (e.g. valuation of stock), but it's still stupid.


@Thuy: What beer you prefer? Many thanks, will test it.

Avatar
Discard
Author

Hi Thomas
You can send a beer to Mr Thuy, he solved it for us ;)

Hi Thomas,
I'm in Vietnam so it's hard to receive beer from you. I'm glad it was of help to you.

Related Posts Replies Views Activity
2
May 24
4542
1
Oct 24
21456
2
May 22
1899
0
Jan 22
3565
1
Oct 21
342