Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    • Referral Program
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Change "Product Type" after a product has been sold.

Subscribe

Get notified when there's activity on this post

This question has been flagged
restrictionwarningoverridev14
5 Replies
10291 Views
Avatar
Rickard Wallster

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.



0
Avatar
Discard
Thuy Ngoc

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 """)

Sergio Serrano Lloret

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

Moustafa Ebada - SPOC

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.

Avatar
Thuy Ngoc
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.

4
Avatar
Discard
Rickard Wallster
Author

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

Thuy Ngoc

Hi Rickard,

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

keredine arif

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?

Thuy Ngoc

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'

Ewizz DevA, Adrian Ewizz Dev

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

Myat Thet Htwe

Thanks you for your help and you make me happy bro

Avatar
fz
Best Answer

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

0
Avatar
Discard
Avatar
Michael Murray
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.

0
Avatar
Discard
Michael Murray

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

Avatar
Rickard Wallster
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.

0
Avatar
Discard
Thuy Ngoc

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.

Avatar
Dr. Thomas Koliwer
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.

0
Avatar
Discard
Rickard Wallster
Author

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

Thuy Ngoc

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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
odoo 14: override controller to add more fields in Odoo SignUp form Solved
override controllers v14
Avatar
Avatar
Avatar
2
May 24
7149
Warning on Odoo 14 with track_visibility Solved
code models warning v14
Avatar
Avatar
1
Oct 24
24880
How to override "_title_changed" function in Web?
webclient javascript override v14
Avatar
Avatar
2
May 22
4023
Odoo method override order explained
sale.order stock.move override v14
Avatar
0
Jan 22
5744
override onchange function Solved
onchange override Odoo13.0 v14
Avatar
1
Oct 21
342
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now