Skip to Content
Menu
This question has been flagged
1 Reply
9123 Views

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?

Avatar
Discard
Best Answer

You can get last record id from account.config.settings table using the below code:-

account_config_obj = self.pool.get('account.config.settings')

account_config_ids = account_config_obj.search(cr, uid,  [], limit=1, order='id desc')

Avatar
Discard
Author

Thank you prakash, I have written like this cr.execute('SELECT id FROM account_config_settings ') account_config_settings_last_id= cr.fetchall()[-1][0] but your suggested way is good. I am going to follow your way.

Related Posts Replies Views Activity
0
Jul 25
13
2
Jun 24
1042
0
Jan 22
2312
2
Aug 20
10309
0
Jul 19
4849