[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:
David Drapeau 2019-06-11 23:34:10 +02:00
parent dae683f931
commit 596a39b83a
8 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,2 @@
from . import wizard
from . import models

View 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,
}

View File

@ -0,0 +1 @@
from . import project_project

View 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,
}

View File

@ -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>

View File

@ -0,0 +1 @@
from . import project_timesheet_matrix_wiz

View File

@ -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)

View File

@ -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>