[FIX] stock: hide reset to draft button when no needed
Only immediate transfers should have the ability to reset the state to draft. Also rewording it as "Plan" as the goal of this button is to left the stock move to be done later and impact the forecast Task: 3256447 Part-of: odoo/odoo#124409
This commit is contained in:
@@ -932,9 +932,12 @@ class Picking(models.Model):
|
||||
picking_to_reset = self.filtered(lambda p: p.state not in ('done', 'cancel'))
|
||||
picking_to_reset.do_unreserve()
|
||||
picking_to_reset.immediate_transfer = False
|
||||
picking_to_reset.move_ids.quantity_done = 0
|
||||
picking_to_reset.move_ids.move_line_ids.unlink()
|
||||
picking_to_reset.move_ids.state = 'draft'
|
||||
if picking_to_reset.move_ids:
|
||||
picking_to_reset.move_ids.quantity_done = 0
|
||||
picking_to_reset.move_ids.move_line_ids.unlink()
|
||||
picking_to_reset.move_ids.state = 'draft'
|
||||
else:
|
||||
picking_to_reset.state = 'draft'
|
||||
|
||||
def _action_done(self):
|
||||
"""Call `_action_done` on the `stock.move` of the `stock.picking` in `self`.
|
||||
|
||||
@@ -22,3 +22,14 @@ class TestPicking(common.TransactionCase):
|
||||
})
|
||||
self.assertEqual(
|
||||
er.exception.args[0], f'Sequences {operation_type_1.sequence_id.name} already exist.')
|
||||
|
||||
def test_empty_picking_draft(self):
|
||||
""" test an empty still can be reset to draft """
|
||||
picking = self.env['stock.picking'].create({
|
||||
'picking_type_id': self.env.ref('stock.picking_type_in').id,
|
||||
'location_id': self.env.ref('stock.stock_location_stock').id,
|
||||
'location_dest_id': self.env.ref('stock.stock_location_stock').id,
|
||||
})
|
||||
self.assertFalse(picking.move_ids)
|
||||
picking.action_reset_draft()
|
||||
self.assertEqual(picking.state, 'draft')
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
<button name="action_assign" invisible="not show_check_availability" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user" data-hotkey="w"/>
|
||||
<button name="button_validate" invisible="state in ('waiting', 'confirmed', 'draft', 'done', 'cancel') or not show_validate" string="Validate" type="object" class="oe_highlight" groups="stock.group_stock_user" data-hotkey="v"/>
|
||||
<button name="button_validate" invisible="state in ('draft', 'assigned', 'done', 'cancel') or not show_validate" string="Validate" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="v"/>
|
||||
<button name="action_reset_draft" invisible="state in ('draft', 'done', 'cancel')" string="Set Draft" type="object" groups="stock.group_stock_user" class="o_highlight" data-hotkey="d"/>
|
||||
<button name="action_reset_draft" invisible="state in ('draft', 'done', 'cancel') or not immediate_transfer" string="Plan" type="object" groups="stock.group_stock_user" class="o_highlight" data-hotkey="d"/>
|
||||
<button name="action_set_quantities_to_reservation" invisible="not show_set_qty_button" string="Set quantities" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="g"/>
|
||||
<button name="action_clear_quantities_to_zero" invisible="not show_clear_qty_button" string="Clear quantities" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="g"/>
|
||||
<widget name="signature" string="Sign" highlight="1"
|
||||
|
||||
Reference in New Issue
Block a user