mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-25 01:52:03 +02:00
19.0 vanilla
This commit is contained in:
parent
a1137a1456
commit
e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions
26
odoo-bringout-oca-ocb-hr/hr/models/hr_mixin.py
Normal file
26
odoo-bringout-oca-ocb-hr/hr/models/hr_mixin.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
from .hr_employee import _ALLOW_READ_HR_EMPLOYEE
|
||||
|
||||
|
||||
class HrMixin(models.AbstractModel):
|
||||
_name = _description = 'hr.mixin'
|
||||
|
||||
# Those overrides deal with many2many fields to comodel 'hr.employee'. In
|
||||
# the past, one could assign such a many2many field without having any
|
||||
# access to its comodel. Since Odoo 19, one must have read access to the
|
||||
# comodel to modify the relation. The hack consists in passing a special
|
||||
# value in the context, and pretend 'hr.employee' records to be readable
|
||||
# when that value is present.
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
special_self = self.with_context(_allow_read_hr_employee=_ALLOW_READ_HR_EMPLOYEE)
|
||||
records = super(HrMixin, special_self).create(vals_list)
|
||||
return records.with_env(self.env)
|
||||
|
||||
def write(self, vals):
|
||||
special_self = self.with_context(_allow_read_hr_employee=_ALLOW_READ_HR_EMPLOYEE)
|
||||
return super(HrMixin, special_self).write(vals)
|
||||
Loading…
Add table
Add a link
Reference in a new issue