diff --git a/project_timesheet_matrix/__init__.py b/project_timesheet_matrix/__init__.py new file mode 100644 index 0000000..12a4cc2 --- /dev/null +++ b/project_timesheet_matrix/__init__.py @@ -0,0 +1,2 @@ +from . import wizard +from . import models \ No newline at end of file diff --git a/project_timesheet_matrix/__manifest__.py b/project_timesheet_matrix/__manifest__.py new file mode 100644 index 0000000..a492bbd --- /dev/null +++ b/project_timesheet_matrix/__manifest__.py @@ -0,0 +1,18 @@ +{ + 'name': 'Project Timesheet Matrix', + 'summary': "Wizard which allows to timesheet per user per day of a month for a project", + "version": "1.0.0", + "author": "JMDN Solutions Sàrl", + "website": "https://www.jmdn-group.com", + "license": "AGPL-3", + "category": "Project", + "depends": [ + 'web_widget_x2many_2d_matrix', 'project', 'analytic' + ], + "data": [ + # 'security/ir.model.access.csv', + 'views/project_timesheet_matrix_view.xml', + 'wizard/project_timesheet_matrix_wiz.xml', + ], + "installable": True, +} diff --git a/project_timesheet_matrix/models/__init__.py b/project_timesheet_matrix/models/__init__.py new file mode 100644 index 0000000..f211b6d --- /dev/null +++ b/project_timesheet_matrix/models/__init__.py @@ -0,0 +1 @@ +from . import project_project \ No newline at end of file diff --git a/project_timesheet_matrix/models/project_project.py b/project_timesheet_matrix/models/project_project.py new file mode 100644 index 0000000..a838b46 --- /dev/null +++ b/project_timesheet_matrix/models/project_project.py @@ -0,0 +1,20 @@ +from odoo import models, fields, api + + +class ProjectProject(models.Model): + _inherit = "project.project" + + @api.model + def open_timesheets_matrix(self): + import pdb; pdb.set_trace() + wiz = self.env['project.timesheet.matrix.wiz'].create({}) + return { + 'name': 'Edit timesheets', + 'type': 'ir.actions.act_window', + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'project.timesheet.matrix.wiz', + 'target': 'new', + 'res_id': wiz.id, + 'context': self.env.context, + } diff --git a/project_timesheet_matrix/views/project_timesheet_matrix_view.xml b/project_timesheet_matrix/views/project_timesheet_matrix_view.xml new file mode 100644 index 0000000..cd5808e --- /dev/null +++ b/project_timesheet_matrix/views/project_timesheet_matrix_view.xml @@ -0,0 +1,19 @@ + + + + project.timesheet.matrix.view.form + project.project + + + +
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/project_timesheet_matrix/wizard/__init__.py b/project_timesheet_matrix/wizard/__init__.py new file mode 100644 index 0000000..4fd0dd1 --- /dev/null +++ b/project_timesheet_matrix/wizard/__init__.py @@ -0,0 +1 @@ +from . import project_timesheet_matrix_wiz diff --git a/project_timesheet_matrix/wizard/project_timesheet_matrix_wiz.py b/project_timesheet_matrix/wizard/project_timesheet_matrix_wiz.py new file mode 100644 index 0000000..a57d7eb --- /dev/null +++ b/project_timesheet_matrix/wizard/project_timesheet_matrix_wiz.py @@ -0,0 +1,24 @@ +from odoo import fields, models + +class ProjectTimesheetMatrixWizard(models.TransientModel): + _name = 'project.timesheet.matrix.wiz' + + def _default_line_ids(self): + import pdb; pdb.set_trace() + recs = self.env['account.analytic.account'].search([]) + users = self.env['account.analytic.line'].search([]).mapped('user_id') + + return [ + (0, 0, { + 'name': "{}'s task on {}".format(usr.name, rec.name), + 'account_id': rec.id, + 'user_id': usr.id, + 'unit_amount': 0, + }) + if not rec.line_ids.filtered(lambda x:x.user_id == usr) else + (4, rec.line_ids.filtered(lambda x:x.user_id == usr)[0].id) + for rec in recs + for usr in users + ] + + line_ids = fields.Many2many('account.analytic.line', default=_default_line_ids) \ No newline at end of file diff --git a/project_timesheet_matrix/wizard/project_timesheet_matrix_wiz.xml b/project_timesheet_matrix/wizard/project_timesheet_matrix_wiz.xml new file mode 100644 index 0000000..579f99c --- /dev/null +++ b/project_timesheet_matrix/wizard/project_timesheet_matrix_wiz.xml @@ -0,0 +1,21 @@ + + + + + project.timesheet.matrix.wiz + project.timesheet.matrix.wiz + form + +
+ + + + + + + +
+
+
+ +