From cd30baee6051ba5c350876375022c4feac7be751 Mon Sep 17 00:00:00 2001 From: Andreas Osim Date: Mon, 14 May 2018 14:49:32 +0200 Subject: [PATCH] add wizard for TZBox-Import --- ext/custom-addons/dp_custom/__manifest__.py | 1 + ext/custom-addons/dp_custom/models/sale.py | 19 +++++++++- .../dp_custom/views/sale_views.xml | 6 +++ .../dp_custom/wizards/__init__.py | 1 + .../dp_custom/wizards/wizard_import_tzbox.py | 33 +++++++++++++++++ .../dp_custom/wizards/wizard_import_tzbox.xml | 37 +++++++++++++++++++ 6 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.py create mode 100644 ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.xml diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index e8a1d872..f906da6d 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -43,6 +43,7 @@ 'data': [ 'views/commission_account.xml', 'wizards/wizard_confirm_production.xml', + 'wizards/wizard_import_tzbox.xml', 'wizards/portal_assign_company.xml', 'wizards/wizard_confirm_print_invoice.xml', 'security/security.xml', diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index c19c05aa..c9bfd46e 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -32,7 +32,9 @@ class SaleOrder(models.Model): _name = 'sale.order' _inherit = ['sale.order', 'dp_custom.helper'] - ASSEMBLY_STATES = [('created', 'nicht freigegeben'), + ASSEMBLY_STATES = [('import','Import'), + ('import_failed','Fehler Import'), + ('created', 'nicht freigegeben'), ('approved', 'Produktionsfreigabe'), ('wait', 'freigegeben'), ('failed', 'Fehler Freigabe'), @@ -49,7 +51,7 @@ class SaleOrder(models.Model): assembled = fields.Boolean(string='Zusammengebaut') 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') internal_notes = fields.Text() assembly_notes = fields.Text() @@ -159,6 +161,19 @@ class SaleOrder(models.Model): }) 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 def pg_create_quotation(self, vals): """ diff --git a/ext/custom-addons/dp_custom/views/sale_views.xml b/ext/custom-addons/dp_custom/views/sale_views.xml index 361c4770..f9e252f1 100644 --- a/ext/custom-addons/dp_custom/views/sale_views.xml +++ b/ext/custom-addons/dp_custom/views/sale_views.xml @@ -6,6 +6,12 @@ sale.order + +
+
+
diff --git a/ext/custom-addons/dp_custom/wizards/__init__.py b/ext/custom-addons/dp_custom/wizards/__init__.py index 9d83ef0f..ddbef7c2 100644 --- a/ext/custom-addons/dp_custom/wizards/__init__.py +++ b/ext/custom-addons/dp_custom/wizards/__init__.py @@ -1,3 +1,4 @@ from . import wizard_confirm_production +from . import wizard_import_tzbox from . import wizard_confirm_print_invoice from . import portal_assign_company diff --git a/ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.py b/ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.py new file mode 100644 index 00000000..fb0fa8c6 --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.py @@ -0,0 +1,33 @@ +# Copyright 2018-Today datenpol gmbh () +# 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 diff --git a/ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.xml b/ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.xml new file mode 100644 index 00000000..7088c7bb --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/wizard_import_tzbox.xml @@ -0,0 +1,37 @@ + + + + + + + view_wizard_import_tzbox_form + wizard.import.tzbox + +
+ +

Wollen Sie die TZBox-Dateien für die markierten Aufträge importieren?

+
+
+
+
+
+
+ + + +