From 5c199e60eb8f36483eb2b263b575756bc8e63a42 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Mon, 13 Nov 2023 15:36:20 +0100 Subject: [PATCH] [FIX] repair: minor bugfixes This commit fixes the following issues: 1. Before this commit, when adding a new move in a repair order, its default quantity was equal to the repair order's product quantity. The move's quantity should be 1 by default; 2. The `forecast_availability` is renamed from "Reserved" to "Forecasted"; 3. Removes the "Clear Quantities" button since it does basically the same thing than the "Unreserve" button. closes odoo/odoo#141849 Signed-off-by: William Henrotin (whe) --- addons/repair/models/repair.py | 17 ++++++----------- addons/repair/views/repair_views.xml | 7 ++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index cf74b76adbc..fb380a1deb8 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -164,8 +164,8 @@ class Repair(models.Model): picking_product_ids = fields.One2many('product.product', compute='compute_picking_product_ids') picking_product_id = fields.Many2one(related="picking_id.product_id") # UI Fields - show_set_qty_button = fields.Boolean(compute='_compute_show_qty_button') - show_clear_qty_button = fields.Boolean(compute='_compute_show_qty_button') + show_set_qty_button = fields.Boolean(compute='_compute_show_qty_button') # TODO: remove in master. + show_clear_qty_button = fields.Boolean(compute='_compute_show_qty_button') # TODO: remove in master. unreserve_visible = fields.Boolean( 'Allowed to Unreserve Production', compute='_compute_unreserve_visible', help='Technical field to check when we can unreserve') @@ -255,11 +255,6 @@ class Repair(models.Model): def _compute_show_qty_button(self): self.show_set_qty_button = False self.show_clear_qty_button = False - for repair in self.filtered(lambda r: r.state not in ['cancel', 'done']): - 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 repair.move_ids): - repair.show_set_qty_button = True - elif any(not float_is_zero(m.quantity, precision_rounding=m.product_uom.rounding) for m in repair.move_ids): - repair.show_clear_qty_button = True @api.depends('move_ids', 'state', 'move_ids.product_uom_qty') def _compute_unreserve_visible(self): @@ -267,7 +262,10 @@ class Repair(models.Model): already_reserved = repair.state not in ('done', 'cancel') and any(repair.mapped('move_ids.move_line_ids.quantity')) repair.unreserve_visible = already_reserved - repair.reserve_visible = repair.state in ('confirmed', 'under_repair') and any(move.product_uom_qty and move.state in ['confirmed', 'partially_available'] for move in repair.move_ids) + repair.reserve_visible = ( + repair.state in ('confirmed', 'under_repair') and + any(not move.picked and move.product_uom_qty and move.state in ['confirmed', 'partially_available'] for move in repair.move_ids) + ) @api.onchange('product_uom') def onchange_product_uom(self): @@ -323,9 +321,6 @@ class Repair(models.Model): def action_assign(self): return self.move_ids._action_assign() - def action_clear_quantities_to_zero(self): - return self.move_ids.filtered(lambda m: float_compare(m.quantity, m.reserved_availability, precision_rounding=m.product_uom.rounding) == 0)._clear_quantities_to_zero() - def action_create_sale_order(self): if any(repair.sale_order_id for repair in self): concerned_ro = self.filtered('sale_order_id') diff --git a/addons/repair/views/repair_views.xml b/addons/repair/views/repair_views.xml index 77dd9c0a32f..6ea7884db21 100644 --- a/addons/repair/views/repair_views.xml +++ b/addons/repair/views/repair_views.xml @@ -61,13 +61,10 @@
- -