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 2f5e107
Show file tree
Hide file tree
Showing 9 changed files with 98 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
11 changes: 11 additions & 0 deletions mrp_usability/i18n/ca_ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:mrp_usability.mrp_production_form_view
msgid "Work Orders"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_check_availability_button
msgid "Show Check Availability Button"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_do_unreserve_button
msgid "Show Do Unreserve Button"
msgstr ""

11 changes: 11 additions & 0 deletions mrp_usability/i18n/en_GB.po
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:mrp_usability.mrp_production_form_view
msgid "Work Orders"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_check_availability_button
msgid "Show Check Availability Button"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_do_unreserve_button
msgid "Show Do Unreserve Button"
msgstr ""

10 changes: 10 additions & 0 deletions mrp_usability/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ msgstr "Órdenes de Trabajo"
msgid "Move Lines"
msgstr "Operaciones detalladas"

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_check_availability_button
msgid "Show Check Availability Button"
msgstr "Mostrar boton comprobar disponibilidad"

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_do_unreserve_button
msgid "Show Do Unreserve Button"
msgstr "Mostrar botón anular reserva"

11 changes: 11 additions & 0 deletions mrp_usability/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:mrp_usability.mrp_production_form_view
msgid "Work Orders"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_check_availability_button
msgid "Show Check Availability Button"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_do_unreserve_button
msgid "Show Do Unreserve Button"
msgstr ""

10 changes: 10 additions & 0 deletions mrp_usability/i18n/mrp_usability.pot
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ msgstr ""
msgid "Move Lines"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_check_availability_button
msgid "Show Check Availability Button"
msgstr ""

#. module: mrp_usability
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__show_do_unreserve_button
msgid "Show Do Unreserve Button"
msgstr ""

25 changes: 25 additions & 0 deletions mrp_usability/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ def _compute_workorder_count(self):
("location_dest_id", "in", self.location_dest_id.ids),
],
)
show_check_availability_button = fields.Boolean(
compute="_compute_show_check_availability_button"
)
show_do_unreserve_button = fields.Boolean(
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 2f5e107

Please sign in to comment.