[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) <sle@openerp.com>
Co-authored-by: sle-odoo <sle@odoo.com>
This commit is contained in:
svs-odoo
2019-10-28 10:46:06 +00:00
co-authored by sle-odoo
parent c5fbb9cc23
commit 596b246f93
6 changed files with 55 additions and 0 deletions
@@ -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)
+19
View File
@@ -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
@@ -98,6 +98,18 @@
All items couldn't be shipped, the remaining ones will be shipped as soon as they become available.
</span>
</p>
<div t-if="o.signature" class="mt32 ml64 mr4" name="signature">
<div class="offset-8">
<strong>Signature</strong>
</div>
<div class="offset-8">
<img t-att-src="image_data_uri(o.signature)" style="max-height: 4cm; max-width: 8cm;"/>
</div>
<div class="offset-8 text-center">
<p t-field="o.partner_id.name"/>
</div>
</div>
</div>
</t>
</t>
+5
View File
@@ -58,6 +58,11 @@
<field name="name">A warning can be set on a partner (Stock)</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_stock_sign_delivery" model="res.groups">
<field name="name">Require a signature on your delivery orders</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</data>
<data noupdate="1">
<record id="base.default_user" model="res.users">
@@ -93,6 +93,17 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="group_stock_sign_delivery"/>
</div>
<div class="o_setting_right_pane">
<label for="group_stock_sign_delivery"/>
<div class="text-muted">
Require a signature on your delivery orders
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="delivery" title="Shipping connectors allow to compute accurate shipping costs, print shipping labels and request carrier picking at your warehouse to ship to the customer. Apply shipping connector from delivery methods.">
<div class="o_setting_left_pane">
<field name="module_delivery"/>
@@ -194,6 +194,7 @@
<field name="location_id" options="{'no_create': True}" string="From" groups="stock.group_stock_multi_locations" optional="show"/>
<field name="location_dest_id" options="{'no_create': True}" string="To" groups="stock.group_stock_multi_locations" optional="show"/>
<field name="partner_id" optional="show"/>
<field name="signature" string="Signed" optional="hide" widget="boolean" groups="stock.group_stock_sign_delivery"/>
<field name="user_id" optional="hide"/>
<field name="date" invisible="1"/>
<field name="scheduled_date" optional="show"/>
@@ -227,6 +228,12 @@
<button name="action_assign" attrs="{'invisible': [('show_check_availability', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'in', ('waiting','confirmed')), ('show_validate', '=', False)]}" string="Validate" type="object" class="oe_highlight" groups="stock.group_stock_user"/>
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'not in', ('waiting', 'confirmed')), ('show_validate', '=', False)]}" string="Validate" type="object" groups="stock.group_stock_user" class="o_btn_validate"/>
<widget name="signature" string="Sign" highlight="1"
attrs="{'invisible': ['|', '|', '|', ('id', '=', False), ('picking_type_code', '!=', 'outgoing'), ('state', '!=', 'done'), ('is_locked', '=', False)]}"
full_name="partner_id" groups="stock.group_stock_sign_delivery"/>
<widget name="signature" string="Sign"
attrs="{'invisible': ['|', '|', '|', ('id', '=', False), ('picking_type_code', '!=', 'outgoing'), ('state', '=', 'done'), ('is_locked', '=', False)]}"
full_name="partner_id" groups="stock.group_stock_sign_delivery"/>
<button name="do_print_picking" string="Print" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|', ('state', 'not in', ('assigned', 'partially_available')), ('is_locked', '=', False)]}"/>
<button name="%(action_report_delivery)d" string="Print" attrs="{'invisible': ['|', ('state', '!=', 'done'), ('is_locked', '=', False)]}" type="action" groups="base.group_user"/>
<button name="%(act_stock_return_picking)d" string="Return" attrs="{'invisible': ['|', ('state', '!=', 'done'), ('is_locked', '=', False)]}" type="action" groups="base.group_user"/>