add wizard for TZBox-Import
							parent
							
								
									ea919c1cc3
								
							
						
					
					
						commit
						cd30baee60
					
				|  | @ -43,6 +43,7 @@ | ||||||
|     'data': [ |     'data': [ | ||||||
|         'views/commission_account.xml', |         'views/commission_account.xml', | ||||||
|         'wizards/wizard_confirm_production.xml', |         'wizards/wizard_confirm_production.xml', | ||||||
|  |         'wizards/wizard_import_tzbox.xml', | ||||||
|         'wizards/portal_assign_company.xml', |         'wizards/portal_assign_company.xml', | ||||||
|         'wizards/wizard_confirm_print_invoice.xml', |         'wizards/wizard_confirm_print_invoice.xml', | ||||||
|         'security/security.xml', |         'security/security.xml', | ||||||
|  |  | ||||||
|  | @ -32,7 +32,9 @@ class SaleOrder(models.Model): | ||||||
|     _name = 'sale.order' |     _name = 'sale.order' | ||||||
|     _inherit = ['sale.order', 'dp_custom.helper'] |     _inherit = ['sale.order', 'dp_custom.helper'] | ||||||
| 
 | 
 | ||||||
|     ASSEMBLY_STATES = [('created', 'nicht freigegeben'), |     ASSEMBLY_STATES = [('import','Import'), | ||||||
|  |                        ('import_failed','Fehler Import'), | ||||||
|  |                        ('created', 'nicht freigegeben'), | ||||||
|                        ('approved', 'Produktionsfreigabe'), |                        ('approved', 'Produktionsfreigabe'), | ||||||
|                        ('wait', 'freigegeben'), |                        ('wait', 'freigegeben'), | ||||||
|                        ('failed', 'Fehler Freigabe'), |                        ('failed', 'Fehler Freigabe'), | ||||||
|  | @ -49,7 +51,7 @@ class SaleOrder(models.Model): | ||||||
| 
 | 
 | ||||||
|     assembled = fields.Boolean(string='Zusammengebaut') |     assembled = fields.Boolean(string='Zusammengebaut') | ||||||
|     line_id = fields.Many2one(comodel_name='res.line', string='Produktionslinie') |     line_id = fields.Many2one(comodel_name='res.line', string='Produktionslinie') | ||||||
|     assembly_state = fields.Selection(ASSEMBLY_STATES, string="Status PG", track_visibility='onchange') |     assembly_state = fields.Selection(ASSEMBLY_STATES, string="Status PG", track_visibility='onchange', help='Bitte nicht manuell ändern', default='') | ||||||
|     quote_name = fields.Char(compute='_compute_quote_name') |     quote_name = fields.Char(compute='_compute_quote_name') | ||||||
|     internal_notes = fields.Text() |     internal_notes = fields.Text() | ||||||
|     assembly_notes = fields.Text() |     assembly_notes = fields.Text() | ||||||
|  | @ -159,6 +161,19 @@ class SaleOrder(models.Model): | ||||||
|             }) |             }) | ||||||
|         return order_list |         return order_list | ||||||
| 
 | 
 | ||||||
|  |     @api.model | ||||||
|  |     def pg_update_quotation(self, vals): | ||||||
|  |         """ | ||||||
|  |         SST-3a | ||||||
|  |         :param order_name: | ||||||
|  |         :return: | ||||||
|  |         """ | ||||||
|  |         order_name = vals.get('order_name', False) | ||||||
|  |         order_line_vals = vals.get('order_lines', False) | ||||||
|  |         order_id = self.search([('name', '=', order_name)], order='id DESC',limit=1) | ||||||
|  |         order_id.pg_create_order_lines(order_line_vals) | ||||||
|  |         return {'id': order_id.id, 'name': order_id.name} | ||||||
|  | 
 | ||||||
|     @api.model |     @api.model | ||||||
|     def pg_create_quotation(self, vals): |     def pg_create_quotation(self, vals): | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
|  | @ -6,6 +6,12 @@ | ||||||
|         <field name="model">sale.order</field> |         <field name="model">sale.order</field> | ||||||
|         <field name="inherit_id" ref="sale.view_order_form"/> |         <field name="inherit_id" ref="sale.view_order_form"/> | ||||||
|         <field name="arch" type="xml"> |         <field name="arch" type="xml"> | ||||||
|  |             <xpath expr="//sheet" position="before"> | ||||||
|  |                 <header> | ||||||
|  |                     <button name="%(action_wizard_import_tzbox)d" string="TZBox-Datei importieren" type="action" | ||||||
|  |                             class="btn-danger" attrs="{'invisible':['|','|',('state','!=','draft'),('order_type','!=','T'),('assembly_state','not in',[False,'import_failed'])]}"/> | ||||||
|  |                 </header> | ||||||
|  |             </xpath> | ||||||
|             <field name="client_order_ref" position="replace"/> |             <field name="client_order_ref" position="replace"/> | ||||||
|             <field name="origin" position="replace"/> |             <field name="origin" position="replace"/> | ||||||
|             <field name="payment_term_id" position="after"> |             <field name="payment_term_id" position="after"> | ||||||
|  |  | ||||||
|  | @ -1,3 +1,4 @@ | ||||||
| from . import wizard_confirm_production | from . import wizard_confirm_production | ||||||
|  | from . import wizard_import_tzbox | ||||||
| from . import wizard_confirm_print_invoice | from . import wizard_confirm_print_invoice | ||||||
| from . import portal_assign_company | from . import portal_assign_company | ||||||
|  |  | ||||||
|  | @ -0,0 +1,33 @@ | ||||||
|  | # 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 | ||||||
|  | @ -0,0 +1,37 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <!-- 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). --> | ||||||
|  | 
 | ||||||
|  | <odoo> | ||||||
|  | 
 | ||||||
|  |     <record id="view_wizard_import_tzbox_form" model="ir.ui.view"> | ||||||
|  |         <field name="name">view_wizard_import_tzbox_form</field> | ||||||
|  |         <field name="model">wizard.import.tzbox</field> | ||||||
|  |         <field name="arch" type="xml"> | ||||||
|  |             <form string="Wizard Import TZBox"> | ||||||
|  |                 <group> | ||||||
|  |                     <p>Wollen Sie die TZBox-Dateien für die markierten Aufträge importieren?</p> | ||||||
|  |                 </group> | ||||||
|  |                 <footer> | ||||||
|  |                     <button name="button_import_tzbox" | ||||||
|  |                             string="Import TZBox-Datei" | ||||||
|  |                             class="btn-primary" | ||||||
|  |                             type="object"/> | ||||||
|  |                     <button string="Abbrechen" | ||||||
|  |                             class="btn-default" | ||||||
|  |                             special="cancel"/> | ||||||
|  |                 </footer> | ||||||
|  |             </form> | ||||||
|  |         </field> | ||||||
|  |     </record> | ||||||
|  | 
 | ||||||
|  |     <act_window id="action_wizard_import_tzbox" | ||||||
|  |         name="Import TZBox-Datei" | ||||||
|  |         src_model="sale.order" | ||||||
|  |         res_model="wizard.import.tzbox" | ||||||
|  |         view_type="form" | ||||||
|  |         view_mode="form" | ||||||
|  |         key2="client_action_multi" | ||||||
|  |         target="new"/> | ||||||
|  | 
 | ||||||
|  | </odoo> | ||||||
		Loading…
	
		Reference in New Issue