34 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.4 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, fields, models, _
 | 
						|
from odoo.exceptions import ValidationError
 | 
						|
 | 
						|
 | 
						|
class WizardImportTZBox(models.TransientModel):
 | 
						|
    _name = 'wizard.import.tzbox'
 | 
						|
    _description = 'Import TZBox-Datei'
 | 
						|
 | 
						|
    name = fields.Char()
 | 
						|
 | 
						|
    @api.multi
 | 
						|
    def button_import_tzbox(self):
 | 
						|
        for wizard in self:
 | 
						|
            error_at_quotation = False
 | 
						|
            info = 'Bitte prüfen Sie den PG-Status und/oder Angebotsstatus folgender Angebote:'
 | 
						|
            active_ids = self.env.context.get('active_ids', [])
 | 
						|
            sale_orders = self.env['sale.order'].browse(active_ids)
 | 
						|
            if sale_orders.exists():
 | 
						|
                for so in sale_orders:
 | 
						|
                    if (so.assembly_state == 'import_failed'
 | 
						|
                        or so.assembly_state == '' or so.assembly_state == False) and so.state == 'draft':
 | 
						|
                        so.assembly_state = 'import'
 | 
						|
                    else:
 | 
						|
                        info += '\n %s' % so.name
 | 
						|
                        error_at_quotation = True
 | 
						|
            if error_at_quotation:
 | 
						|
                raise ValidationError(_(info))
 | 
						|
            action = self.env.ref('sale.action_orders').read()[0]
 | 
						|
            action['domain'] = [('id', 'in', active_ids)]
 | 
						|
            return action
 |