Skip to Content
Menu
This question has been flagged
1 Reply
2971 Views

Hello,

I have a problem with the fleet app that I inherit the fleet.vehicle model for my purposes

I want to make a driver an employee and so I substituted the driver_id which is related with res.partner with employee_id which is related with hr.employee. The problem is that when I do this thing everything is work in the form but when I try to add a new contract from the Vehichle contract menu, when I open the many2one selection i see only the Create and edit button even if I create 12-13 vehichles! 


HEre is the code:

In fleet_vehicle.py:
 driver_id = fields.Many2one('res.partner', string="Driver",translate=True)   
 employee_id = fields.Many2one('hr.employee',string="Driver",domain('name_dep', '=', 'Drivers')])
In fleet_vehicle_view.xml:
 <field name="driver_id" position="replace">          
<field invisible="1" name="driver_id"/>                
<field domain="[('name_dep', '=', 'Drivers')]" string="Driver" name="employee_id"/>
</field>  

What should I do? I understand that HERE is the problem because if I don't switch the ids of the drivers everything works.
Thank you
Avatar
Discard
Best Answer

Hi,

Did you have got a field named name_dep inside the model hr.employee ? If so make sure that there is at-least one record holds the value Drivers in name_dep field.

Rather than giving domain using a string, add a Boolean field in employee model, to recognize whether it is driver or not and give domain based on it.

Thanks

Avatar
Discard
Author

Hi,

Yes i have the name_dep in hr.employee

class HrEmployee(models.Model):

_inherit = ['hr.employee']

name_dep = fields.Char(related="department_id.name")

I cannot understand where are the problem! The drivers with the value Drivers show me in the many2one field of employee_id!

The problem is that I can't see the vehicle that I created!

Use store=True,

name_dep = fields.Char(related="department_id.name", store=True)

Author

Hey,

Still not working.

I think there is a problem with the driver ID, because if I remove the employee_id and I use driver_id of res.partner everything works.

I don't know :sad:

Related Posts Replies Views Activity
0
Jun 23
1271
7
Jan 20
2860
2
Nov 19
2339
6
Nov 19
3168
2
Aug 19
10005