-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD][17.0] tms_expense #133
base: 17.0
Are you sure you want to change the base?
Conversation
@max3903, please check this |
tms_expense/models/hr_employee.py
Outdated
class HrEmployee(models.Model): | ||
_inherit = "hr.employee" | ||
|
||
is_driver = fields.Boolean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This data can be obtained from the partner associated with the employee.
tms_expense/models/res_partner.py
Outdated
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
employee_id = fields.Many2one("hr.employee") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I also believe that there is no need to create a new field. You can probably retrieve this based on the existing data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe search for the partner in employee_id.address_home_id (where address_home is a res.partner) or, if it is a user, get the employee_id and partner_id linked to the user.
@@ -22,7 +22,9 @@ class TMSOrder(models.Model): | |||
@api.depends("driver_id") | |||
def _compute_driver_employee_id(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
employee_id = fields.Many2one('hr.employee', string='Driver', compute='_compute_employee_id', store=True)
@api.depends('driver_id')
def _compute_employee_id(self):
for record in self:
record.employee_id = self.env['hr.employee'].search([('user_partner_id', '=', record.driver_id.id)], limit=1)
if not record.employee_id:
record.employee_id = self.env['hr.employee'].search([('address_home_id', '=', record.driver_id.id)], limit=1)
cb80981
to
e14055f
Compare
e14055f
to
003d07b
Compare
003d07b
to
68005aa
Compare
No description provided.