Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Constraint Error

By
Susi
on 7/28/16, 11:07 PM 219 views

i have function approve inherit in hr.analytic.timesheet

 

def approve(self,cr,uid,ids,context=None):
    for value in self.browse(cr,uid,ids) :
        value.write({'state':'done'})
    return True 


and when i click my button approve (state=confirm)  its show constraint like this

Error! You cannot modify an entry in a confirmed timesheet.


and i try to redefine function like this

 def _check(self, cr, uid, ids):
        for line in self.browse(cr, uid, ids):
            if line.sheet_id and line.sheet_id.state not in ('draft', 'new','confirm'):
                    raise osv.except_osv(_('Error!'), _('You cannot modify an entry in a confirmed timesheet.'))
            return True 

in my function i add state confirm. but the constraiint still show. what should i do with my code? is there something wrong? thanks before

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/28/16, 11:07 PM
Seen: 219 times
Last updated: 7/29/16, 3:08 AM