fix(part-catalog): upload slot + swapped Number/Name + smart buttons
Three fixes on fp.part.catalog form:
1. 3D Model upload actually works now. The old field exposed only a
Many2one search dropdown — no way to add a new file. Added a
Binary upload slot (model_upload + model_upload_filename) that
fires an onchange which wraps the bytes in an ir.attachment and
links it to model_attachment_id. The upload slot is hidden once a
model is already attached, so the current file stays visible.
Accepts STEP/STP/STL/IGES/IGS/BREP. Auto-runs the surface-area
calculation after attach, same as before.
2. Part Number is now the big <h1> title, Part Name is the smaller
field underneath. Matches how plating shops actually identify
parts (by customer part number, not a free-text name). Swapped
column order in the list view too — Part Number first, then Name.
3. Four smart buttons now on the part form:
- Customer → opens res.partner record
- Sale Orders (already existed)
- Work Orders → filtered mrp.workorder list across SOs for this part
- Quotes (already existed)
- Revisions → shown only when 2+ revs exist, opens the revision
tree filtered by root part
New compute fields workorder_count + revision_count feed the
statinfo widgets, with matching action_view_customer,
action_view_workorders, action_view_revisions handlers.
Verified on demo data:
VS-ESMC6H00801P01 → SO=2, WO=18, REV=2
VS-PQR8440 → SO=1, WO=9, REV=3
All counts light up, buttons drill in cleanly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,8 +12,9 @@
|
||||
<field name="model">fp.part.catalog</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="Part Catalog" decoration-muted="not active">
|
||||
<field name="partner_id"/>
|
||||
<field name="part_number"/>
|
||||
<field name="name" string="Part Name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="revision"/>
|
||||
<field name="substrate_material"/>
|
||||
<field name="surface_area"/>
|
||||
@@ -38,6 +39,15 @@
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="action_view_customer"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-user"
|
||||
invisible="not partner_id">
|
||||
<div class="o_stat_info">
|
||||
<span class="o_stat_text">Customer</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_view_sale_orders"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
@@ -45,6 +55,13 @@
|
||||
invisible="sale_order_count == 0">
|
||||
<field name="sale_order_count" widget="statinfo" string="Sale Orders"/>
|
||||
</button>
|
||||
<button name="action_view_workorders"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-cogs"
|
||||
invisible="workorder_count == 0">
|
||||
<field name="workorder_count" widget="statinfo" string="Work Orders"/>
|
||||
</button>
|
||||
<button name="action_view_configurators"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
@@ -52,13 +69,20 @@
|
||||
invisible="configurator_count == 0">
|
||||
<field name="configurator_count" widget="statinfo" string="Quotes"/>
|
||||
</button>
|
||||
<button name="action_view_revisions"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-code-fork"
|
||||
invisible="revision_count < 2">
|
||||
<field name="revision_count" widget="statinfo" string="Revisions"/>
|
||||
</button>
|
||||
</div>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="text-bg-danger" invisible="active"/>
|
||||
<widget name="web_ribbon" title="Superseded" bg_color="text-bg-warning" invisible="is_latest_revision"/>
|
||||
<div class="oe_title">
|
||||
<label for="name"/>
|
||||
<h1><field name="name" placeholder="e.g. Valve Body Housing"/></h1>
|
||||
<field name="part_number" placeholder="Customer part number (e.g. VS-R392007E01)"/>
|
||||
<label for="part_number" string="Part Number"/>
|
||||
<h1><field name="part_number" placeholder="e.g. VS-R392007E01"/></h1>
|
||||
<field name="name" placeholder="Descriptive part name (e.g. Valve Body Housing)"/>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
@@ -131,7 +155,26 @@
|
||||
</page>
|
||||
<page string="Attachments" name="attachments">
|
||||
<group>
|
||||
<field name="model_attachment_id"/>
|
||||
<!-- Upload slot: Binary field that wraps the file
|
||||
in an ir.attachment on change. Hidden once a
|
||||
3D model is already attached. -->
|
||||
<label for="model_upload" string="Upload 3D Model"
|
||||
invisible="model_attachment_id"/>
|
||||
<div class="o_row" invisible="model_attachment_id">
|
||||
<field name="model_upload" nolabel="1"
|
||||
filename="model_upload_filename"
|
||||
class="oe_inline"/>
|
||||
<field name="model_upload_filename" invisible="1"/>
|
||||
<span class="text-muted ms-2 small">
|
||||
STEP / STP / STL / IGES / IGS / BREP
|
||||
</span>
|
||||
</div>
|
||||
<!-- Current attachment + remove affordance -->
|
||||
<label for="model_attachment_id" string="3D Model File"
|
||||
invisible="not model_attachment_id"/>
|
||||
<div class="o_row" invisible="not model_attachment_id">
|
||||
<field name="model_attachment_id" nolabel="1" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="drawing_attachment_ids" widget="fp_pdf_preview_binary"/>
|
||||
</group>
|
||||
<div invisible="not model_attachment_id" class="mt-3">
|
||||
|
||||
Reference in New Issue
Block a user