Skip to Content
Menu
This question has been flagged

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.

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
Discard

Create and write will be available for all models. Just inherit the model and super write method

Author Best Answer

Thanks, its resolved...

Avatar
Discard
Best Answer

Dear 


Try this :

_sql_constraints = [('budget_check', 'CHECK (expense_amount_field >=budget_amount_field)', _("Total expense exceeds budget amount"))]
Avatar
Discard
Related Posts Replies Views Activity
5
Apr 19
7459
3
Jul 17
2972
2
Jan 20
13435
4
Dec 19
13418
16
Aug 19
8650