[IMP] maintenance: add hook method for inherit
When you need to add certain details to the data in order to make a maintenance request. I can't do it using the old code. As a result, I've included a hook method to be more flexible with customers. closes odoo/odoo#81052 X-original-commit: a71a8fbc43cf0deee669869792b2ff2ac9ab9a8b Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
@@ -221,9 +221,9 @@ class MaintenanceEquipment(models.Model):
|
||||
category_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
|
||||
return categories.browse(category_ids)
|
||||
|
||||
def _create_new_request(self, date):
|
||||
def _prepare_maintenance_request_vals(self, date):
|
||||
self.ensure_one()
|
||||
self.env['maintenance.request'].create({
|
||||
return {
|
||||
'name': _('Preventive Maintenance - %s', self.name),
|
||||
'request_date': date,
|
||||
'schedule_date': date,
|
||||
@@ -235,7 +235,13 @@ class MaintenanceEquipment(models.Model):
|
||||
'maintenance_team_id': self.maintenance_team_id.id,
|
||||
'duration': self.maintenance_duration,
|
||||
'company_id': self.company_id.id or self.env.company.id
|
||||
})
|
||||
}
|
||||
|
||||
def _create_new_request(self, date):
|
||||
self.ensure_one()
|
||||
vals = self._prepare_maintenance_request_vals(date)
|
||||
maintenance_requests = self.env['maintenance.request'].create(vals)
|
||||
return maintenance_requests
|
||||
|
||||
@api.model
|
||||
def _cron_generate_requests(self):
|
||||
|
||||
Reference in New Issue
Block a user