feat(configurator): D1+D2 - drafts dual-routing + legacy deprecation banner
D1: action_open_draft method routes drafts-list click to the matching form view by view_source. view_source badge column added to the drafts list (Express=blue, Legacy=muted). D2: Deprecation banner on the legacy direct-order form pointing operators to the new Express view, plus a Switch-to-Express header button. Legacy action context defaults new drafts to view_source='legacy' (Express action defaults to 'express') so newly-created drafts open in the right view automatically.
This commit is contained in:
@@ -193,6 +193,28 @@ class FpDirectOrderWizard(models.Model):
|
||||
).id,
|
||||
'target': 'current',
|
||||
}
|
||||
|
||||
def action_open_draft(self):
|
||||
"""Route the drafts-list row-click to the form view matching view_source.
|
||||
|
||||
Drafts created in the Express view re-open in Express; drafts
|
||||
created in the Legacy view re-open in Legacy. Either view's
|
||||
header has a 'Switch to ...' button to bounce between.
|
||||
"""
|
||||
self.ensure_one()
|
||||
view_xmlid = (
|
||||
'fusion_plating_configurator.view_fp_express_order_form'
|
||||
if self.view_source == 'express'
|
||||
else 'fusion_plating_configurator.view_fp_direct_order_wizard_form'
|
||||
)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'fp.direct.order.wizard',
|
||||
'res_id': self.id,
|
||||
'view_mode': 'form',
|
||||
'view_id': self.env.ref(view_xmlid).id,
|
||||
'target': 'current',
|
||||
}
|
||||
invoice_strategy = fields.Selection(
|
||||
[('deposit', 'Deposit'), ('progress', 'Progress Billing'),
|
||||
('net_terms', 'Net Terms'), ('cod_prepay', 'COD / Prepay')],
|
||||
|
||||
@@ -24,7 +24,21 @@
|
||||
invisible="state != 'cancelled'"/>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="draft,confirmed"/>
|
||||
<button name="action_switch_to_express" type="object"
|
||||
string="Switch to Express ➜"
|
||||
class="btn-secondary"
|
||||
invisible="state != 'draft'"/>
|
||||
</header>
|
||||
<div class="alert alert-warning py-2 mb-0 small"
|
||||
role="alert"
|
||||
invisible="state != 'draft'">
|
||||
<i class="fa fa-exclamation-triangle me-1"/>
|
||||
<strong>Legacy view.</strong> This form is being retired in favour of the new
|
||||
<a href="#" class="alert-link"><strong>Express Orders</strong></a> view, which
|
||||
is faster for batch entry — every column inline, type-once-and-remember per-part
|
||||
defaults, masking + bake toggles per line. Click <em>Switch to Express ➜</em>
|
||||
above to flip this draft into the new view.
|
||||
</div>
|
||||
<div class="alert alert-info py-2 mb-0 small"
|
||||
role="alert"
|
||||
invisible="state != 'draft'">
|
||||
@@ -365,11 +379,13 @@
|
||||
estimator breadcrumb between the wizard and the part form / Composer.
|
||||
Odoo prompts to save unsaved changes when navigating away. -->
|
||||
<record id="action_fp_direct_order_wizard" model="ir.actions.act_window">
|
||||
<field name="name">New Direct Order</field>
|
||||
<field name="name">New Direct Order (Legacy)</field>
|
||||
<field name="res_model">fp.direct.order.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">current</field>
|
||||
<field name="context">{}</field>
|
||||
<!-- view_source tags the draft so the drafts list routes
|
||||
re-opens back to the legacy form. -->
|
||||
<field name="context">{'default_view_source': 'legacy'}</field>
|
||||
</record>
|
||||
|
||||
<!-- ===== Drafts list view (resume an in-flight order entry) ===== -->
|
||||
@@ -380,7 +396,8 @@
|
||||
<list string="Direct Order Drafts"
|
||||
decoration-info="state == 'draft'"
|
||||
decoration-muted="state == 'cancelled'"
|
||||
decoration-success="state == 'confirmed'">
|
||||
decoration-success="state == 'confirmed'"
|
||||
open_form_view="True">
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="user_id"/>
|
||||
@@ -394,10 +411,23 @@
|
||||
<field name="currency_id" column_invisible="1"/>
|
||||
<field name="create_date" optional="show"/>
|
||||
<field name="sale_order_id" optional="hide"/>
|
||||
<!-- View source badge: which form the draft was created from. -->
|
||||
<field name="view_source" widget="badge"
|
||||
decoration-info="view_source == 'express'"
|
||||
decoration-muted="view_source == 'legacy'"
|
||||
optional="show"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-info="state == 'draft'"
|
||||
decoration-success="state == 'confirmed'"
|
||||
decoration-muted="state == 'cancelled'"/>
|
||||
<!-- Express drafts can be re-opened in the matching form
|
||||
via the per-row 'Open' button. Drafts list standard
|
||||
row-click goes to the default form view (legacy).
|
||||
For Express drafts, use the Open button which routes
|
||||
by view_source. -->
|
||||
<button name="action_open_draft" type="object"
|
||||
string="Open" class="btn-link"
|
||||
icon="fa-external-link"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user