fleet_vehicle_log_services.py 958 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import api, fields, models
  4. class FleetVehicleLogServices(models.Model):
  5. _inherit = 'fleet.vehicle.log.services'
  6. purchaser_employee_id = fields.Many2one(
  7. 'hr.employee', string="Driver (Employee)",
  8. compute='_compute_purchaser_employee_id', readonly=False, store=True,
  9. )
  10. @api.depends('vehicle_id', 'purchaser_employee_id')
  11. def _compute_purchaser_id(self):
  12. internals = self.filtered(lambda r: r.purchaser_employee_id)
  13. super(FleetVehicleLogServices, (self - internals))._compute_purchaser_id()
  14. for service in internals:
  15. service.purchaser_id = service.purchaser_employee_id.address_home_id
  16. @api.depends('vehicle_id')
  17. def _compute_purchaser_employee_id(self):
  18. for service in self:
  19. service.purchaser_employee_id = service.vehicle_id.driver_employee_id