I have added one extra column to ""account.config.settings" i.e "threelevelinvoiceapproval". I have written this function to validate invoice.
def approve(self, cr, uid, ids):
flag=False
for invoice in self.pool.get('account.invoice').browse(cr, uid, ids, context=None):
for i in self.pool.get('account.config.settings').browse(cr, uid, ids, context=None):
flag=i.threelevelinvoiceapproval
# Three level approval true.
if flag:
if invoice.create_uid1.id==uid:
raise openerp.exceptions.Warning("You don't have right to validate purchase order")
return False
else:
self.write(cr, uid, ids, {'state': 'validate','write_uid1':uid})
return True
# No three level approval use the fields in the user creation to approve
else:
for i in self.pool.get('res.users').browse(cr, uid, [uid], context=None):
flag=i.canvalidateinvoice
if flag:
self.write(cr, uid, ids, {'state': 'validate','write_uid1':uid})
return True
else:
raise openerp.exceptions.Warning("You don't have right to validate purchase order")
return False
In fourth line of the function getting the "ids" from invoice line but i need the id of the last record of "account.config.settings". Please tell me how can i solve this?