summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJoren Van Onder <jov@odoo.com>2017-09-18 17:05:03 -0700
committeramoyaux <arm@odoo.com>2017-09-20 15:08:36 +0200
commit46cfc2e41dbd458fdf493e22697ef411dae69c43 (patch)
treec92582116d04c36779f50c397c65744b8d7e5717 /addons
parent2e837d69515395d5af71e2dab7f5b71c8af3492a (diff)
[IMP] stock: limit user actions on planned stock.picking form views
Don't allow immediate edition of quantity_done, marking as todo and immediate validation.
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/models/stock_move.py12
-rw-r--r--addons/stock/models/stock_picking.py28
-rw-r--r--addons/stock/views/stock_picking_views.xml9
3 files changed, 46 insertions, 3 deletions
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 52727d083cb..f248e727b86 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -156,6 +156,7 @@ class StockMove(models.Model):
additional = fields.Boolean("Whether the move was added after the picking's confirmation", default=False)
is_locked = fields.Boolean(related='picking_id.is_locked', readonly=True)
is_initial_demand_editable = fields.Boolean('Is initial demand editable', compute='_compute_is_initial_demand_editable')
+ is_quantity_done_editable = fields.Boolean('Is quantity done editable', compute='_compute_is_quantity_done_editable')
@api.depends('product_id', 'has_tracking', 'move_line_ids', 'location_id', 'location_dest_id')
def _compute_show_details_visible(self):
@@ -196,6 +197,17 @@ class StockMove(models.Model):
else:
move.is_initial_demand_editable = False
+ @api.multi
+ @api.depends('state', 'picking_id')
+ def _compute_is_quantity_done_editable(self):
+ for move in self:
+ if self._context.get('planned_picking') and move.picking_id.state == 'draft':
+ move.is_quantity_done_editable = False
+ elif move.picking_id.is_locked and move.state in ('done', 'cancel'):
+ move.is_quantity_done_editable = False
+ else:
+ move.is_quantity_done_editable = True
+
@api.one
@api.depends('product_id', 'product_uom', 'product_uom_qty')
def _compute_product_qty(self):
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 078b1172ca2..f01532da49d 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -271,6 +271,12 @@ class Picking(models.Model):
show_check_availability = fields.Boolean(
compute='_compute_show_check_availability',
help='Technical field used to compute whether the check availability button should be shown.')
+ show_mark_as_todo = fields.Boolean(
+ compute='_compute_show_mark_as_todo',
+ help='Technical field used to compute whether the mark as todo button should be shown.')
+ show_validate = fields.Boolean(
+ compute='_compute_show_validate',
+ help='Technical field used to compute whether the validate should be shown.')
owner_id = fields.Many2one(
'res.partner', 'Owner',
@@ -371,6 +377,28 @@ class Picking(models.Model):
)
picking.show_check_availability = picking.is_locked and picking.state in ('confirmed', 'waiting') and has_moves_to_reserve
+ @api.multi
+ @api.depends('state')
+ def _compute_show_mark_as_todo(self):
+ for picking in self:
+ if self._context.get('planned_picking') and picking.state == 'draft':
+ picking.show_mark_as_todo = True
+ elif picking.state != 'draft' or not picking.id:
+ picking.show_mark_as_todo = False
+ else:
+ picking.show_mark_as_todo = True
+
+ @api.multi
+ @api.depends('state', 'is_locked')
+ def _compute_show_validate(self):
+ for picking in self:
+ if self._context.get('planned_picking') and picking.state == 'draft':
+ picking.show_validate = False
+ elif picking.state not in ('draft', 'confirmed', 'assigned') or not picking.is_locked:
+ picking.show_validate = False
+ else:
+ picking.show_validate = True
+
@api.onchange('picking_type_id', 'partner_id')
def onchange_picking_type(self):
if self.picking_type_id:
diff --git a/addons/stock/views/stock_picking_views.xml b/addons/stock/views/stock_picking_views.xml
index 3dc8dcbb43d..987cbbea883 100644
--- a/addons/stock/views/stock_picking_views.xml
+++ b/addons/stock/views/stock_picking_views.xml
@@ -201,10 +201,12 @@
<form string="Transfer">
<header>
<field name="is_locked" invisible="1"/>
+ <field name="show_mark_as_todo" invisible="1"/>
<field name="show_check_availability" invisible="1"/>
- <button name="action_confirm" attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('id', '=', False)]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
+ <field name="show_validate" invisible="1"/>
+ <button name="action_confirm" attrs="{'invisible': [('show_mark_as_todo', '=', False)]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
<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', 'not in', ('draft', 'confirmed', 'assigned')), ('is_locked', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
+ <button name="button_validate" attrs="{'invisible': [('show_validate', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
<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"/>
@@ -293,9 +295,10 @@
<field name="product_id" required="1" attrs="{'readonly': ['&amp;', ('state', '!=', 'draft'), ('additional', '=', False)]}"/>
<field name="is_initial_demand_editable" invisible="1"/>
+ <field name="is_quantity_done_editable" invisible="1"/>
<field name="product_uom_qty" string="Initial Demand" attrs="{'readonly': [('is_initial_demand_editable', '=', False)]}"/>
<field name="reserved_availability" string="Reserved" invisible="context.get('picking_type_code') == 'incoming'"/>
- <field name="quantity_done" string="Done" attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)], 'invisible': [('show_operations', '=', True)]}"/>
+ <field name="quantity_done" string="Done" attrs="{'readonly': [('is_quantity_done_editable', '=', False)], 'invisible': [('show_operations', '=', True)]}"/>
<field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft'), ('additional', '=', False)]}" options="{'no_open': True, 'no_create': True}" string="Unit of Measure" groups="product.group_uom"/>
<button name="action_show_details" string="Register lots, packs, location" type="object" icon="fa-list" attrs="{'invisible': [('show_details_visible', '=', False)]}"/>
</tree>