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

Hi everyone,

I have two fields in python file.

system_category_id = fields.Selection([
        ('laptop', 'Laptop'),
        ('desktop', 'Desktop'),
        ('mobile', 'Mobile'),
        ('switches', 'Switch'),
        ('wifirouters', 'WiFi Router'),
        ('printers', 'Printer'),
        ('firewall', 'Firewall'),
    ], string='Equipment Category',copy=False, index=True, default='laptop')


super_category_id = fields.Selection([
        ('laptop', 'Laptop'),
        ('desktop', 'Desktop'),
        ('mobile', 'Mobile'),
        ('switches', 'Switch'),
        ('wifirouters', 'WiFi Router'),
        ('printers', 'Printers'),
        ('firewall', 'Firewall'),
        ('datacard','Data Card'),
        ('sims','SIMS'),
        ('workstation','Work Station'),
        ('accesscards','Access Card'),
    ], string='Equipment Category',copy=False, index=True, default='laptop')


So in the view whenever i select Laptop,Desktop

model,make,serial_no,ram,hard disk,processor,processor_speed should be mandatory. For that i wrote xml code

<field name ="ram" attrs="{'invisible': ['|',('system_category_id','in',('switches','firewall','wifirouters','printers','mobile')),('super_category_id','in',('switches','firewall','wifirouters','printers','datacard','sims','workstation','accesscards','mobile'))],'required': ['|',('system_category_id','in',('laptop','desktop')),('super_category_id','in',('laptop','desktop'))]}" style="text-transform: uppercase;" groups="asset_management.group_asset_system_admin,asset_management.group_asset_super_admin"/>


But even if i select other asset from super category like mobile still it is showing ram is mandatory even if i give ram only mandatory for laptop n desktop. How to solve this??


Please anyone help me with this

Avatar
Discard
Best Answer

Hi,

The code seems to be fine. There is no issue in it.
Hope you are aware of the logic you have given . The given logic is such a way that, the field will get required field if you select desktop or laptop in either one of this field . Also the field will get invisible if the selected one is not the lap top or desktop in either one of this field.

So if you have these two fields super_category_id and system_category_id visible in you form make sure that, its working according to the logic.
Thanks

Avatar
Discard
Author

Thanku Niyas.You always been wonderful support in all my questions.

Best Answer

Savita,

Your domain for required itself said, that any of the category_id field having selected destkop or laptop it would make your ram field mandatory.

In domain "|", this sign is mean OR. any of the condition will get true your field will become mandatory.

Hope this will give you some idea.

Rgds,

Anil.

 


Avatar
Discard