[IMP] hr_fleet: Adapt module with new hr.employee.public model
This commit is contained in:
committed by
Yannick Tivisse
parent
9f407bd453
commit
acd8638575
@@ -4,15 +4,15 @@
|
||||
import base64
|
||||
import io
|
||||
|
||||
from odoo import _
|
||||
from odoo.http import request, route, Controller
|
||||
|
||||
from PyPDF2 import PdfFileReader, PdfFileWriter
|
||||
from reportlab.pdfgen import canvas
|
||||
|
||||
from odoo import _
|
||||
from odoo.http import request, route, Controller
|
||||
|
||||
|
||||
|
||||
class HrFleet(Controller):
|
||||
|
||||
@route(["/fleet/print_claim_report/<int:employee_id>"], type='http', auth='user')
|
||||
def get_claim_report_user(self, employee_id, **post):
|
||||
if not request.env.user.has_group('fleet.fleet_group_manager'):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Employee(models.Model):
|
||||
_inherit = 'hr.employee'
|
||||
|
||||
@@ -26,7 +26,7 @@ class Employee(models.Model):
|
||||
driver_ids = (self.mapped('user_id.partner_id') | self.sudo().mapped('address_home_id')).ids
|
||||
fleet_data = self.env['fleet.vehicle.assignation.log'].read_group(
|
||||
domain=[('driver_id', 'in', driver_ids)], fields=['driver_id'], groupby=['driver_id'])
|
||||
mapped_data = dict([(m['driver_id'][0], m['driver_id_count']) for m in fleet_data])
|
||||
mapped_data = {m['driver_id'][0]: m['driver_id_count'] for m in fleet_data}
|
||||
for employee in self:
|
||||
drivers = employee.user_id.partner_id | employee.sudo().address_home_id
|
||||
employee.employee_cars_count = sum(mapped_data.get(pid, 0) for pid in drivers.ids)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="action_open_employee_cars" type="object"
|
||||
class="oe_stat_button" icon="fa-car"
|
||||
class="oe_stat_button" icon="fa-car" groups="fleet.fleet_group_manager"
|
||||
attrs="{'invisible': [('employee_cars_count','=', 0)]}">
|
||||
<field name="employee_cars_count" widget="statinfo" />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user