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
    • Approvals
    • 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
    • Estate 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
    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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
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

Selection Field Options Disappear from Database (PostgreSQL enum) on Module Upgrade

Subscribe

Get notified when there's activity on this post

This question has been flagged
v17
1277 Views
Avatar
Xi Ansen

Hello Odoo Community,

I'm encountering a very strange issue in Odoo 17 regarding a Selection field that loses its options in the database schema under specific upgrade scenarios. I would appreciate any insights or suggestions.

My Goal & Implementation

My goal is to add a consistent workflow state field (kanban_state) to many models that already use mail.thread and mail.activity.mixin (like sale.order, purchase.order, etc.).

To avoid creating a new mixin and manually adding it to dozens of models, I chose to inherit the core mail.activity.mixin and inject my new field there. This way, any model that is "chatter-enabled" automatically gets my workflow capabilities.

Here is the code for my mixin:

code

Python

# In my custom module: my_workflow_mixin/models/mail_activity_mixin.py


from odoo import fields, models


class MailActivityMixin(models.AbstractModel):

_name = 'mail.activity.mixin'

_inherit = 'mail.activity.mixin'

_description = 'Enhance native Activity Mixin with workflow capabilities'


kanban_state = fields.Selection([

('draft', 'Draft'),

('to_approve', 'To Approve'),

('approved', 'Approved'),

('rejected', 'Rejected')

], string='Kanban State', default='draft', tracking=True, copy=False,

help="A visual state field for use in kanban views and status bars.")

The Strange Problem

The issue arises with models that inherit this mixin, for example, sale.order.

Initial State: After installing my module (my_workflow_mixin), everything works correctly. The kanban_state field appears in the sale.order model, and in the PostgreSQL database, the sale_order table has a kanban_state column with the correct enum type and its four defined options.

Problem Occurs: After a server restart and an upgrade of another module (or sometimes after just upgrading my own module again after making a small change), I find that the selection options for kanban_state have disappeared from the sale_order table in the database. When I inspect the column type in PostgreSQL, the enum is empty. This causes errors in the UI as the values no longer match a valid selection.

Temporary Fix: If I run a full database update for all modules using the command line: ./odoo-bin -u all -d my_database, the selection options reappear correctly in the database schema for the sale_order table. The enum is repopulated.

Problem Reappears: However, if I then make a change to my my_workflow_mixin module and upgrade only this module (./odoo-bin -u my_workflow_mixin -d my_database), the problem comes back! The selection options are once again wiped from the sale_order table's enum type.

My Hypothesis and Questions

It seems like the module loading order and the scope of the update (-u my_module vs. -u all) are causing the Odoo ORM to incorrectly update the PostgreSQL enum type. When only my module is updated, the ORM seems to forget that other models like sale.order depend on this modified mixin, and it fails to propagate the schema changes correctly. The -u all command forces a re-evaluation of the entire model registry in the correct dependency order, which fixes it temporarily.

Has anyone encountered this behavior before?

Is inheriting a core Odoo mixin like mail.activity.mixin to add fields considered bad practice, and could it be the root cause of these ORM inconsistencies?

Is this a potential bug in the Odoo 17 ORM regarding how it handles schema updates for inherited models?

Any help would be greatly appreciated. Thank you!


0
Avatar
Discard
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
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Avatar
Avatar
1
Oct 25
1324
How to add a new Many2one field in res.config.settings? Solved
v17
Avatar
Avatar
Avatar
Avatar
4
Oct 25
3724
Add field to ALL models in Odoo
v17
Avatar
Avatar
Avatar
2
Sep 25
2398
How to disable Email notification - You have been assigned to Solved
v17
Avatar
Avatar
Avatar
Avatar
4
Sep 25
7787
How to get the active_id from get_view function in odoo 17?
v17
Avatar
Avatar
Avatar
Avatar
Avatar
4
May 25
4560
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 ภาษาไทย 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