Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. def post(cls, invoices):                                                      
  2.                                                                                
  3.         Move = Pool().get('account.move')#crem un nou registre del Model account.move
  4.                                                                                
  5.         cls.set_number(invoices)#Definim el el numero de les factures          
  6.         moves = [] #Declarem l'array moguiments                                
  7.         for invoice in invoices:                                              
  8.             move = invoice.get_move()                                          
  9.             if move != invoice.move:#Si el moguiment es diferent al moguiment de la factura, el moguiment de la factura el guardarem a una array.
  10.                 invoice.move = move                                            
  11.                 moves.append(move)                                            
  12.             if invoice.state != 'posted': #Si ed firefent a publicat fem que canvi a oublicat,
  13.                invoice.state = 'posted'                                        
  14.         if moves:#Si tenim moguiments els guardarem i les factures            
  15.             Move.save(moves)                                                  
  16.         cls.save(invoices) #Guardem les facures                                
  17.         Move.post([i.move for i in invoices if i.move.state != 'posted'])#Busquem les factures que no etiguin publicades
  18.         reconciled = []#Definim una array                                      
  19.         for invoice in invoices: #Recorrem les factures i les que siguin de tipus output  les imprimim i les que siguin reconciliades les guardem a l'array.
  20.             if invoice.type == 'out':                                          
  21.                 invoice.print_invoice()                                        
  22.             if invoice.reconciled:                                            
  23.                 reconciled.append(invoice)                                    
  24.         if reconciled:#Les que tenim a l'array reconciliades les fiquem al proces.
  25.             cls.__queue__.process(reconciled)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement