Skip to Content
Menú
This question has been flagged
3 Respostes
3988 Vistes

Hello Every one...

In Odoo 8 , Expense I have a field Budget whose value is coming from onchange, now what I want is when amount i.e total expense exceeds budget amount it should throw popup and that entry should not be saved.

I have created a update button like in purchase or sale module and on if condition its showing popup. But ALL I want is how to disallow save of that entry. i.e. exceeding amount entry should not be saved. when user click on update button and if condition is true it create popup but after clicking popup ok it allows to save form.

Thanks in advance....

Avatar
Descartar

You can super the create function of the model to do this. or you can do it by giving constrains

Autor Best Answer

There is no create or write function in hr_expense_expense(osv.osv) in odoo 8. But only function I think that can do needfull is as below , but how to call that before save button click.

def _amount(self, cr, uid, ids, field_name, arg, context=None):
        res= {}
        for expense in self.browse(cr, uid, ids, context=context):
            total = 0.0
            for line in expense.line_ids:
                total += line.unit_amount * line.unit_quantity
            res[expense.id] = total
        return res

Avatar
Descartar
Best Answer

Override the write method of that particular model and check for the condition

@api.multi

def write(self)
for rec in self:
if rec.budget > "budget":

     raise Warning(_('budget is exceded !'))
else:

return super(name_of_your_model, self).write(vals)
Avatar
Descartar
Related Posts Respostes Vistes Activitat
3
de jul. 17
3733
0
de gen. 24
2105
1
de febr. 21
5456
4
de des. 19
15030
0
de des. 18
13