31 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
| # Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>)
 | |
| # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
 | |
| 
 | |
| from odoo import api, models
 | |
| 
 | |
| 
 | |
| class AccountInvoice(models.Model):
 | |
|     _inherit = 'account.invoice'
 | |
| 
 | |
|     @api.multi
 | |
|     def order_lines_layouted(self):
 | |
|         res = super(AccountInvoice, self).order_lines_layouted()
 | |
|         uncategorized = False
 | |
|         # Rechnungszeilen ohne Kategorie löschen und an den Anfang stellen
 | |
|         for idx1, page in enumerate(res):
 | |
|             for idx2, category in enumerate(page):
 | |
|                 if category.get('name') == 'Uncategorized':
 | |
|                     uncategorized = page.pop(idx2)
 | |
|             if uncategorized:
 | |
|                 res[idx1] = [uncategorized] + res[idx1]
 | |
|         for page in res:
 | |
|             for category in page:
 | |
|                 price_subtotal = 0.0
 | |
|                 for line in category['lines']:
 | |
|                     price_subtotal += line.price_subtotal
 | |
|                 category['price_subtotal'] = price_subtotal
 | |
|                 sale_order = self.env['sale.order'].search([('name', '=', category['name'])])
 | |
|                 if sale_order:
 | |
|                     category['confirmation_nr'] = sale_order.confirmation_nr
 | |
|         return res
 |