From dda1d24f46234b883f91e95b85847b9096e22aa6 Mon Sep 17 00:00:00 2001 From: Roman Widmann Date: Wed, 31 Jan 2018 16:56:21 +0100 Subject: [PATCH] Fall 4915: Auftragsfreigabe mehrere Angebote --- ext/custom-addons/dp_custom/__init__.py | 1 + ext/custom-addons/dp_custom/__manifest__.py | 1 + .../dp_custom/views/sale_views.xml | 17 ++++++ .../dp_custom/wizards/__init__.py | 1 + .../wizards/wizard_confirm_production.py | 27 +++++++++ .../wizards/wizard_confirm_production.xml | 56 +++++++++++++++++++ 6 files changed, 103 insertions(+) create mode 100644 ext/custom-addons/dp_custom/wizards/__init__.py create mode 100644 ext/custom-addons/dp_custom/wizards/wizard_confirm_production.py create mode 100644 ext/custom-addons/dp_custom/wizards/wizard_confirm_production.xml diff --git a/ext/custom-addons/dp_custom/__init__.py b/ext/custom-addons/dp_custom/__init__.py index 15bca215..a4a92031 100644 --- a/ext/custom-addons/dp_custom/__init__.py +++ b/ext/custom-addons/dp_custom/__init__.py @@ -20,3 +20,4 @@ ############################################################################## from . import models +from . import wizards diff --git a/ext/custom-addons/dp_custom/__manifest__.py b/ext/custom-addons/dp_custom/__manifest__.py index 22295244..6102ab36 100644 --- a/ext/custom-addons/dp_custom/__manifest__.py +++ b/ext/custom-addons/dp_custom/__manifest__.py @@ -37,6 +37,7 @@ 'dp_intercompany_invoicing', ], 'data': [ + 'wizards/wizard_confirm_production.xml', 'security/security.xml', 'data/dp_custom_data.xml', 'data/glaser_company_data.xml', diff --git a/ext/custom-addons/dp_custom/views/sale_views.xml b/ext/custom-addons/dp_custom/views/sale_views.xml index 416cbf1d..25b580aa 100644 --- a/ext/custom-addons/dp_custom/views/sale_views.xml +++ b/ext/custom-addons/dp_custom/views/sale_views.xml @@ -55,7 +55,24 @@ + + + + + view.sales.order.filter.assembly + sale.order + + + + + + + + + + + diff --git a/ext/custom-addons/dp_custom/wizards/__init__.py b/ext/custom-addons/dp_custom/wizards/__init__.py new file mode 100644 index 00000000..a0ef024d --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/__init__.py @@ -0,0 +1 @@ +from . import wizard_confirm_production diff --git a/ext/custom-addons/dp_custom/wizards/wizard_confirm_production.py b/ext/custom-addons/dp_custom/wizards/wizard_confirm_production.py new file mode 100644 index 00000000..51e767e1 --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/wizard_confirm_production.py @@ -0,0 +1,27 @@ +# 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 WizardConfirmProduction(models.TransientModel): + _name = 'wizard.confirm.production' + _description = 'Produktionsfreigabe' + + name = fields.Char() + + @api.multi + def button_confirm_production(self): + for wizard in self: + 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 == 'created' and so.state == 'sale': + so.assembly_state = 'approved' + else: + raise ValidationError(u'Auftrag %s: Bitte prüfen Sie den PG-Status und/oder Auftragsstatus.' % so.name) + 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_confirm_production.xml b/ext/custom-addons/dp_custom/wizards/wizard_confirm_production.xml new file mode 100644 index 00000000..d2d164cd --- /dev/null +++ b/ext/custom-addons/dp_custom/wizards/wizard_confirm_production.xml @@ -0,0 +1,56 @@ + + + + + + + view_wizard_confirm_production_form + wizard.confirm.production + +
+ +

Wollen Sie die Produktion für die markierten Aufträge freigeben?

+
+
+
+
+
+
+ + + + + + +