[REM] I have not been able to debug even if I thing I am very close to make it work
This commit is contained in:
parent
dae683f931
commit
596a39b83a
2
project_timesheet_matrix/__init__.py
Normal file
2
project_timesheet_matrix/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from . import wizard
|
||||
from . import models
|
18
project_timesheet_matrix/__manifest__.py
Normal file
18
project_timesheet_matrix/__manifest__.py
Normal file
@ -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,
|
||||
}
|
1
project_timesheet_matrix/models/__init__.py
Normal file
1
project_timesheet_matrix/models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import project_project
|
20
project_timesheet_matrix/models/project_project.py
Normal file
20
project_timesheet_matrix/models/project_project.py
Normal file
@ -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,
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="project_timesheet_matrix_view_form" model="ir.ui.view">
|
||||
<field name="name">project.timesheet.matrix.view.form</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="inherit_id" ref="project.view_project_kanban"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[hasclass('o_kanban_card_manage_section')]" position="inside">
|
||||
<div>
|
||||
<!-- <a name="open_timesheets_matrix" type="object">Timesheet</a> -->
|
||||
<button name="open_timesheets_matrix" type="object" string="Workers" class="oe_stat_button" icon="fa-edit" />
|
||||
</div>
|
||||
</xpath>
|
||||
<!-- <field name="task_count" position="after">
|
||||
<button name="open_project_timesheet_matrix" type="object" string="Timesheet Workers" class="oe_stat_button" icon="fa-edit" />
|
||||
</field> -->
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
1
project_timesheet_matrix/wizard/__init__.py
Normal file
1
project_timesheet_matrix/wizard/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from . import project_timesheet_matrix_wiz
|
@ -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)
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="project_timesheet_matrix_wiz" model="ir.ui.view">
|
||||
<field name="name">project.timesheet.matrix.wiz</field>
|
||||
<field name="model">project.timesheet.matrix.wiz</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<field name="line_ids" widget="x2many_2d_matrix" field_x_axis="account_id" field_y_axis="user_id" field_value="unit_amount">
|
||||
<tree>
|
||||
<field name="account_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="unit_amount"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
Loading…
Reference in New Issue
Block a user