[IMP] add domain to select current company calendar

Before this commit user was able to select calendars from
differant companies even though user is not allowed to read
that companies record.

This commit add field related to country company and use
it in a domain to restrict user to select on availble
calendars.

task-3078009

closes odoo/odoo#109904

Related: odoo/enterprise#37334
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
sofiagvaladze
2023-03-21 18:55:55 +01:00
committed by Kartik Chavda
parent 603df3c890
commit 94bbffe46b
2 changed files with 2 additions and 1 deletions
@@ -11,5 +11,5 @@ class HrPayrollStructureType(models.Model):
name = fields.Char('Salary Structure Type')
default_resource_calendar_id = fields.Many2one(
'resource.calendar', 'Default Working Hours',
default=lambda self: self.env.company.resource_calendar_id)
default=lambda self: self.env.company.resource_calendar_id if self.env.company.country_id else False)
country_id = fields.Many2one('res.country', string='Country', default=lambda self: self.env.company.country_id)
+1
View File
@@ -10,6 +10,7 @@ class ResourceCalendar(models.Model):
_inherit = 'resource.calendar'
contracts_count = fields.Integer("# Contracts using it", compute='_compute_contracts_count', groups="hr_contract.group_hr_contract_manager")
company_country_id = fields.Many2one('res.country', string='Country', related='company_id.partner_id.country_id')
def transfer_leaves_to(self, other_calendar, resources=None, from_date=None):
"""