wizard_reset_order
parent
2d597c454a
commit
26b8c9c3f8
|
|
@ -2,7 +2,7 @@
|
||||||
# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
|
# License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses).
|
||||||
|
|
||||||
from odoo import tools, api, fields, models, _
|
from odoo import tools, api, fields, models, _
|
||||||
from odoo.exceptions import ValidationError, UserError
|
from odoo.exceptions import ValidationError, UserError, Warning
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -11,7 +11,16 @@ class WizardResetOrder(models.TransientModel):
|
||||||
_name = 'wizard.reset_order'
|
_name = 'wizard.reset_order'
|
||||||
_description = 'Reset imos-Order'
|
_description = 'Reset imos-Order'
|
||||||
|
|
||||||
name = fields.Char()
|
# name = fields.Char()
|
||||||
|
#
|
||||||
|
# @api.onchange('name')
|
||||||
|
# def _onchange_name(self):
|
||||||
|
# return {
|
||||||
|
# 'warning': {
|
||||||
|
# 'title': _('Warning!'),
|
||||||
|
# 'message': _("Achtung, es gab Fehler"),
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def button_reset_order(self):
|
def button_reset_order(self):
|
||||||
|
|
@ -30,17 +39,20 @@ class WizardResetOrder(models.TransientModel):
|
||||||
if error_at_quotation:
|
if error_at_quotation:
|
||||||
raise ValidationError(_(info))
|
raise ValidationError(_(info))
|
||||||
|
|
||||||
info = 'Mindestens eines der Angebote konnte nicht zurückgesetzt werden:'
|
info = 'Mindestens ein Warenkorb konnte nicht zurückgesetzt werden:'
|
||||||
for so in sale_orders:
|
for so in sale_orders:
|
||||||
order_info = self.reset_order_status(so.origin)
|
order_info = self.reset_order_status(so.origin)
|
||||||
if order_info != '':
|
if order_info != '':
|
||||||
error_at_quotation = True
|
error_at_quotation = True
|
||||||
info += "\n"+order_info
|
info += "\n%s" % order_info
|
||||||
|
so.message_post(body='Warenkorb konnte im DesignBox-Portal nicht zurückgesetzt werden!\n %s' % order_info)
|
||||||
else:
|
else:
|
||||||
info += "\n%s --> OK" % so.name
|
info += "\n%s --> OK" % so.name
|
||||||
|
so.message_post(body='Warenkorb im DesignBox-Portal zurückgesetzt!\n%s --> OK' % so.name)
|
||||||
|
|
||||||
if error_at_quotation:
|
if error_at_quotation:
|
||||||
raise UserError(_(info))
|
raise Warning(_(info))
|
||||||
|
# self.name = _(info)
|
||||||
|
|
||||||
action = self.env.ref('sale.action_orders').read()[0]
|
action = self.env.ref('sale.action_orders').read()[0]
|
||||||
action['domain'] = [('id', 'in', active_ids)]
|
action['domain'] = [('id', 'in', active_ids)]
|
||||||
|
|
@ -70,9 +82,9 @@ class WizardResetOrder(models.TransientModel):
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
if lRes.get('status') != 0:
|
if lRes.get('status') != 0:
|
||||||
info = "Angebot: %s, Fehler='%s'" % (order_id,lRes)
|
info = "Warenkorb: %s, Fehler='%s'" % (order_id,lRes)
|
||||||
else:
|
else:
|
||||||
if lRes.get('status') != 0:
|
if lRes.get('status') != 0:
|
||||||
info = "Angebot: %s, Fehler='%s'" % (order_id,lRes.get('data'))
|
info = "Warenkorb: %s, Fehler='%s'" % (order_id,lRes.get('data'))
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,12 @@
|
||||||
<group>
|
<group>
|
||||||
<p>Wollen Sie die imos-Bestellung für die markierten Aufträge zurücksetzen?</p>
|
<p>Wollen Sie die imos-Bestellung für die markierten Aufträge zurücksetzen?</p>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<group>
|
||||||
|
<field name="name"/>
|
||||||
|
</group>
|
||||||
|
-->
|
||||||
<footer>
|
<footer>
|
||||||
<button name="button_reset_order"
|
<button name="button_reset_order"
|
||||||
string="imos-Bestellung zurücksetzen"
|
string="imos-Bestellung zurücksetzen"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue