diff --git a/portal_timesheet/__manifest__.py b/portal_timesheet/__manifest__.py
index ae9ee2f9..c150d1d9 100644
--- a/portal_timesheet/__manifest__.py
+++ b/portal_timesheet/__manifest__.py
@@ -19,7 +19,7 @@
##############################################################################
{
"name": "Portal Timesheet",
- "version": "18.0.1.2.0",
+ "version": "19.0.1.0.0",
"category": "Base",
"sequence": 14,
"summary": "",
@@ -39,13 +39,14 @@
"security/ir.model.access.csv",
"views/base_menus.xml",
"views/hr_employee_views.xml",
+ "views/project_project_views.xml",
],
"demo": [
# 'demo/hr_demo.xml',
"demo/project_demo.xml",
"demo/res_users_demo.xml",
],
- "installable": False,
+ "installable": True,
"auto_install": False,
"application": False,
}
diff --git a/portal_timesheet/demo/res_users_demo.xml b/portal_timesheet/demo/res_users_demo.xml
index cc5df518..02a16565 100644
--- a/portal_timesheet/demo/res_users_demo.xml
+++ b/portal_timesheet/demo/res_users_demo.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/portal_timesheet/models/__init__.py b/portal_timesheet/models/__init__.py
index 611a5af1..7cc41e47 100644
--- a/portal_timesheet/models/__init__.py
+++ b/portal_timesheet/models/__init__.py
@@ -1,4 +1,6 @@
from . import ir_http
from . import project
from . import res_users
+
+# from . import res_partner
from . import account_analytic_line
diff --git a/portal_timesheet/models/account_analytic_line.py b/portal_timesheet/models/account_analytic_line.py
index b010f9c9..20898361 100644
--- a/portal_timesheet/models/account_analytic_line.py
+++ b/portal_timesheet/models/account_analytic_line.py
@@ -11,3 +11,9 @@ def _get_favorite_project_id(self, employee_id=False):
if self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
self = self.sudo()
return super()._get_favorite_project_id(employee_id=employee_id)
+
+ def _compute_readonly_timesheet(self):
+ if self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
+ self.readonly_timesheet = False
+ else:
+ super()._compute_readonly_timesheet()
diff --git a/portal_timesheet/models/project.py b/portal_timesheet/models/project.py
index 1b05e42b..deb4ae6f 100644
--- a/portal_timesheet/models/project.py
+++ b/portal_timesheet/models/project.py
@@ -8,10 +8,14 @@ class Project(models.Model):
groups="hr_timesheet.group_hr_timesheet_user, portal_timesheet.group_portal_backend_timesheet"
)
+ message_partner_ids = fields.Many2many(groups="base.group_user,portal_timesheet.group_portal_backend_timesheet")
+
class Task(models.Model):
_inherit = "project.task"
+ message_partner_ids = fields.Many2many(groups="base.group_user,portal_timesheet.group_portal_backend_timesheet")
+
def _ensure_fields_are_accessible(self, fields, operation="read", check_group_user=True):
if not self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
super()._ensure_fields_are_accessible(fields, operation, check_group_user)
diff --git a/portal_timesheet/models/res_partner.py b/portal_timesheet/models/res_partner.py
new file mode 100644
index 00000000..9c90b3d7
--- /dev/null
+++ b/portal_timesheet/models/res_partner.py
@@ -0,0 +1,33 @@
+# from odoo import api, models
+
+
+# class ResPartner(models.Model):
+# _inherit = "res.partner"
+
+# @api.model
+# def _search(self, domain, offset=0, limit=None, order=None, access_rights_uid=None, **kwargs):
+# """Use sudo for portal backend users to access partners in message_partner_ids"""
+# if self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
+# # When using sudo(), don't pass access_rights_uid as it's not needed
+# return super(ResPartner, self.sudo())._search(domain, offset=offset, limit=limit, order=order, **kwargs)
+# # Only pass access_rights_uid if it was provided
+# if access_rights_uid is not None:
+# return super()._search(
+# domain, offset=offset, limit=limit, order=order, access_rights_uid=access_rights_uid, **kwargs
+# )
+# return super()._search(domain, offset=offset, limit=limit, order=order, **kwargs)
+
+# def read(self, fields=None, load="_classic_read"):
+# """Allow portal backend users to read partners"""
+# if self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
+# return super(ResPartner, self.sudo()).read(fields=fields, load=load)
+# return super().read(fields=fields, load=load)
+
+# @api.model
+# def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None, **read_kwargs):
+# """Use sudo for portal backend users"""
+# if self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
+# return super(ResPartner, self.sudo()).search_read(
+# domain=domain, fields=fields, offset=offset, limit=limit, order=order, **read_kwargs
+# )
+# return super().search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order, **read_kwargs)
diff --git a/portal_timesheet/models/res_users.py b/portal_timesheet/models/res_users.py
index 90e49b56..71e4ece3 100644
--- a/portal_timesheet/models/res_users.py
+++ b/portal_timesheet/models/res_users.py
@@ -1,11 +1,12 @@
from odoo import models
-class User(models.Model):
- _inherit = ["res.users"]
+class ResUsers(models.Model):
+ _inherit = "res.users"
def get_last_validated_timesheet_date(self):
if not self.env.user.has_group("portal_timesheet.group_portal_backend_timesheet"):
return super().get_last_validated_timesheet_date()
else:
+ # Portal users should respect the same date validation as internal users
return self.sudo().employee_id.last_validated_timesheet_date
diff --git a/portal_timesheet/security/ir.model.access.csv b/portal_timesheet/security/ir.model.access.csv
index 8535b2a4..13229a10 100644
--- a/portal_timesheet/security/ir.model.access.csv
+++ b/portal_timesheet/security/ir.model.access.csv
@@ -1,14 +1,15 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
portal_timesheet_account_analytic_account,portal-timesheet-model_account_analytic_account,analytic.model_account_analytic_account,group_portal_backend_timesheet,1,1,0,0
portal_timesheet_account_analytic_line,portal-timesheet-model_account_analytic_line,analytic.model_account_analytic_line,group_portal_backend_timesheet,1,1,1,1
+portal_timesheet_account_analytic_plan,portal-timesheet-model_account_analytic_plan,analytic.model_account_analytic_plan,group_portal_backend_timesheet,1,0,0,0
+portal_timesheet_res_partner,portal-timesheet-model_res_partner,base.model_res_partner,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_hr_employee_public,portal-timesheet-model_hr_employee_public,hr.model_hr_employee_public,group_portal_backend_timesheet,1,0,0,0
-portal_timesheet_project_project,portal-timesheet-model_project_project,project.model_project_project,group_portal_backend_timesheet,1,0,0,0
+portal_timesheet_project_project,portal-timesheet-model_project_project,project.model_project_project,group_portal_backend_timesheet,1,1,0,0
portal_timesheet_project_task,portal-timesheet-model_project_task,project.model_project_task,group_portal_backend_timesheet,1,1,0,0
portal_timesheet_resource_calendar,portal-timesheet-model_resource_calendar,resource.model_resource_calendar,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_resource_calendar_attendance,portal-timesheet-model_resource_calendar_attendance,resource.model_resource_calendar_attendance,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_resource_calendar_leaves,portal-timesheet-model_resource_calendar_leaves,resource.model_resource_calendar_leaves,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_timer_timer,portal-timesheet-model_timer_timer,timer.model_timer_timer,group_portal_backend_timesheet,1,0,0,0
-portal_timesheet_uom_category,portal-timesheet-model_uom_category,uom.model_uom_category,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_uom_uom,portal-timesheet-model_uom_uom,uom.model_uom_uom,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_calendar_attendee,portal-timesheet-model_calendar_attendee,calendar.model_calendar_attendee,group_portal_backend_timesheet,1,0,0,0
portal_timesheet_access_hr_department_public,hr.department.public,hr.model_hr_department,group_portal_backend_timesheet,1,0,0,0
diff --git a/portal_timesheet/security/ir_rule.xml b/portal_timesheet/security/ir_rule.xml
index ca79e617..90ca8bcb 100644
--- a/portal_timesheet/security/ir_rule.xml
+++ b/portal_timesheet/security/ir_rule.xml
@@ -16,11 +16,49 @@
Analytic Line timesheet portal backend
- [('project_id', '!=', False), '|', ('project_id.message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id]), ('task_id.message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id]), ('project_id.privacy_visibility', '=', 'portal')]
+ [
+ ('project_id', '!=', False),
+ ('project_id.privacy_visibility', '=', 'portal'),
+ '|',
+ ('project_id.message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id]),
+ ('task_id.message_partner_ids', 'child_of', [user.partner_id.commercial_partner_id.id])
+ ]
+
+
+
+
+
+
diff --git a/portal_timesheet/security/res_groups.xml b/portal_timesheet/security/res_groups.xml
index 021ce809..a385bd94 100644
--- a/portal_timesheet/security/res_groups.xml
+++ b/portal_timesheet/security/res_groups.xml
@@ -1,13 +1,16 @@
-
- Portal Timesheet
-
+
+ Advanced Timesheet
+ Advanced timesheet permissions
+
+ 10
-
- Portal Timesheet
- Allows portal backend users to access the application dashboard to record hours worked on tasks and projects that have been shared with them.
-
+
+ Portal Backend: Timesheets
+ Allows portal backend users to access the application dashboard to record hours worked on tasks and projects that have been shared with them..
+
+
diff --git a/portal_timesheet/views/base_menus.xml b/portal_timesheet/views/base_menus.xml
index 399376ac..b3d27074 100644
--- a/portal_timesheet/views/base_menus.xml
+++ b/portal_timesheet/views/base_menus.xml
@@ -1,10 +1,10 @@
diff --git a/portal_timesheet/views/project_project_views.xml b/portal_timesheet/views/project_project_views.xml
new file mode 100644
index 00000000..65abee8b
--- /dev/null
+++ b/portal_timesheet/views/project_project_views.xml
@@ -0,0 +1,13 @@
+
+
+
+ project.project.template.form
+ project.project
+
+
+
+ !portal_backend.group_portal_backend
+
+
+
+