From 596b246f93f62498fc700bec8826f08d384e8282 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Fri, 18 Oct 2019 14:08:57 +0000 Subject: [PATCH] [IMP] stock: add signature field on picking On a delivery type picking, adds a button to able the partner to sign the delivery on receipt. task-1878607 closes odoo/odoo#39183 Signed-off-by: Simon Lejeune (sle) Co-authored-by: sle-odoo --- addons/stock/models/res_config_settings.py | 1 + addons/stock/models/stock_picking.py | 19 +++++++++++++++++++ addons/stock/report/report_deliveryslip.xml | 12 ++++++++++++ addons/stock/security/stock_security.xml | 5 +++++ .../stock/views/res_config_settings_views.xml | 11 +++++++++++ addons/stock/views/stock_picking_views.xml | 7 +++++++ 6 files changed, 55 insertions(+) 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.

+ +
+
+ Signature +
+
+ +
+
+

+

+
diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml index f4ea1c0ae29..7b2c39f580c 100644 --- a/addons/stock/security/stock_security.xml +++ b/addons/stock/security/stock_security.xml @@ -58,6 +58,11 @@ A warning can be set on a partner (Stock) + + + Require a signature on your delivery orders + + diff --git a/addons/stock/views/res_config_settings_views.xml b/addons/stock/views/res_config_settings_views.xml index d3c9f605fff..572d8ace382 100644 --- a/addons/stock/views/res_config_settings_views.xml +++ b/addons/stock/views/res_config_settings_views.xml @@ -93,6 +93,17 @@ +
+
+ +
+
+
+
diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml index 73d5713ce5d..18a6d46bfaf 100644 --- a/addons/stock/views/stock_picking_views.xml +++ b/addons/stock/views/stock_picking_views.xml @@ -194,6 +194,7 @@ + @@ -227,6 +228,12 @@