updates
This commit is contained in:
@@ -153,9 +153,17 @@ class FusionTechnicianTask(models.Model):
|
||||
('assessment', 'Assessment'),
|
||||
('installation', 'Installation'),
|
||||
('maintenance', 'Maintenance'),
|
||||
('ltc_visit', 'LTC Visit'),
|
||||
('other', 'Other'),
|
||||
], string='Task Type', required=True, default='delivery', tracking=True)
|
||||
|
||||
facility_id = fields.Many2one(
|
||||
'fusion.ltc.facility',
|
||||
string='LTC Facility',
|
||||
tracking=True,
|
||||
help='LTC Home for this visit',
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# SCHEDULING
|
||||
# ------------------------------------------------------------------
|
||||
@@ -219,6 +227,7 @@ class FusionTechnicianTask(models.Model):
|
||||
'assessment': 1.5,
|
||||
'installation': 2.0,
|
||||
'maintenance': 1.5,
|
||||
'ltc_visit': 3.0,
|
||||
'other': 1.0,
|
||||
}
|
||||
|
||||
@@ -919,6 +928,26 @@ class FusionTechnicianTask(models.Model):
|
||||
addr = order.dest_address_id or order.partner_id
|
||||
self._fill_address_from_partner(addr)
|
||||
|
||||
@api.onchange('facility_id')
|
||||
def _onchange_facility_id(self):
|
||||
"""Auto-fill address from the LTC facility."""
|
||||
if self.facility_id and self.task_type == 'ltc_visit':
|
||||
fac = self.facility_id
|
||||
self.address_street = fac.street or ''
|
||||
self.address_street2 = fac.street2 or ''
|
||||
self.address_city = fac.city or ''
|
||||
self.address_state_id = fac.state_id.id if fac.state_id else False
|
||||
self.address_zip = fac.zip or ''
|
||||
self.description = self.description or _(
|
||||
'LTC Visit at %s', fac.name
|
||||
)
|
||||
|
||||
@api.onchange('task_type')
|
||||
def _onchange_task_type_ltc(self):
|
||||
if self.task_type == 'ltc_visit':
|
||||
self.sale_order_id = False
|
||||
self.purchase_order_id = False
|
||||
|
||||
def _fill_address_from_partner(self, addr):
|
||||
"""Populate address fields from a partner record."""
|
||||
if not addr:
|
||||
@@ -941,6 +970,8 @@ class FusionTechnicianTask(models.Model):
|
||||
for task in self:
|
||||
if task.x_fc_sync_source:
|
||||
continue
|
||||
if task.task_type == 'ltc_visit':
|
||||
continue
|
||||
if not task.sale_order_id and not task.purchase_order_id:
|
||||
raise ValidationError(_(
|
||||
"A task must be linked to either a Sale Order (Case) or a Purchase Order."
|
||||
|
||||
Reference in New Issue
Block a user