mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-27 08:51:59 +02:00
19.0 vanilla
This commit is contained in:
parent
a1137a1456
commit
e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions
|
|
@ -10,34 +10,24 @@ class ResCompany(models.Model):
|
|||
|
||||
@api.model
|
||||
def _default_project_time_mode_id(self):
|
||||
uom = self.env.ref('uom.product_uom_hour', raise_if_not_found=False)
|
||||
wtime = self.env.ref('uom.uom_categ_wtime')
|
||||
if not uom:
|
||||
uom = self.env['uom.uom'].search([('category_id', '=', wtime.id), ('uom_type', '=', 'reference')], limit=1)
|
||||
if not uom:
|
||||
uom = self.env['uom.uom'].search([('category_id', '=', wtime.id)], limit=1)
|
||||
return uom
|
||||
return self.env.ref('uom.product_uom_hour', raise_if_not_found=False)
|
||||
|
||||
@api.model
|
||||
def _default_timesheet_encode_uom_id(self):
|
||||
uom = self.env.ref('uom.product_uom_hour', raise_if_not_found=False)
|
||||
wtime = self.env.ref('uom.uom_categ_wtime')
|
||||
if not uom:
|
||||
uom = self.env['uom.uom'].search([('category_id', '=', wtime.id), ('uom_type', '=', 'reference')], limit=1)
|
||||
if not uom:
|
||||
uom = self.env['uom.uom'].search([('category_id', '=', wtime.id)], limit=1)
|
||||
return uom
|
||||
|
||||
return self.env.ref('uom.product_uom_hour', raise_if_not_found=False)
|
||||
|
||||
project_time_mode_id = fields.Many2one('uom.uom', string='Project Time Unit',
|
||||
default=_default_project_time_mode_id,
|
||||
help="This will set the unit of measure used in projects and tasks.\n"
|
||||
"If you use the timesheet linked to projects, don't "
|
||||
"forget to setup the right unit of measure in your employees.")
|
||||
timesheet_encode_uom_id = fields.Many2one('uom.uom', string="Timesheet Encoding Unit",
|
||||
default=_default_timesheet_encode_uom_id, domain=lambda self: [('category_id', '=', self.env.ref('uom.uom_categ_wtime').id)])
|
||||
default=_default_timesheet_encode_uom_id)
|
||||
internal_project_id = fields.Many2one(
|
||||
'project.project', string="Internal Project",
|
||||
help="Default project value for timesheet generated from time off type.")
|
||||
"project.project", string="Internal Project",
|
||||
domain=[("is_template", "=", False)],
|
||||
help="Default project value for timesheet generated from time off type.",
|
||||
)
|
||||
|
||||
@api.constrains('internal_project_id')
|
||||
def _check_internal_project_id_company(self):
|
||||
|
|
@ -45,8 +35,8 @@ class ResCompany(models.Model):
|
|||
raise ValidationError(_('The Internal Project of a company should be in that company.'))
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, values):
|
||||
company = super(ResCompany, self).create(values)
|
||||
def create(self, vals_list):
|
||||
company = super().create(vals_list)
|
||||
# use sudo as the user could have the right to create a company
|
||||
# but not to create a project. On the other hand, when the company
|
||||
# is created, it is not in the allowed_company_ids on the env
|
||||
|
|
@ -74,9 +64,3 @@ class ResCompany(models.Model):
|
|||
for company in self:
|
||||
company.internal_project_id = projects_by_company.get(company.id, False)
|
||||
return project_ids
|
||||
|
||||
def _is_timesheet_hour_uom(self):
|
||||
return self.timesheet_encode_uom_id and self.timesheet_encode_uom_id == self.env.ref('uom.product_uom_hour')
|
||||
|
||||
def _timesheet_uom_text(self):
|
||||
return self._is_timesheet_hour_uom() and _("hours") or _("days")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue