add parent project in timesheet

This commit is contained in:
Pawan Kumar 2021-01-29 11:53:45 +05:30
parent bd73f37e75
commit 78472f44ff
1 changed files with 6 additions and 3 deletions

View File

@ -17,12 +17,15 @@ class AccountAnalyticLine(models.Model):
end_time = fields.Float(string='End Time', digits=(16, 2))
unit_amount = fields.Float('Duration', default=0.0)
parent_project = fields.Many2one('project.project', string='Parent Project')
#sub_project = fields.Many2one('project.project', string='Sub Project')
@api.onchange('project_id')
def _onchange_parent_project_id(self):
if self.project_id and self.project_id.sub_project:
self.parent_project = self.project_id.sub_project.id
if self.project_id:
parent_project = self.env['project.project'].search([('sub_project', '=', self.project_id.id)], limit=1)
if parent_project:
self.parent_project = parent_project.id
else:
self.parent_project = False
else:
self.parent_project = False