Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
9030 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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.

Post correlati Risposte Visualizzazioni Attività
0
lug 25
13
2
giu 24
999
0
gen 22
2244
2
ago 20
10222
0
lug 19
4797