feat(plating): MO smart buttons — Sale Order + Work Orders + Receiving

Manager / operator opening an MO had no way to jump back to the
originating SO, see the WO list, or check the receiving record
without going through menus. Add three smart buttons in the MO
form's button-box:

  • [📄 Sale Order] — opens the source SO (resolved via mo.origin)
  • [⚙ Work Orders 9] — list view filtered by production_id
  • [🚚 Receiving 1] — opens the fp.receiving record (or list when
    multiple), filtered by mo.x_fc_sale_order_id

New computed fields on mrp.production (non-stored — recomputed on
view load, no migration cost):
  • x_fc_sale_order_id      — Many2one resolved from origin
  • x_fc_workorder_count    — len(workorder_ids)
  • x_fc_receiving_count    — search_count on fp.receiving

Each button hides itself when count is zero / link unresolvable, so
brand-new draft MOs without a source SO don't show stale buttons.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-19 13:27:29 -04:00
parent 5c3e7a3cf3
commit 6d90789967
3 changed files with 118 additions and 1 deletions

View File

@@ -64,6 +64,30 @@
</xpath>
<xpath expr="//div[@name='button_box']" position="inside">
<!-- Sale Order — back to the customer's order -->
<button name="action_view_sale_order" type="object"
class="oe_stat_button" icon="fa-file-text-o"
invisible="not x_fc_sale_order_id">
<div class="o_stat_info">
<span class="o_stat_value">
<field name="x_fc_sale_order_id" nolabel="1" readonly="1"/>
</span>
<span class="o_stat_text">Sale Order</span>
</div>
</button>
<!-- Work Orders — drill into the WO list -->
<button name="action_view_workorders" type="object"
class="oe_stat_button" icon="fa-cogs">
<field name="x_fc_workorder_count" widget="statinfo"
string="Work Orders"/>
</button>
<!-- Receiving — link to the parts-receiving record(s) -->
<button name="action_view_receiving" type="object"
class="oe_stat_button" icon="fa-truck"
invisible="x_fc_receiving_count == 0">
<field name="x_fc_receiving_count" widget="statinfo"
string="Receiving"/>
</button>
<button name="action_configure_recipe_steps" type="object"
class="oe_stat_button" icon="fa-sliders"
invisible="not x_fc_recipe_id">