0
votes

How can i keep a alert om odoo 8 when user entered 0 should show you have entered 0 in the particular slab as a popup and when click on OK the record should br saved currently i am getting warning and not saving until the zero is changed .

'

def create(self, cr, uid, vals, context=None):
        accruemonth = {'accrue_jan': 'January', 'accrue_feb': 'February', 
          'accrue_mar':'March','accrue_apr': 'April','accrue_may': 'May', 
          'accrue_june': 'June','accrue_july': 'July','accrue_aug': 
          'August', 'accrue_sep':     
   'September','accrue_oct':'October','accrue_nov':'November''accrue_dec': 
           'December', }
        for key, value in accruemonth.items():
            if 'accrue_slab' in vals and vals['accrue_slab'] == 'monthly' 
                and key in vals and vals[key] < 0.01:
                 raise osv.except_osv(_('Alert!'),
                                     _("%s slab is 0 or empty", )%(value))                

' I want to get the record saved when user entered less than 0.01 by showing alert and clicking OK button on the popup window and clicking on save button the record should be saved now i am getting warning as popup window and not allowing to save until we change the value to greter than 0.01.

1

1 Answers

0
votes

sree

For this, you have to use the onchange method and from there you have to raise the warning message. Example:

def onchange_slab(self, cr, uid, ids, context=None):
    if 'Your_Field' < 0:
        return {'warning': {
            'title': _('Warning!'),
            'message': _("slab is 0 or empty")
            }
        }
    return {}