Skip to Content
Menu
This question has been flagged
2 Replies
2502 Views

I run an insurance agency and I'm using Odoo 14CE to manage our client profiles, and I'm trying to figure out how to make a many2one field show in red if the client is taking a medication that's on the declinable list. I have my model created as x_meds and several many2one fields created as x_med1, x_med2, x_med3, etc. that all reference x_meds.

What I want is for certain records in the x_meds model to display in red if they will cause the client to get declined on an application. e.g, if the agent enters carvedilol in x_med1 and amlodipine in x_med2 that's fine, but if she enters gabapentin in x_med3 I want it to be flagged so the agent knows right away there is a problem without having to look up each drug manually. Is it possible to do this kind of conditional formatting on a many2one field?

Avatar
Discard
Author

Thanks! I will try these and report results.

Author

I don't have enough karma to reply directly, but I think decoration-danger is what I want. However, all the examples I can find of its use are for a numeric value and not a text string. What would be the syntax to apply it if a text string is found anywhere in the value?

Best Answer

Hi,

The following Odoo link might help you

https://www.odoo.com/forum/help-1/how-to-change-color-of-line-in-tree-view-55291

Thanks

Avatar
Discard
Best Answer

Hi Alan:

You can add the decoration attribute to a field like so to conditionally control the color of the field.

<field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount > 24"/>

decoration-danger will display the field in red

Avatar
Discard
Related Posts Replies Views Activity
2
Apr 23
1451
2
May 24
35790
2
Nov 22
1474
1
Feb 22
6686
2
Dec 21
2704