Merge branch 'sub_project_timesheet' into 'master'

remove timesheet sup-project issue

See merge request prakash.jain/cor-odoo!271
This commit is contained in:
pawan.sharma 2022-11-07 13:48:22 +05:30
commit 3c11078cfa
2 changed files with 20 additions and 8 deletions

View File

@ -37,6 +37,14 @@ class AccountAnalyticLine(models.Model):
])
return domain
@api.depends('project_id', 'sub_project')
def compute_sub_project_id(self):
for record in self:
if record.project_id and record.project_id.is_sub_project == True and record.project_id.sub_project:
record.sub_project_ids = record.project_id.sub_project.ids
else:
record.sub_project_ids = False
def default_get(self, field_list):
result = super(AccountAnalyticLine, self).default_get(field_list)
if self.env.user:
@ -53,13 +61,13 @@ class AccountAnalyticLine(models.Model):
date = fields.Date('Date', required=True, index=True, compute='_compute_start_end_date', store=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.Many2one('project.project', domain="[('is_sub_project', '=', True)]",
string='Sub Project')
sub_project_ids = fields.Many2many('project.project', compute='compute_sub_project_id')
sub_project = fields.Many2one('project.project', string='Sub Project')
active_project = fields.Boolean(related='project_id.active', store=True)
pricing_type = fields.Selection(related='project_id.pricing_type', store=True)
project_type = fields.Selection(related='project_id.project_type', store=True)
@api.onchange('project_id')
"""@api.onchange('project_id')
def _onchange_sub_project_id(self):
self.sub_project = False
res = {}
@ -67,7 +75,7 @@ class AccountAnalyticLine(models.Model):
res['domain'] = {'sub_project': [('id', 'in', self.project_id.sub_project.ids)]}
else:
res['domain'] = {'sub_project': [('id', '=', False)]}
return res
return res"""
def _default_start_datetime(self):
return fields.Datetime.to_string(datetime.combine(fields.Datetime.now(), datetime.min.time()))

View File

@ -66,10 +66,13 @@
<field name="date" readonly="1" invisible="1"/>
<field name="employee_id" invisible="1"/>
<!--<field name="project_ids" widget="many2many_tags"/>-->
<field name="project_id" required="1" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
<field name="project_id" required="1"
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"
/>
<field name="sub_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
/>
<field name="sub_project_ids" widget="many2many_tags" invisible="1"/>
<field name="sub_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
domain="[('id', 'in', sub_project_ids)]"/>
<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)]"/>
@ -164,7 +167,8 @@
</group>
<group>
<group>
<field name="project_id" required="1" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
<field name="project_id" required="1"
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
<field name="sub_project"
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>