lunch_is_favorite
Nine lines of code that exist for one reason: Odoo's lunch menu kanban is declared non-editable, and the favorite star still has to work.
| Technical name | lunch_is_favorite |
|---|---|
| Field types | boolean |
| Views | kanban, list, form |
| Module | lunch |
| Used in core | 1 occurrence, the lunch menu kanban card in lunch |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0 |
| No-code setup | No. Studio cannot set this widget, and the behavior only matters on a non-editable view |
| Alternatives | boolean_favorite, boolean_toggle, priority |
What the lunch favorite field does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
autosave | boolean | Inherited from the favorite-star widget. When true, clicking the star saves the record immediately instead of leaving it dirty. Core relies on the default, because a kanban card has no save button.(default: true) |
Read-only behaves differently here, and that is the entire widget. The base star reads the evaluated read-only state, which accounts for the view, the record and any readonly expression. This one reads the raw readonly attribute and coerces it with a boolean cast, so a non-empty attribute value of any kind, including the string 0, makes the star read-only, and the absence of the attribute makes it editable no matter what the surrounding view says.
Working examples
One replaced prop, and the coercion it introduces
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Byte-identical to Odoo 19 on the development branch. |
| Odoo 19.0 | Verified | Verified against the shipped source. Identical to Odoo 18. |
| Odoo 18.0 | Verified | First version. Same descriptor override. |
| Odoo 17.0 | Not available | Widget does not exist. |
| Odoo 16.0 | Not available | Widget does not exist. |
Upgrade note. The widget arrived in Odoo 18, and the Odoo 18, Odoo 19 and development-branch files are identical, so nothing needs attention on upgrade. On Odoo 17 and earlier the lunch kanban used a different arrangement; backporting the widget is trivial, since the whole file is nine lines.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| The star is frozen even though there is no readonly expression in effect | A readonly attribute is present on the field element. Its value is never evaluated, only cast to a boolean, so even readonly="0" locks it. Remove the readonly attribute entirely from the field element. |
| The star is clickable on a record the user should not touch | Intended behavior. The widget ignores the evaluated read-only state. Enforce the restriction with access rights or a record rule; the interface is not the control point here. |
| Clicking the star does not persist | autosave was turned off and the view has no save action. Remove 'autosave': False, or move the field to a view with a save button. |
| Missing widget error in the log | The lunch module is not installed in that database. Install lunch, or use the base boolean_favorite widget instead. |
| The star column is too narrow in a list | The base widget sets a 20 pixel column width when the field has no label. Give the column a label, or set a width on the list column. |
| The star does not appear at all | The field is not a boolean; supported types are inherited and limited to boolean. Point the widget at a boolean field. |
Lunch favorite field vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
lunch_is_favorite | A per-user favorite flag on a view that is deliberately not editable | Takes its read-only state from the literal XML attribute instead of the evaluated view state |
| boolean_favorite | A favorite star on an ordinary editable view | Honors the evaluated read-only state, so it freezes with the rest of the view |
| boolean_toggle | An on/off setting rather than a personal favorite | Switch styling and no star semantics |
| priority | Ranking records by importance | Stars representing a graded value, not a single boolean |
Frequently asked questions
What does lunch_is_favorite change compared to boolean_favorite?+
Why is the star still clickable on a non-editable kanban?+
Does readonly="0" work?+
Can I use it outside the lunch app?+
Is the field protected if the star ignores readonly?+
Locked-down screens that still need one live control?
Read-only views are easy to declare and awkward to soften afterwards, and the usual workaround is to unlock far more than you meant to. We solve those cases precisely, one field at a time, as part of Odoo customization work on 16 through 19.
Book a free consultation