Skip to content

Commit

Permalink
[IMP] add company_id field for easier configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
damdam-s authored and pedrobaeza committed Oct 27, 2016
1 parent b8f61dc commit 00f4e3d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions hr_holidays_legal_leave/models/hr_holidays_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ class HolidaysType(models.Model):
'You cannot unset it directly. '
'Set it on another Leave type instead. '
)
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self._get_default_company()
)

@api.multi
def _get_default_company(self):
return self.env.user.company_id.id

@api.depends('company_id', 'is_annual')
def _compute_is_annual(self):
company = self.env.user.company_id
self.filtered(lambda x: x == company.legal_holidays_status_id)\
.update({'is_annual': True})
for rec in self:
rec.is_annual = rec.company_id.legal_holidays_status_id == rec.id

@api.multi
def _inverse_is_annual(self):
self.ensure_one()
company = self.env.user.company_id
if self.is_annual:
company.legal_holidays_status_id = self.id
self.company_id.legal_holidays_status_id = self.id

0 comments on commit 00f4e3d

Please sign in to comment.