Skip to content

Commit

Permalink
[IMP] hr_employee_calendar_planning: Allow to archive when calendars …
Browse files Browse the repository at this point in the history
…have finished.

Show them on calendar view
  • Loading branch information
etobella authored and victoralmau committed Jun 27, 2023
1 parent b488b72 commit c1b5258
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
6 changes: 5 additions & 1 deletion hr_employee_calendar_planning/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"license": "AGPL-3",
"installable": True,
"depends": ["hr"],
"data": ["security/ir.model.access.csv", "views/hr_employee_views.xml"],
"data": [
"security/ir.model.access.csv",
"views/hr_employee_views.xml",
"views/resource_calendar_views.xml",
],
"post_init_hook": "post_init_hook",
"maintainers": ["victoralmau", "pedrobaeza"],
}
8 changes: 7 additions & 1 deletion hr_employee_calendar_planning/models/resource_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ class ResourceCalendar(models.Model):

active = fields.Boolean(default=True)
auto_generate = fields.Boolean()
employee_calendar_ids = fields.One2many("hr.employee.calendar", "calendar_id")

@api.constrains("active")
def _check_active(self):
for item in self:
total_items = self.env["hr.employee.calendar"].search_count(
[("calendar_id", "=", item.id)]
[
("calendar_id", "=", item.id),
"|",
("date_end", "=", False),
("date_end", "<=", fields.Date.today()),
]
)
if total_items:
raise ValidationError(
Expand Down
23 changes: 23 additions & 0 deletions hr_employee_calendar_planning/views/resource_calendar_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Creu Blanca
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="resource_calendar_form" model="ir.ui.view">
<field name="model">resource.calendar</field>
<field name="inherit_id" ref="resource.resource_calendar_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page name="employee_calendar" string="Employee Calendars">
<field name="employee_calendar_ids">
<tree editable="top" create="0">
<field name="company_id" invisible="1" />
<field name="date_start" />
<field name="date_end" />
<field name="employee_id" />
</tree>
</field>
</page>
</notebook>
</field>
</record>
</odoo>

0 comments on commit c1b5258

Please sign in to comment.