# 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 tools, api, fields, models, _ from odoo.exceptions import ValidationError, UserError, Warning import json import requests class WizardSignDelivery(models.TransientModel): _name = 'wizard.sign_delivery' _description = 'Sign Delivery' picking_signature = fields.Binary() @api.multi def button_sign_delivery(self): for wizard in self: error_at_dlv = False info = 'Bitte prüfen Sie den Lieferscheinstatus:' active_ids = self.env.context.get('active_ids', []) delivery = self.env['stock.picking'].browse(active_ids) if delivery.exists(): for dlv in delivery: if dlv.state != 'cancel': info += "\n %s -- OK" % dlv.name else: info += "\n %s state='%s'" % (dlv.name,dlv.state) error_at_dlv = True if error_at_dlv: raise ValidationError(_(info)) for dlv in delivery: # msg = '' # if not wizard['picking_signature'] or len(wizard['picking_signature']) == 3012: # if dlv['picking_signature'] or len(dlv['picking_signature']) == 3012: # msg = 'X Unterschrift wurde entfernt' # else: # if not dlv['picking_signature'] or len(dlv['picking_signature']) == 3012: # msg = 'X Lieferschein wurde unterschrieben' # elif wizard['picking_signature'] != dlv['picking_signature']: # msg = 'X Unterschrift wurde geändert' # # if msg != '': dlv.picking_signature = wizard['picking_signature'] # dlv.message_post(body=msg) action = self.env.ref('stock.stock_picking_action_picking_type').read()[0] action['domain'] = [('id', 'in', active_ids)] action['context'] = [{}] return action def sign_delivery_status(self, order_id): info = 'Done' return info