feat: hide authorizer for rental orders, auto-set sale type

Rental orders no longer show the "Authorizer Required?" question or
the Authorizer field. The sale type is automatically set to 'Rentals'
when creating or confirming a rental order. Validation logic also
skips authorizer checks for rental sale type.

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-02-25 23:33:23 -05:00
parent 3c8f83b8e6
commit 14fe9ab716
51 changed files with 4192 additions and 822 deletions

View File

@@ -7,6 +7,46 @@
<field name="inherit_id" ref="sale_renting.rental_order_form_view"/>
<field name="arch" type="xml">
<!-- Smart buttons in button_box -->
<div name="button_box" position="inside">
<button name="action_view_deposit_invoice"
type="object"
class="oe_stat_button"
icon="fa-shield"
invisible="not is_rental_order or rental_deposit_invoice_count == 0">
<field name="rental_deposit_invoice_count"
widget="statinfo"
string="Security Deposit"/>
</button>
<button name="action_view_rental_charges_invoice"
type="object"
class="oe_stat_button"
icon="fa-file-text-o"
invisible="not is_rental_order or rental_charges_invoice_count == 0">
<field name="rental_charges_invoice_count"
widget="statinfo"
string="Rental Invoice"/>
</button>
<button name="action_view_renewal_invoices"
type="object"
class="oe_stat_button"
icon="fa-refresh"
invisible="not is_rental_order or rental_renewal_invoice_count == 0">
<field name="rental_renewal_invoice_count"
widget="statinfo"
string="Renewals"/>
</button>
<button name="action_view_refund_invoices"
type="object"
class="oe_stat_button"
icon="fa-undo"
invisible="not is_rental_order or rental_refund_invoice_count == 0">
<field name="rental_refund_invoice_count"
widget="statinfo"
string="Refunds"/>
</button>
</div>
<!-- Header buttons -->
<button name="action_open_pickup" position="before">
<button name="action_send_rental_agreement"
@@ -37,26 +77,12 @@
string="Mark Deposit Collected"
invisible="not is_rental_order or rental_deposit_status != 'pending'"
icon="fa-check-circle"/>
<button name="action_refund_deposit"
<button name="action_process_deposit"
type="object"
class="btn-secondary"
string="Refund Deposit"
invisible="not is_rental_order or rental_deposit_status != 'collected'"
confirm="This will initiate the deposit refund hold period. Continue?"
icon="fa-undo"/>
<button name="action_force_refund_deposit"
type="object"
class="btn-secondary"
string="Process Refund Now"
invisible="not is_rental_order or rental_deposit_status != 'refund_hold'"
confirm="Skip the hold period and process the refund immediately?"
icon="fa-bolt"/>
<button name="action_deduct_deposit"
type="object"
class="btn-danger"
string="Deduct Deposit"
invisible="not is_rental_order or rental_deposit_status != 'collected'"
icon="fa-minus-circle"/>
string="Process Deposit"
invisible="not is_rental_order or rental_deposit_status not in ('collected', 'refund_hold')"
icon="fa-credit-card"/>
<button name="action_close_rental"
type="object"
@@ -68,61 +94,109 @@
icon="fa-power-off"/>
</button>
<!-- Rental fields -->
<!-- Hidden fields (must stay in form, outside notebook) -->
<field name="duration_days" position="after">
<!-- Renewal settings -->
<field name="rental_auto_renew" invisible="not is_rental_order"/>
<field name="rental_renewal_count" invisible="not is_rental_order or rental_renewal_count == 0"/>
<field name="rental_max_renewals" invisible="not is_rental_order or not rental_auto_renew"/>
<field name="rental_payment_token_id" invisible="not is_rental_order"/>
<field name="rental_next_renewal_date" invisible="not is_rental_order or not rental_auto_renew"/>
<field name="rental_reminder_sent" invisible="1"/>
<field name="rental_original_duration" invisible="1"/>
<field name="rental_agreement_token" invisible="1"/>
<!-- Agreement status -->
<field name="rental_agreement_signed" invisible="not is_rental_order"
widget="boolean_toggle" readonly="1"/>
<field name="rental_agreement_signer_name"
invisible="not is_rental_order or not rental_agreement_signed" readonly="1"/>
<field name="rental_agreement_signed_date"
invisible="not is_rental_order or not rental_agreement_signed" readonly="1"/>
<!-- Rental charges invoice -->
<field name="rental_charges_invoice_id"
invisible="not is_rental_order or not rental_charges_invoice_id" readonly="1"/>
<!-- Deposit status -->
<field name="rental_deposit_status" invisible="not is_rental_order or not rental_deposit_status"
decoration-success="rental_deposit_status == 'refunded'"
decoration-warning="rental_deposit_status in ('pending', 'refund_hold', 'collected')"
decoration-danger="rental_deposit_status == 'deducted'"
widget="badge"/>
<field name="rental_deposit_invoice_id"
invisible="not is_rental_order or not rental_deposit_invoice_id" readonly="1"/>
<!-- Inspection status -->
<field name="rental_inspection_status"
invisible="not is_rental_order or not rental_inspection_status"
decoration-success="rental_inspection_status == 'passed'"
decoration-danger="rental_inspection_status == 'flagged'"
widget="badge"/>
<!-- Purchase interest -->
<field name="rental_purchase_interest"
invisible="not is_rental_order or not rental_purchase_interest"
widget="boolean_toggle" readonly="1"/>
<field name="rental_purchase_coupon_id"
invisible="not is_rental_order or not rental_purchase_coupon_id" readonly="1"/>
<!-- Close status -->
<field name="rental_closed"
invisible="not is_rental_order or not rental_closed" readonly="1"/>
<field name="rental_marketing_email_sent" invisible="1"/>
</field>
<!-- Notebook pages -->
<xpath expr="//notebook" position="inside">
<!-- Rental Management -->
<page string="Rental Management"
name="rental_management"
invisible="not is_rental_order">
<!-- Row 1: Agreement + Payment -->
<group>
<group string="Agreement">
<field name="rental_agreement_signed"
widget="boolean_toggle" readonly="1"/>
<field name="rental_agreement_signer_name"
invisible="not rental_agreement_signed" readonly="1"/>
<field name="rental_agreement_signed_date"
invisible="not rental_agreement_signed" readonly="1"/>
</group>
<group string="Payment">
<field name="rental_payment_token_id"/>
<div invisible="not is_rental_order or state != 'sale' or rental_closed">
<button name="action_send_card_reauthorization"
type="object"
class="btn btn-outline-secondary btn-sm"
string="Reauthorize Card"
icon="fa-credit-card"
confirm="This will send a card authorization form to the customer. Continue?"/>
</div>
<field name="rental_charges_invoice_id"
invisible="not rental_charges_invoice_id" readonly="1"/>
<field name="rental_deposit_invoice_id"
invisible="not rental_deposit_invoice_id" readonly="1"/>
</group>
</group>
<!-- Row 2: Renewal + Status -->
<group>
<group string="Renewal">
<field name="rental_auto_renew"/>
<field name="rental_auto_renew_off_reason"
invisible="rental_auto_renew"
required="not rental_auto_renew"
placeholder="Reason for disabling auto-renewal..."/>
<field name="rental_max_renewals"
invisible="not rental_auto_renew"/>
<field name="rental_next_renewal_date"
invisible="not rental_auto_renew"/>
<field name="rental_renewal_count"
invisible="rental_renewal_count == 0"/>
</group>
<group string="Status">
<field name="rental_deposit_status"
invisible="not rental_deposit_status"
decoration-success="rental_deposit_status == 'refunded'"
decoration-warning="rental_deposit_status in ('pending', 'refund_hold', 'collected')"
decoration-danger="rental_deposit_status == 'deducted'"
widget="badge"/>
<field name="rental_inspection_status"
invisible="not rental_inspection_status"
decoration-success="rental_inspection_status == 'passed'"
decoration-danger="rental_inspection_status == 'flagged'"
widget="badge"/>
<field name="rental_purchase_interest"
invisible="not rental_purchase_interest"
widget="boolean_toggle" readonly="1"/>
<field name="rental_purchase_coupon_id"
invisible="not rental_purchase_coupon_id" readonly="1"/>
<field name="rental_closed"
invisible="not rental_closed" readonly="1"/>
</group>
</group>
<!-- Row 3: Document + Billing (visible after agreement signed) -->
<group invisible="not rental_agreement_signed">
<group string="Signed Agreement">
<div invisible="not rental_agreement_document" class="mb-2">
<button name="action_preview_rental_agreement" type="object"
class="btn btn-outline-primary"
icon="fa-file-pdf-o">
Preview Signed Agreement
</button>
</div>
<field name="rental_agreement_document"
filename="rental_agreement_document_filename"
widget="binary" readonly="1"/>
<field name="rental_agreement_document_filename" invisible="1"/>
</group>
<group string="Billing Details">
<field name="rental_billing_address" readonly="1"/>
<field name="rental_billing_postal_code" readonly="1"/>
</group>
</group>
</page>
<!-- Renewal History -->
<page string="Renewal History"
name="renewal_history"
invisible="not is_rental_order or rental_renewal_count == 0">
@@ -147,6 +221,8 @@
</list>
</field>
</page>
<!-- Cancellation Requests -->
<page string="Cancellation Requests"
name="cancellation_requests"
invisible="not is_rental_order"
@@ -166,32 +242,37 @@
</list>
</field>
</page>
<!-- Inspection -->
<page string="Inspection"
name="inspection"
invisible="not is_rental_order or not rental_inspection_status">
invisible="not is_rental_order">
<group>
<group>
<field name="rental_inspection_status"/>
<field name="rental_inspection_status"
decoration-success="rental_inspection_status == 'passed'"
decoration-danger="rental_inspection_status == 'flagged'"
decoration-info="rental_inspection_status == 'pending'"
widget="badge"/>
</group>
</group>
<group string="Inspection Notes">
<div class="alert alert-secondary" role="alert"
invisible="rental_inspection_status">
No inspection has been performed yet. Use the
<strong>Return</strong> button to process the return
and complete the inspection.
</div>
<group string="Inspection Notes"
invisible="not rental_inspection_status">
<field name="rental_inspection_notes" nolabel="1"/>
</group>
<group string="Inspection Photos">
<field name="rental_inspection_photo_ids" widget="many2many_binary" nolabel="1"/>
</group>
</page>
<page string="Agreement"
name="agreement_tab"
invisible="not is_rental_order or not rental_agreement_signed">
<group>
<group string="Signature Details">
<field name="rental_agreement_signer_name" readonly="1"/>
<field name="rental_agreement_signed_date" readonly="1"/>
</group>
<group string="Signature">
<field name="rental_agreement_signature" widget="image" readonly="1"/>
</group>
<group string="Inspection Photos"
invisible="not rental_inspection_status">
<field name="rental_inspection_photo_ids"
widget="inspection_photos"
nolabel="1"
class="o_inspection_photos"
options="{'accepted_file_extensions': 'image/*'}"/>
</group>
</page>
</xpath>