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

@@ -156,7 +156,10 @@ class ReadyForDeliveryWizard(models.TransientModel):
return {'type': 'ir.actions.act_window_close'}
def _create_technician_tasks(self, order):
"""Create a technician task for each assigned technician.
"""Create a single delivery task with lead + additional technicians.
The first selected technician becomes the lead. Any remaining
technicians are assigned as additional technicians on the same task.
The task model's create() method auto-populates address fields
from the linked sale order's shipping address when address_street
@@ -164,7 +167,7 @@ class ReadyForDeliveryWizard(models.TransientModel):
"""
Task = self.env['fusion.technician.task']
scheduled_date = False
time_start = 9.0 # default 9:00 AM
time_start = 9.0
if self.scheduled_datetime:
scheduled_date = self.scheduled_datetime.date()
@@ -172,43 +175,45 @@ class ReadyForDeliveryWizard(models.TransientModel):
else:
scheduled_date = fields.Date.context_today(self)
created_tasks = self.env['fusion.technician.task']
for tech in self.technician_ids:
vals = {
'technician_id': tech.id,
'sale_order_id': order.id,
'task_type': 'delivery',
'scheduled_date': scheduled_date,
'time_start': time_start,
'time_end': time_start + 1.0, # 1 hour default
'partner_id': order.partner_id.id,
'description': self.notes or '',
'pod_required': True,
}
task = Task.create(vals)
created_tasks |= task
_logger.info("Created delivery task %s for %s on order %s", task.name, tech.name, order.name)
techs = self.technician_ids
lead_tech = techs[0]
additional_techs = techs[1:] if len(techs) > 1 else self.env['res.users']
# Post a summary of created tasks back to the sale order chatter
if created_tasks:
task_lines = ''
for t in created_tasks:
task_url = f'/web#id={t.id}&model=fusion.technician.task&view_type=form'
time_str = t.time_start_12h or ''
task_lines += (
f'<li><a href="{task_url}">{t.name}</a> - '
f'{t.technician_id.name} '
f'({t.scheduled_date.strftime("%b %d, %Y") if t.scheduled_date else "TBD"}'
f'{" at " + time_str if time_str else ""})</li>'
)
summary = Markup(
'<div class="alert alert-info" style="margin:0;">'
'<strong><i class="fa fa-wrench"></i> Delivery Tasks Created</strong>'
'<ul style="margin-bottom:0;">%s</ul>'
'</div>'
) % Markup(task_lines)
order.message_post(
body=summary,
message_type='notification',
subtype_xmlid='mail.mt_note',
)
vals = {
'technician_id': lead_tech.id,
'additional_technician_ids': [(6, 0, additional_techs.ids)] if additional_techs else False,
'sale_order_id': order.id,
'task_type': 'delivery',
'scheduled_date': scheduled_date,
'time_start': time_start,
'time_end': time_start + 1.0,
'partner_id': order.partner_id.id,
'description': self.notes or '',
'pod_required': True,
}
task = Task.create(vals)
_logger.info(
"Created delivery task %s for %s (+%d additional) on order %s",
task.name, lead_tech.name, len(additional_techs), order.name,
)
task_url = f'/web#id={task.id}&model=fusion.technician.task&view_type=form'
time_str = task.time_start_12h or ''
all_names = ', '.join(techs.mapped('name'))
task_line = (
f'<li><a href="{task_url}">{task.name}</a> - '
f'{all_names} '
f'({task.scheduled_date.strftime("%b %d, %Y") if task.scheduled_date else "TBD"}'
f'{" at " + time_str if time_str else ""})</li>'
)
summary = Markup(
'<div class="alert alert-info" style="margin:0;">'
'<strong><i class="fa fa-wrench"></i> Delivery Task Created</strong>'
'<ul style="margin-bottom:0;">%s</ul>'
'</div>'
) % Markup(task_line)
order.message_post(
body=summary,
message_type='notification',
subtype_xmlid='mail.mt_note',
)