Skip to content

Commit

Permalink
[IMP] mrp_usability: Change condition to show "Check Availability" an…
Browse files Browse the repository at this point in the history
…d "Unreserve" buttons.
  • Loading branch information
alfredoavanzosc committed Dec 11, 2024
1 parent be17141 commit 39d7346
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mrp_usability/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand Down
2 changes: 1 addition & 1 deletion mrp_usability/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 26 additions & 0 deletions mrp_usability/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions mrp_usability/views/mrp_production_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<field name="reservation_state" position="after">
<field name="show_check_availability_button" invisible="1" />
<field name="show_do_unreserve_button" invisible="1" />
</field>
<button name="action_assign" position="attributes">
<attribute
name="attrs"
>{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('show_check_availability_button', '=', False)]}</attribute>
</button>
<button name="do_unreserve" position="attributes">
<attribute
name="attrs"
>{'invisible': [('show_do_unreserve_button', '=', False)]}</attribute>
</button>
<button name="%(mrp.action_mrp_production_moves)d" position="attributes">
<attribute
name="attrs"
Expand Down

0 comments on commit 39d7346

Please sign in to comment.