[FIX] stock: remove 'set' and 'clear' quantities buttons
Thanks to ref https://github.com/odoo/odoo/pull/137864, the quantity on stock move can be emptied or fill with the unreserve/reserve mechanism. Those two buttons becomes useless closes odoo/odoo#140116 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
@@ -890,7 +890,7 @@ class TestSubcontractingTracking(TransactionCase):
|
||||
move.quantity = nb_finished_product
|
||||
picking_receipt = picking_form.save()
|
||||
picking_receipt.action_confirm()
|
||||
picking_receipt.action_clear_quantities_to_zero()
|
||||
picking_receipt.do_unreserve()
|
||||
|
||||
# We shouldn't be able to call the 'record_components' button
|
||||
self.assertEqual(picking_receipt.display_action_record_components, 'hide')
|
||||
@@ -1331,7 +1331,7 @@ class TestSubcontractingSerialMassReceipt(TransactionCase):
|
||||
# Receive
|
||||
for quantity in quantities:
|
||||
# Receive <quantity> finished products
|
||||
picking_receipt.action_clear_quantities_to_zero()
|
||||
picking_receipt.do_unreserve()
|
||||
Form(self.env['stock.assign.serial'].with_context(
|
||||
default_move_id=picking_receipt.move_ids[0].id,
|
||||
default_next_serial_number=self.env['stock.lot']._get_next_serial(picking_receipt.company_id, picking_receipt.move_ids[0].product_id) or 'sn#1',
|
||||
@@ -1361,7 +1361,7 @@ class TestSubcontractingSerialMassReceipt(TransactionCase):
|
||||
move.product_uom_qty = quantity
|
||||
picking_receipt = picking_form.save()
|
||||
picking_receipt.action_confirm()
|
||||
picking_receipt.action_clear_quantities_to_zero()
|
||||
picking_receipt.do_unreserve()
|
||||
# Receive finished products
|
||||
Form(self.env['stock.assign.serial'].with_context(
|
||||
default_move_id=picking_receipt.move_ids[0].id,
|
||||
|
||||
@@ -243,7 +243,7 @@ class TestAccountSubcontractingFlows(TestMrpSubcontractingCommon):
|
||||
# Mimic the extra cost on the po line
|
||||
picking_receipt.move_ids.price_unit = 50
|
||||
picking_receipt.action_confirm()
|
||||
picking_receipt.action_clear_quantities_to_zero()
|
||||
picking_receipt.do_unreserve()
|
||||
|
||||
# We should be able to call the 'record_components' button
|
||||
self.assertTrue(picking_receipt.display_action_record_components)
|
||||
|
||||
@@ -788,7 +788,7 @@ Please change the quantity done or the rounding precision of your unit of measur
|
||||
def _do_unreserve(self):
|
||||
moves_to_unreserve = OrderedSet()
|
||||
for move in self:
|
||||
if move.state == 'cancel' or (move.state == 'done' and move.scrapped):
|
||||
if move.state == 'cancel' or (move.state == 'done' and move.scrapped) or move.picked:
|
||||
# We may have cancelled move in an open picking in a "propagate_cancel" scenario.
|
||||
# We may have done move in an open picking in a scrap scenario.
|
||||
continue
|
||||
|
||||
@@ -517,6 +517,7 @@ class Picking(models.Model):
|
||||
('available', 'Available'),
|
||||
('expected', 'Expected'),
|
||||
('late', 'Late')], compute='_compute_products_availability')
|
||||
# To remove in Master
|
||||
show_set_qty_button = fields.Boolean(compute='_compute_show_qty_button')
|
||||
show_clear_qty_button = fields.Boolean(compute='_compute_show_qty_button')
|
||||
|
||||
@@ -529,17 +530,10 @@ class Picking(models.Model):
|
||||
('name_uniq', 'unique(name, company_id)', 'Reference must be unique per company!'),
|
||||
]
|
||||
|
||||
@api.depends('move_ids.product_uom_qty', 'move_ids.quantity')
|
||||
@api.depends()
|
||||
def _compute_show_qty_button(self):
|
||||
self.show_set_qty_button = False
|
||||
self.show_clear_qty_button = False
|
||||
for picking in self:
|
||||
if picking.state in ['draft', 'done', 'cancel']:
|
||||
continue
|
||||
if any(float_is_zero(m.quantity, precision_rounding=m.product_uom.rounding) and not float_is_zero(m.product_uom_qty, precision_rounding=m.product_uom.rounding) for m in picking.move_ids):
|
||||
picking.show_set_qty_button = True
|
||||
elif any(not float_is_zero(m.quantity, precision_rounding=m.product_uom.rounding) for m in picking.move_ids):
|
||||
picking.show_clear_qty_button = True
|
||||
|
||||
def _compute_has_tracking(self):
|
||||
for picking in self:
|
||||
@@ -1164,9 +1158,6 @@ class Picking(models.Model):
|
||||
}
|
||||
return True
|
||||
|
||||
def action_clear_quantities_to_zero(self):
|
||||
self.move_ids.filtered(lambda m: not m.picked)._do_unreserve()
|
||||
|
||||
def _pre_action_done_hook(self):
|
||||
for picking in self:
|
||||
if all(not move.picked for move in picking.move_ids):
|
||||
|
||||
@@ -2433,7 +2433,7 @@ class TestStockUOM(TestStockCommon):
|
||||
'location_dest_id': self.stock_location
|
||||
})
|
||||
picking_in.action_confirm()
|
||||
picking_in.action_clear_quantities_to_zero()
|
||||
picking_in.do_unreserve()
|
||||
|
||||
self.assertEqual(move.product_uom_qty, 60.00, 'Wrong T_GT quantity')
|
||||
self.assertEqual(move.product_qty, 134400.00, 'Wrong T_LBS quantity')
|
||||
|
||||
@@ -2213,12 +2213,10 @@ class TestStockFlow(TestStockCommon):
|
||||
self.assertEqual(move_a.quantity, 10)
|
||||
self.assertEqual(move_b.quantity, 10)
|
||||
|
||||
# test clear qty button without manual change
|
||||
self.assertTrue(picking_in.show_clear_qty_button)
|
||||
picking_in.action_clear_quantities_to_zero()
|
||||
# test unreserve button without manual change
|
||||
picking_in.do_unreserve()
|
||||
self.assertEqual(move_a.quantity, 0)
|
||||
self.assertEqual(move_b.quantity, 0)
|
||||
self.assertFalse(picking_in.show_clear_qty_button)
|
||||
|
||||
# test set qty button with manual change
|
||||
move_a.quantity = 5
|
||||
|
||||
@@ -139,8 +139,6 @@
|
||||
<field name="has_packages" invisible="1"/>
|
||||
<field name="picking_type_entire_packs" invisible="1"/>
|
||||
<field name="use_create_lots" invisible="1"/>
|
||||
<field name="show_set_qty_button" invisible="1"/>
|
||||
<field name="show_clear_qty_button" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
|
||||
<header>
|
||||
@@ -148,7 +146,6 @@
|
||||
<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 ('draft', 'confirmed', 'done', 'cancel')" string="Validate" type="object" class="oe_highlight" groups="stock.group_stock_user" data-hotkey="v"/>
|
||||
<button name="button_validate" invisible="state in ('waiting', 'assigned', 'done', 'cancel')" string="Validate" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="v"/>
|
||||
<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"
|
||||
invisible="not id or picking_type_code != 'outgoing' or state != 'done'"
|
||||
full_name="partner_id" groups="stock.group_stock_sign_delivery"/>
|
||||
|
||||
@@ -57,22 +57,14 @@ class StockPickingBatch(models.Model):
|
||||
- If not manually changed and transfers are added/removed/updated then this will be their earliest scheduled date
|
||||
but this scheduled date will not be set for all transfers in batch.""")
|
||||
is_wave = fields.Boolean('This batch is a wave')
|
||||
# To remove in master
|
||||
show_set_qty_button = fields.Boolean(compute='_compute_show_qty_button')
|
||||
show_clear_qty_button = fields.Boolean(compute='_compute_show_qty_button')
|
||||
|
||||
@api.depends('state',
|
||||
'picking_ids.show_set_qty_button',
|
||||
'picking_ids.show_clear_qty_button')
|
||||
@api.depends()
|
||||
def _compute_show_qty_button(self):
|
||||
self.show_set_qty_button = False
|
||||
self.show_clear_qty_button = False
|
||||
for batch in self:
|
||||
if batch.state != 'in_progress':
|
||||
continue
|
||||
if any(p.show_set_qty_button for p in self.picking_ids):
|
||||
batch.show_set_qty_button = True
|
||||
elif any(p.show_clear_qty_button for p in self.picking_ids):
|
||||
batch.show_clear_qty_button = True
|
||||
|
||||
@api.depends('company_id', 'picking_type_id', 'state')
|
||||
def _compute_allowed_picking_ids(self):
|
||||
@@ -194,9 +186,6 @@ class StockPickingBatch(models.Model):
|
||||
self.ensure_one()
|
||||
return self.env.ref('stock_picking_batch.action_report_picking_batch').report_action(self)
|
||||
|
||||
def action_clear_quantities_to_zero(self):
|
||||
self.picking_ids.filtered("show_clear_qty_button").action_clear_quantities_to_zero()
|
||||
|
||||
def action_done(self):
|
||||
def has_no_quantity(picking):
|
||||
return all(not m.picked or float_is_zero(m.quantity, precision_rounding=m.product_uom.rounding) for m in picking.move_ids if m.state not in ('done', 'cancel'))
|
||||
|
||||
@@ -72,8 +72,6 @@
|
||||
<field name="show_allocation" invisible="1"/>
|
||||
<field name="picking_type_code" invisible="1"/>
|
||||
<field name="is_wave" invisible="1"/>
|
||||
<field name="show_set_qty_button" invisible="1"/>
|
||||
<field name="show_clear_qty_button" invisible="1"/>
|
||||
<header>
|
||||
<button name="action_confirm" invisible="state != 'draft'" string="Confirm" type="object" class="oe_highlight"/>
|
||||
<button name="action_done" string="Validate" type="object" class="oe_highlight"
|
||||
@@ -82,8 +80,6 @@
|
||||
invisible="state != 'in_progress' or not show_check_availability"/>
|
||||
<button name="action_done" string="Validate" type="object"
|
||||
invisible="state != 'in_progress' or not show_check_availability"/>
|
||||
<button name="action_clear_quantities_to_zero" string="Clear quantities" type="object"
|
||||
invisible="not show_clear_qty_button"/>
|
||||
<button name="action_assign" string="Check Availability" type="object"
|
||||
invisible="state != 'draft' or not show_check_availability"/>
|
||||
<button name="action_print" invisible="state not in ('in_progress', 'done')" string="Print" type="object"/>
|
||||
|
||||
Reference in New Issue
Block a user