Skip to content
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

[IMP] hr_contract_employee_calendar_planning: multicreate warning #1446

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions hr_contract_employee_calendar_planning/models/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def write(self, vals):
vals.pop("resource_calendar_id")
return super().write(vals)

@api.model
def create(self, vals):
@api.model_create_multi
def create(self, vals_list):
# the create method of contracts syncs contract calendars with employee calendars
# in order to not overwrite the employee calendar
# we set the contract calendar to match the employee calendar
employee_contract = (
self.env["hr.employee"]
.browse([vals.get("employee_id")])
.resource_calendar_id
)
if employee_contract:
vals.update({"resource_calendar_id": employee_contract.id})
contracts = super(HrContract, self).create(vals)
return contracts
for vals in vals_list:
employee_contract = (
self.env["hr.employee"]
.browse([vals.get("employee_id")])
.resource_calendar_id
)
if employee_contract:
vals.update({"resource_calendar_id": employee_contract.id})
return super().create(vals_list)