Ir al contenido
Menú
Se marcó esta pregunta
5 Respuestas
7390 Vistas

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
Descartar

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.

Mejor respuesta

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
Descartar
Autor

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

Mejor respuesta

Thank you Thuy for guiding in the right direction. I'm on v18 and I had to use "set is_storable=FALSE"

Avatar
Descartar
Mejor respuesta

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
Descartar

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

Autor Mejor respuesta

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
Descartar

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.

Mejor respuesta

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
Descartar
Autor

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.

Publicaciones relacionadas Respuestas Vistas Actividad
2
may 24
5222
1
oct 24
22414
2
may 22
2417
0
ene 22
4077
1
oct 21
342