odoo/ext/custom-addons/dp_custom/wizards/wizard_sign_delivery.py

37 lines
1.5 KiB
Python

# 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 tools, api, fields, models, _
from odoo.exceptions import ValidationError, UserError, Warning
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:
dlv.picking_signature = wizard['picking_signature']
action = self.env.ref('stock.stock_picking_action_picking_type').read()[0]
action['domain'] = [('id', 'in', active_ids)]
action['context'] = [{}]
return action