[IMP] stock: reduce steps required to process a stock.picking
When pickings are created or modified they will be automatically 'Marked as todo'. Draft pickings can still be created through the 'Planned transfer' link on the stock.picking.type kanban card.
This commit is contained in:
@@ -189,9 +189,9 @@ class StockMove(models.Model):
|
||||
@api.depends('state', 'picking_id')
|
||||
def _compute_is_initial_demand_editable(self):
|
||||
for move in self:
|
||||
if move.state == 'draft':
|
||||
if self._context.get('planned_picking'):
|
||||
move.is_initial_demand_editable = True
|
||||
elif move.state != 'done' and move.picking_id and not move.picking_id.is_locked:
|
||||
elif not move.picking_id.is_locked and move.state != 'done' and move.picking_id:
|
||||
move.is_initial_demand_editable = True
|
||||
else:
|
||||
move.is_initial_demand_editable = False
|
||||
|
||||
@@ -403,7 +403,9 @@ class Picking(models.Model):
|
||||
if len(move) == 3:
|
||||
move[2]['location_id'] = vals['location_id']
|
||||
move[2]['location_dest_id'] = vals['location_dest_id']
|
||||
return super(Picking, self).create(vals)
|
||||
res = super(Picking, self).create(vals)
|
||||
res._autoconfirm_picking()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
@@ -416,6 +418,8 @@ class Picking(models.Model):
|
||||
after_vals['location_dest_id'] = vals['location_dest_id']
|
||||
if after_vals:
|
||||
self.mapped('move_lines').filtered(lambda move: not move.scrapped).write(after_vals)
|
||||
if vals.get('move_lines'):
|
||||
self._autoconfirm_picking()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
@@ -641,6 +645,13 @@ class Picking(models.Model):
|
||||
quantity_done[pack.product_id.id] += pack.qty_done
|
||||
return any(quantity_done[x] < quantity_todo.get(x, 0) for x in quantity_done)
|
||||
|
||||
@api.multi
|
||||
def _autoconfirm_picking(self):
|
||||
if not self._context.get('planned_picking'):
|
||||
for picking in self.filtered(lambda picking: picking.state not in ('done', 'cancel') and picking.move_lines):
|
||||
picking.action_confirm()
|
||||
|
||||
@api.multi
|
||||
def _create_backorder(self, backorder_moves=[]):
|
||||
""" Move all non-done lines into a new backorder picking. If the key 'do_only_split' is given in the context, then move all lines not in context.get('split', []) instead of all non-done lines.
|
||||
"""
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
<button name="action_confirm" attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('id', '=', False)]}" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting')), ('is_locked', '=', False)]}" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
|
||||
<button name="force_assign" attrs="{'invisible': ['|', ('state', 'not in', ('confirmed', 'waiting', 'partially_available')), ('is_locked', '=', False)]}" string="Force Availability" type="object" groups="stock.group_stock_manager"/>
|
||||
<button name="button_validate" attrs="{'invisible': ['|', ('state', 'not in', ('draft', 'partially_available', 'assigned')), ('is_locked', '=', False)]}" string="Validate" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
|
||||
<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="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"/>
|
||||
@@ -268,7 +268,7 @@
|
||||
<field name="is_initial_demand_editable" invisible="1"/>
|
||||
<field name="product_uom_qty" attrs="{'readonly': [('is_initial_demand_editable', '=', False)], 'required': [('product_id', '!=', False)]}"/>
|
||||
<field name="is_locked" invisible="1"/>
|
||||
<field name="qty_done" attrs="{'readonly': ['|', ('is_initial_demand_editable', '=', True), '&', ('state', '=', 'done'), ('is_locked', '=', True)]}"/>
|
||||
<field name="qty_done" attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"/>
|
||||
</tree>
|
||||
</field>
|
||||
<button class="oe_link oe_right" name="put_in_pack" type="object" string="↳Put in Pack" attrs="{'invisible': [('state', 'in', ('done', 'cancel'))]}" groups="stock.group_tracking_lot"/>
|
||||
@@ -295,7 +295,7 @@
|
||||
<field name="is_initial_demand_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': ['|', '|', ('show_details_visible', '=', True), ('state', '=', 'cancel'), '&', ('state', '=', 'done'), ('is_locked', '=', True)], 'invisible': ['|', ('state', 'in', ['draft', 'confirmed', 'waiting']), ('show_operations', '=', True)]}"/>
|
||||
<field name="quantity_done" string="Done" attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)], '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>
|
||||
@@ -716,7 +716,10 @@
|
||||
<span>New</span>
|
||||
</div>
|
||||
<div>
|
||||
<a name="%(action_picking_form)d" type="action" >Transfer</a>
|
||||
<a name="%(action_picking_form)d" type="action">Immediate Transfer</a>
|
||||
</div>
|
||||
<div>
|
||||
<a name="%(action_picking_form)d" type="action" context="{'planned_picking': True}">Planned Transfer</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user