feat(fusion_repairs): Bundle 8 - rush service + emergency pricing + parts-ordered workflow

The grumpy-old-customer-with-broken-stairlift scenario. Four real workflows
the office faces every week, with comms baked in so the client never has to
call back asking for status.

NEW MODELS
- fusion.repair.emergency.charge (rate card)
  Per (category, tier) rate with per_tech_multiplier; 5 tiers
  (same_day / next_day / after_hours / weekend / holiday). Each category
  can have its own rates - bed motors need 2 techs, stairlift is single.
  Seeded with realistic Westin rates: stairlift same-day $250, weekend
  $450; porch lift same-day $300; bed same-day $175 with 0.6 multiplier
  (2-tech jobs frequent); powerchair same-day $200.

- fusion.repair.part.order (procurement-facing record)
  One per distinct part the tech needs from the manufacturer. Carries
  description + OEM # + manufacturer + quantity + photos + notes.
  4-state lifecycle: draft -> ordered -> received -> fitted (or
  cancelled). On state transitions:
    draft -> ordered:  email client "ordered, expected by X"
    ordered -> received: email client "arrived, scheduling return visit"
                         + auto-create follow-up dispatch task when ALL
                         outstanding parts on the repair have arrived.

REPAIR.ORDER EXTENSIONS
- Rush fields: x_fc_rush_requested, x_fc_rush_tier,
  x_fc_rush_techs_required, x_fc_rush_surcharge (computed via rate card),
  x_fc_rush_acknowledged_at + x_fc_rush_acknowledged_by_id (audit trail
  proving CS got verbal OK before charging).
- Parts-awaiting fields: x_fc_parts_awaiting + x_fc_parts_eta_date +
  x_fc_part_order_ids One2many + x_fc_part_order_count.

- New methods:
  * action_acknowledge_rush() - one-click "client agreed" with audit.
  * action_squeeze_into_today() - picks the lightest-loaded skilled tech,
    finds their first free 1-hour slot between 9am-6pm, schedules the
    task in it, sends:
      1) live bus.bus push to the tech (sticky notification in their
         web client - so they see it MID-SHIFT)
      2) rush-alert email (force_send=True - this can't wait in the queue)
      3) chatter post on the tech task itself
    Validates against fusion_tasks' time-conflict rule by passing
    force_schedule via context (intake.service honours it).
  * action_view_part_orders() - smart button.

WIZARD EXTENSIONS
- repair.intake.wizard:
  New rush_requested + rush_tier + rush_techs_required + rush_acknowledged
  controls. Live rush_surcharge_preview compute shows CS the price in
  real-time as they change category / tier / tech count. Yellow alert
  reminds CS to read the price to the client BEFORE submitting.

- repair.visit.report.wizard:
  New outcome radio: completed / parts_needed / rescheduled.
  When outcome=parts_needed, needs_parts_line_ids One2many appears for
  the tech to capture each part (description, OEM, manufacturer, qty,
  lead days, notes, photos). On submit each line creates a
  fusion.repair.part.order, the repair flips to x_fc_parts_awaiting=True
  with an ETA, and the client gets the "we found the problem, here's the
  plan" email immediately.

INTAKE SERVICE
- _create_dispatch_task now honours force_schedule (date + time_start +
  time_end) via context so squeeze + auto-redispatch don't crash on
  fusion_tasks' time-window validator.
- _create_single_repair carries rush_requested/tier/techs through to
  the new repair fields.

MAIL TEMPLATES (4 new)
- email_template_rush_tech_alert: red 4px accent, address + phone + the
  $surcharge - what the tech needs to know mid-shift.
- email_template_repair_awaiting_parts: amber accent, "we found the
  problem, parts ordered, return visit ~ETA, no action needed".
- email_template_parts_ordered: blue, per-part confirmation.
- email_template_parts_received: green, "arrived, office will call to
  confirm visit".

UI / NAVIGATION
- Backend wizard: rush controls + live surcharge preview + verbal-OK alert.
- repair.order form: new Rush / Parts notebook tab with all the fields
  + linked part orders list. Two new header buttons (Squeeze into
  Today / Client Agreed to Rush Price). Two new search filters
  (Rush, Awaiting Parts).
- Part Order form: statusbar with the 4 transitions + Cancel; notes +
  photos notebook tabs; full chatter for audit.
- Menus: 'Parts to Order' under root; 'Emergency Surcharges' under
  Configuration.

SECURITY
- 8 new ACL entries (emergency_charge user/manager; part_order
  user/dispatcher/manager/technician; visit_report partline for office
  and field tech). Office sees parts but only managers can edit
  emergency rates.

Verified end-to-end on local westin-v19 - all 4 scenarios green:
  S1 Same-day rush stairlift -> $250 surcharge, ack stamped, squeeze
     assigned garry@ at first free 1h slot today, alert email queued,
     chatter posted.
  S2 Next-day priority bed -> $0 surcharge (no rate seeded for bed
     next_day - office can configure), 4 emails queued (client + office).
  S3 2-tech weekend stairlift -> $675 (450 base + 0.5x base for 2nd tech).
  S4 Parts-needed visit-report -> 2 PART-#### records created, repair
     awaiting_parts=True, ETA=2026-06-06, office activity scheduled,
     client email sent. Marking part ordered -> client mail. Marking
     all parts received -> auto-dispatch follow-up + client mail.

Bumped to 19.0.1.9.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
gsinghpal
2026-05-21 01:28:13 -04:00
parent 4f1b7c2df6
commit ebbadb3002
18 changed files with 1367 additions and 8 deletions

View File

@@ -51,6 +51,18 @@
action="action_service_plan_subscription"
sequence="37"/>
<menuitem id="menu_fusion_repairs_part_orders"
name="Parts to Order"
parent="menu_fusion_repairs_root"
action="action_repair_part_order"
sequence="38"/>
<menuitem id="menu_fusion_repairs_emergency_charges"
name="Emergency Surcharges"
parent="menu_fusion_repairs_configuration"
action="action_repair_emergency_charge"
sequence="60"/>
<!-- Configuration -->
<menuitem id="menu_fusion_repairs_configuration"
name="Configuration"

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_repair_emergency_charge_list" model="ir.ui.view">
<field name="name">fusion.repair.emergency.charge.list</field>
<field name="model">fusion.repair.emergency.charge</field>
<field name="arch" type="xml">
<list string="Rush / Emergency Surcharges" editable="bottom">
<field name="category_id"/>
<field name="tier"/>
<field name="base_amount" widget="monetary"/>
<field name="per_tech_multiplier"/>
<field name="currency_id" invisible="1"/>
<field name="active" widget="boolean_toggle"/>
<field name="description" optional="hide"/>
</list>
</field>
</record>
<record id="action_repair_emergency_charge" model="ir.actions.act_window">
<field name="name">Emergency Surcharges</field>
<field name="res_model">fusion.repair.emergency.charge</field>
<field name="view_mode">list</field>
</record>
</odoo>

View File

@@ -31,6 +31,21 @@
icon="fa-handshake-o"
invisible="state in ('done', 'cancel')"
groups="fusion_repairs.group_fusion_repairs_user"/>
<!-- Bundle 8: squeeze a rush into today's tech route + acknowledge surcharge -->
<button name="action_squeeze_into_today"
type="object"
string="Squeeze into Today"
class="btn-warning"
icon="fa-flash"
invisible="state in ('done', 'cancel') or not x_fc_rush_requested"
groups="fusion_repairs.group_fusion_repairs_dispatcher"/>
<button name="action_acknowledge_rush"
type="object"
string="Client Agreed to Rush Price"
class="btn-warning"
icon="fa-check"
invisible="not x_fc_rush_requested or x_fc_rush_acknowledged_at"
groups="fusion_repairs.group_fusion_repairs_user"/>
</xpath>
<!-- Smart buttons: Technician Tasks + Intake Answers + Original SO. -->
@@ -129,6 +144,44 @@
</group>
</group>
</page>
<page string="Rush / Parts" name="fusion_rush_parts">
<group>
<group string="Rush Service">
<field name="x_fc_rush_requested"/>
<field name="x_fc_rush_tier"
invisible="not x_fc_rush_requested"/>
<field name="x_fc_rush_techs_required"
invisible="not x_fc_rush_requested"/>
<field name="x_fc_rush_surcharge"
widget="monetary"
readonly="1"
invisible="not x_fc_rush_requested"/>
<field name="x_fc_rush_acknowledged_at"
readonly="1"
invisible="not x_fc_rush_requested"/>
<field name="x_fc_rush_acknowledged_by_id"
readonly="1"
invisible="not x_fc_rush_requested"/>
</group>
<group string="Awaiting Parts">
<field name="x_fc_parts_awaiting" readonly="1"/>
<field name="x_fc_parts_eta_date" readonly="1"
invisible="not x_fc_parts_awaiting"/>
<field name="x_fc_part_order_count" readonly="1"/>
</group>
</group>
<field name="x_fc_part_order_ids" readonly="1">
<list>
<field name="name"/>
<field name="description"/>
<field name="oem_part_number"/>
<field name="quantity"/>
<field name="expected_date"/>
<field name="received_date"/>
<field name="state" widget="badge"/>
</list>
</field>
</page>
</xpath>
</field>
@@ -258,6 +311,10 @@
domain="[('x_fc_third_party_equipment', '=', True)]"/>
<filter string="Quote Only" name="quote_only"
domain="[('x_fc_is_quote_only', '=', True)]"/>
<filter string="Rush / Emergency" name="rush"
domain="[('x_fc_rush_requested', '=', True)]"/>
<filter string="Awaiting Parts" name="awaiting_parts"
domain="[('x_fc_parts_awaiting', '=', True)]"/>
<separator/>
<filter string="From Backend Wizard" name="src_backend"
domain="[('x_fc_intake_source', '=', 'backend_wizard')]"/>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_repair_part_order_list" model="ir.ui.view">
<field name="name">fusion.repair.part.order.list</field>
<field name="model">fusion.repair.part.order</field>
<field name="arch" type="xml">
<list string="Parts to Order"
decoration-info="state == 'draft'"
decoration-warning="state == 'ordered'"
decoration-success="state == 'received'"
decoration-muted="state in ('fitted', 'cancelled')">
<field name="name"/>
<field name="partner_id"/>
<field name="repair_order_id"/>
<field name="description"/>
<field name="oem_part_number" optional="show"/>
<field name="manufacturer" optional="show"/>
<field name="quantity"/>
<field name="ordered_date" optional="show"/>
<field name="expected_date" optional="show"/>
<field name="received_date" optional="hide"/>
<field name="state" widget="badge"/>
</list>
</field>
</record>
<record id="view_repair_part_order_form" model="ir.ui.view">
<field name="name">fusion.repair.part.order.form</field>
<field name="model">fusion.repair.part.order</field>
<field name="arch" type="xml">
<form string="Part Order">
<header>
<button name="action_mark_ordered" type="object"
string="Mark Ordered with Manufacturer" class="btn-primary"
invisible="state != 'draft'"/>
<button name="action_mark_received" type="object"
string="Mark Received in Warehouse" class="btn-primary"
invisible="state != 'ordered'"/>
<button name="action_mark_fitted" type="object"
string="Mark Fitted" class="btn-secondary"
invisible="state != 'received'"/>
<button name="action_cancel" type="object"
string="Cancel" class="btn-secondary"
invisible="state in ('cancelled', 'fitted')"
confirm="Cancel this part order? This cannot be undone."/>
<field name="state" widget="statusbar"
statusbar_visible="draft,ordered,received,fitted"/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="name" readonly="1"/></h1>
</div>
<group>
<group>
<field name="repair_order_id" options="{'no_create': True}"/>
<field name="partner_id" readonly="1"/>
<field name="description"/>
<field name="oem_part_number"/>
<field name="manufacturer"/>
<field name="quantity"/>
</group>
<group>
<field name="ordered_date" readonly="state != 'draft'"/>
<field name="expected_date"/>
<field name="received_date" readonly="state != 'ordered'"/>
<field name="ordered_by_id" readonly="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
<notebook>
<page string="Tech Notes" name="notes">
<field name="notes"/>
</page>
<page string="Photos" name="photos">
<field name="photo_ids" widget="many2many_binary"/>
</page>
</notebook>
</sheet>
<chatter/>
</form>
</field>
</record>
<record id="action_repair_part_order" model="ir.actions.act_window">
<field name="name">Parts to Order</field>
<field name="res_model">fusion.repair.part.order</field>
<field name="view_mode">list,form</field>
</record>
</odoo>