diff --git a/addons/stock/models/res_config_settings.py b/addons/stock/models/res_config_settings.py index a6c4c9047e6..15d2b4fb2c8 100644 --- a/addons/stock/models/res_config_settings.py +++ b/addons/stock/models/res_config_settings.py @@ -26,6 +26,7 @@ class ResConfigSettings(models.TransientModel): implied_group='stock.group_adv_location', help="Add and customize route operations to process product moves in your warehouse(s): e.g. unload > quality control > stock for incoming products, pick > pack > ship for outgoing products. \n You can also set putaway strategies on warehouse locations in order to send incoming products into specific child locations straight away (e.g. specific bins, racks).") group_warning_stock = fields.Boolean("Warnings for Stock", implied_group='stock.group_warning_stock') + group_stock_sign_delivery = fields.Boolean("Signature", implied_group='stock.group_stock_sign_delivery') module_stock_picking_batch = fields.Boolean("Batch Pickings") module_stock_barcode = fields.Boolean("Barcode Scanner") stock_move_email_validation = fields.Boolean(related='company_id.stock_move_email_validation', readonly=False) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index e6f9fec8fd1..28c68bfe01b 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -356,6 +356,7 @@ class Picking(models.Model): check_company=True, help="When validating the transfer, the products will be assigned to this owner.") printed = fields.Boolean('Printed') + signature = fields.Image('Signature', help='Signature', copy=False, attachment=True) is_locked = fields.Boolean(default=True, help='When the picking is not done this allows changing the ' 'initial demand. When the picking is done this allows ' 'changing the done quantities.') @@ -576,6 +577,9 @@ class Picking(models.Model): if vals.get('picking_type_id') and self.state != 'draft': raise UserError(_("Changing the operation type of this record is forbidden at this point.")) res = super(Picking, self).write(vals) + if vals.get('signature'): + for picking in self: + picking._attach_sign() # Change locations of moves if those of the picking change after_vals = {} if vals.get('location_id'): @@ -1219,3 +1223,18 @@ class Picking(models.Model): action['context'] = self.env.context action['domain'] = [('picking_id', 'in', self.ids)] return action + + def _attach_sign(self): + """ Render the delivery report in pdf and attach it to the picking in `self`. """ + self.ensure_one() + report = self.env.ref('stock.action_report_delivery').render_qweb_pdf(self.id) + filename = "%s_signed_delivery_slip" % self.name + if self.partner_id: + message = _('Order signed by %s') % (self.partner_id.name) + else: + message = _('Order signed') + self.message_post( + attachments=[('%s.pdf' % filename, report[0])], + body=message, + ) + return True diff --git a/addons/stock/report/report_deliveryslip.xml b/addons/stock/report/report_deliveryslip.xml index d5b803dfde1..1981724e8c2 100644 --- a/addons/stock/report/report_deliveryslip.xml +++ b/addons/stock/report/report_deliveryslip.xml @@ -98,6 +98,18 @@ All items couldn't be shipped, the remaining ones will be shipped as soon as they become available.
+ +