add code for project to sub-project
This commit is contained in:
parent
1616e3654e
commit
79df1fb760
|
@ -20,7 +20,32 @@ class AccountAnalyticLine(models.Model):
|
|||
end_datetime = fields.Datetime("End Time", required=True)
|
||||
unit_amount = fields.Float('Duration', default=0.0)
|
||||
parent_project = fields.Many2one('project.project', related='project_id.parent_project', string='Parent Project')
|
||||
sub_project = fields.Many2many('project.project', 'project_subproject_timesheet_rel', 'project_id', 'id',
|
||||
domain="[('is_sub_project', '=', True)]",
|
||||
string='Sub Project')
|
||||
|
||||
# @api.onchange('employee_id')
|
||||
# def onchange_employee_id(self):
|
||||
# res = {}
|
||||
# emp_ids = [emp.employee_id.id for emp in self.project_id.sale_line_employee_ids]
|
||||
# res['domain'] = {'employee_id': [('id', 'in', emp_ids)]}
|
||||
# if 'project_id' in self.env.context:
|
||||
# # if not self.env.context['project_id']:
|
||||
# # raise UserError(_('Please save record before add a line'))
|
||||
# if not emp_ids:
|
||||
# raise UserError(_('Please add consultant at Invoicing tab before add a line'))
|
||||
# res['domain'] = {'employee_id': [('id', 'in', emp_ids)]}
|
||||
# return res
|
||||
|
||||
@api.onchange('project_id')
|
||||
def _onchange_sub_project_id(self):
|
||||
self.sub_project = False
|
||||
res = {}
|
||||
if self.project_id and self.project_id.sub_project:
|
||||
res['domain'] = {'sub_project': [('id', 'in', self.project_id.sub_project.ids)]}
|
||||
else:
|
||||
res['domain'] = {'sub_project': [('id', '=', False)]}
|
||||
return res
|
||||
|
||||
def _default_start_datetime(self):
|
||||
return fields.Datetime.to_string(datetime.combine(fields.Datetime.now(), datetime.min.time()))
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
<field name="employee_id" invisible="1"/>
|
||||
<field name="project_id" required="1" options="{'no_create_edit': True}"
|
||||
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
|
||||
<field name="sub_project" widget="many2many_tags" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
|
||||
<field name="task_id" optional="show" options="{'no_create_edit': True, 'no_open': True}"
|
||||
widget="task_with_hours" context="{'default_project_id': project_id}"
|
||||
domain="[('project_id', '=', project_id)]"/>
|
||||
|
@ -77,7 +78,7 @@
|
|||
<field name="end_datetime" string="End Time"/><!--custom-->
|
||||
<field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total"
|
||||
decoration-danger="unit_amount > 24"/>
|
||||
<field name="parent_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/><!--custom-->
|
||||
<!--<field name="parent_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>--><!--custom-->
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
'license': '',
|
||||
'depends': ['base', 'project'],
|
||||
'data': ['views/sub_project.xml',
|
||||
#'views/analytic_view.xml',
|
||||
#'views/analytic_view.xml',
|
||||
'security/ir.model.access.csv'],
|
||||
'demo': [''],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ import dateutil.parser
|
|||
class AccountAnalyticLineSubProject(models.Model):
|
||||
_inherit = 'account.analytic.line'
|
||||
|
||||
sub_project = fields.Many2many('project.project', 'project_subproject_timesheet_rel', 'project_id', 'id',
|
||||
domain="[('is_sub_project', '=', True),('parent_project', '=', False)]",
|
||||
string='Sub Project')
|
||||
# sub_project = fields.Many2many('project.project', 'project_subproject_timesheet_rel', 'project_id', 'id',
|
||||
# domain="[('is_sub_project', '=', True),('parent_project', '=', False)]",
|
||||
# string='Sub Project')
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="hr_timesheet_line_tree_inherit_subproject" model="ir.ui.view">
|
||||
<!--<record id="hr_timesheet_line_tree_inherit_subproject" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.tree.subproject</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="inherit_id" ref="hr_timesheet.timesheet_view_tree_user"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='project_id']" position="after">
|
||||
<field name="sub_project"/>
|
||||
<field name="sub_project" widget="many2many_tags"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</record>-->
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue