Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
9181 Vizualizări

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?

Imagine profil
Abandonează
Cel mai bun răspuns

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')

Imagine profil
Abandonează
Autor

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 Răspunsuri Vizualizări Activitate
0
iul. 25
13
2
iun. 24
1116
0
ian. 22
2382
2
aug. 20
10410
0
iul. 19
4907