From 39d7346cca5872f899a1c7265c39679c3951101a Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 11 Dec 2024 12:13:15 +0100 Subject: [PATCH] [IMP] mrp_usability: Change condition to show "Check Availability" and "Unreserve" buttons. --- mrp_usability/README.rst | 6 ++++- mrp_usability/__manifest__.py | 2 +- mrp_usability/models/mrp_production.py | 26 ++++++++++++++++++++ mrp_usability/views/mrp_production_views.xml | 14 +++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/mrp_usability/README.rst b/mrp_usability/README.rst index 84e6416f..cae54e1b 100644 --- a/mrp_usability/README.rst +++ b/mrp_usability/README.rst @@ -6,10 +6,14 @@ Manufacturing Usability ======================= -* The buttons that are in the tree view of the work order, put them also in the form view. +* The buttons that are in the tree view of the work order, put them also in the + form view. * Link from Production to Work Orders. * In manufacturing order form new tab "Move Lines", and new field "Finished Move lines". +* Show "Unreserve" button, only if there is a reserved component. +* Show "Check Availabitiy", only if some component is not reserved, or partially + reserved. Bug Tracker =========== diff --git a/mrp_usability/__manifest__.py b/mrp_usability/__manifest__.py index 97db58a5..1be81fe1 100644 --- a/mrp_usability/__manifest__.py +++ b/mrp_usability/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Manufacturing Usability", - "version": "16.0.1.1.0", + "version": "16.0.1.2.0", "author": "AvanzOSC", "website": "https://github.com/avanzosc/mrp-addons", "category": "Hidden", diff --git a/mrp_usability/models/mrp_production.py b/mrp_usability/models/mrp_production.py index bbb0f8e9..0032632d 100644 --- a/mrp_usability/models/mrp_production.py +++ b/mrp_usability/models/mrp_production.py @@ -33,6 +33,32 @@ def _compute_workorder_count(self): ("location_dest_id", "in", self.location_dest_id.ids), ], ) + show_check_availability_button = fields.Boolean( + string="Show Check Availability Button", + compute="_compute_show_check_availability_button", + ) + show_do_unreserve_button = fields.Boolean( + string="Show Do Unreserve Button", compute="_compute_show_do_unreserve_button" + ) + + def _compute_show_check_availability_button(self): + for production in self: + if any( + [ + x.state in ("confirmed", "partially_available") + for x in production.move_raw_ids + ] + ): + production.show_check_availability_button = True + else: + production.show_check_availability_button = False + + def _compute_show_do_unreserve_button(self): + for production in self: + if any([x.state == "assigned" for x in production.move_raw_ids]): + production.show_do_unreserve_button = True + else: + production.show_do_unreserve_button = False def action_view_workorder(self): self.ensure_one() diff --git a/mrp_usability/views/mrp_production_views.xml b/mrp_usability/views/mrp_production_views.xml index e2f77dc7..f921dd0b 100644 --- a/mrp_usability/views/mrp_production_views.xml +++ b/mrp_usability/views/mrp_production_views.xml @@ -4,6 +4,20 @@ mrp.production + + + + + +