From b40fcea38ff4eea672ea06ef6f08ec1b29f38eb8 Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Thu, 18 Nov 2021 12:11:57 +0530 Subject: [PATCH 1/3] add except condition --- sub_project/models/sub_project.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sub_project/models/sub_project.py b/sub_project/models/sub_project.py index 81a8e68..6ba3efe 100755 --- a/sub_project/models/sub_project.py +++ b/sub_project/models/sub_project.py @@ -12,22 +12,21 @@ class SubProject(models.Model): @api.onchange('parent_project', 'sub_project') def onchange_parent_project_sub_project(self): - user_list = [] if self.parent_project.sub_project: - user_list = self.parent_project.sub_project.ids - user_list.append(self._origin.id) - self.parent_project.sub_project = user_list + if self.parent_project: + user_list = self.parent_project.sub_project.ids + user_list.append(self._origin.id) + self.parent_project.sub_project = user_list + else: + self.parent_project.sub_project = self.ids if self.sub_project: for rec in self.sub_project: - #print('AAAAAAAAAAA', rec, rec._origin.id) sub_project = self.env['project.project'].search([('id', '=', rec._origin.id)], limit=1) - #print('BBBBBBBBBBB', sub_project, self._origin.id) sub_project.write({'parent_project': self._origin.id}) - class InheritProjectTask(models.Model): _inherit = 'project.task' From 272b6d2039361b8eb327ca6cbd397111c0efbe70 Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Thu, 18 Nov 2021 12:14:35 +0530 Subject: [PATCH 2/3] simulator module --- hspl_user_simulation/LICENSE | 0 hspl_user_simulation/README.md | 0 hspl_user_simulation/__init__.py | 0 hspl_user_simulation/__manifest__.py | 0 hspl_user_simulation/models/__init__.py | 0 hspl_user_simulation/models/models.py | 0 hspl_user_simulation/security/groups.xml | 0 hspl_user_simulation/security/ir.model.access.csv | 0 .../static/description/assets/css/theme.css | 0 .../static/description/assets/images/app.svg | 0 .../assets/images/heliconia-logo-light.png | Bin .../description/assets/images/heliconia-logo.png | Bin .../static/description/assets/images/heliconia.png | Bin .../description/heliconia_odoo_user_simulation.gif | Bin .../description/heliconia_odoo_user_simulation1.gif | Bin hspl_user_simulation/static/description/icon.png | Bin hspl_user_simulation/static/description/index.html | 0 .../screenshots/hspl_user_simulation_1.png | Bin .../screenshots/hspl_user_simulation_2.png | Bin .../screenshots/hspl_user_simulation_3.png | Bin .../screenshots/hspl_user_simulation_4.png | Bin .../static/src/js/user_simulation.js | 0 hspl_user_simulation/static/src/xml/widget.xml | 0 hspl_user_simulation/views/templates.xml | 0 hspl_user_simulation/views/views.xml | 0 hspl_user_simulation/wizard/__init__.py | 0 .../wizard/user_simulation_wizard.py | 0 .../wizard/user_simulation_wizard_view.xml | 0 28 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 hspl_user_simulation/LICENSE mode change 100644 => 100755 hspl_user_simulation/README.md mode change 100644 => 100755 hspl_user_simulation/__init__.py mode change 100644 => 100755 hspl_user_simulation/__manifest__.py mode change 100644 => 100755 hspl_user_simulation/models/__init__.py mode change 100644 => 100755 hspl_user_simulation/models/models.py mode change 100644 => 100755 hspl_user_simulation/security/groups.xml mode change 100644 => 100755 hspl_user_simulation/security/ir.model.access.csv mode change 100644 => 100755 hspl_user_simulation/static/description/assets/css/theme.css mode change 100644 => 100755 hspl_user_simulation/static/description/assets/images/app.svg mode change 100644 => 100755 hspl_user_simulation/static/description/assets/images/heliconia-logo-light.png mode change 100644 => 100755 hspl_user_simulation/static/description/assets/images/heliconia-logo.png mode change 100644 => 100755 hspl_user_simulation/static/description/assets/images/heliconia.png mode change 100644 => 100755 hspl_user_simulation/static/description/heliconia_odoo_user_simulation.gif mode change 100644 => 100755 hspl_user_simulation/static/description/heliconia_odoo_user_simulation1.gif mode change 100644 => 100755 hspl_user_simulation/static/description/icon.png mode change 100644 => 100755 hspl_user_simulation/static/description/index.html mode change 100644 => 100755 hspl_user_simulation/static/description/screenshots/hspl_user_simulation_1.png mode change 100644 => 100755 hspl_user_simulation/static/description/screenshots/hspl_user_simulation_2.png mode change 100644 => 100755 hspl_user_simulation/static/description/screenshots/hspl_user_simulation_3.png mode change 100644 => 100755 hspl_user_simulation/static/description/screenshots/hspl_user_simulation_4.png mode change 100644 => 100755 hspl_user_simulation/static/src/js/user_simulation.js mode change 100644 => 100755 hspl_user_simulation/static/src/xml/widget.xml mode change 100644 => 100755 hspl_user_simulation/views/templates.xml mode change 100644 => 100755 hspl_user_simulation/views/views.xml mode change 100644 => 100755 hspl_user_simulation/wizard/__init__.py mode change 100644 => 100755 hspl_user_simulation/wizard/user_simulation_wizard.py mode change 100644 => 100755 hspl_user_simulation/wizard/user_simulation_wizard_view.xml diff --git a/hspl_user_simulation/LICENSE b/hspl_user_simulation/LICENSE old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/README.md b/hspl_user_simulation/README.md old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/__init__.py b/hspl_user_simulation/__init__.py old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/__manifest__.py b/hspl_user_simulation/__manifest__.py old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/models/__init__.py b/hspl_user_simulation/models/__init__.py old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/models/models.py b/hspl_user_simulation/models/models.py old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/security/groups.xml b/hspl_user_simulation/security/groups.xml old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/security/ir.model.access.csv b/hspl_user_simulation/security/ir.model.access.csv old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/assets/css/theme.css b/hspl_user_simulation/static/description/assets/css/theme.css old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/assets/images/app.svg b/hspl_user_simulation/static/description/assets/images/app.svg old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/assets/images/heliconia-logo-light.png b/hspl_user_simulation/static/description/assets/images/heliconia-logo-light.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/assets/images/heliconia-logo.png b/hspl_user_simulation/static/description/assets/images/heliconia-logo.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/assets/images/heliconia.png b/hspl_user_simulation/static/description/assets/images/heliconia.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/heliconia_odoo_user_simulation.gif b/hspl_user_simulation/static/description/heliconia_odoo_user_simulation.gif old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/heliconia_odoo_user_simulation1.gif b/hspl_user_simulation/static/description/heliconia_odoo_user_simulation1.gif old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/icon.png b/hspl_user_simulation/static/description/icon.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/index.html b/hspl_user_simulation/static/description/index.html old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_1.png b/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_1.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_2.png b/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_2.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_3.png b/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_3.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_4.png b/hspl_user_simulation/static/description/screenshots/hspl_user_simulation_4.png old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/src/js/user_simulation.js b/hspl_user_simulation/static/src/js/user_simulation.js old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/static/src/xml/widget.xml b/hspl_user_simulation/static/src/xml/widget.xml old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/views/templates.xml b/hspl_user_simulation/views/templates.xml old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/views/views.xml b/hspl_user_simulation/views/views.xml old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/wizard/__init__.py b/hspl_user_simulation/wizard/__init__.py old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/wizard/user_simulation_wizard.py b/hspl_user_simulation/wizard/user_simulation_wizard.py old mode 100644 new mode 100755 diff --git a/hspl_user_simulation/wizard/user_simulation_wizard_view.xml b/hspl_user_simulation/wizard/user_simulation_wizard_view.xml old mode 100644 new mode 100755 From 6d34e347c9bb0a9e63af6b939ead9b76bc0ef3de Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Thu, 18 Nov 2021 19:20:00 +0530 Subject: [PATCH 3/3] change create and write method --- sub_project/models/sub_project.py | 60 ++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/sub_project/models/sub_project.py b/sub_project/models/sub_project.py index 6ba3efe..18b8c91 100755 --- a/sub_project/models/sub_project.py +++ b/sub_project/models/sub_project.py @@ -10,21 +10,57 @@ class SubProject(models.Model): domain="[('is_sub_project', '=', True),('parent_project', '=', False)]", string='Sub Project') parent_project = fields.Many2one('project.project', domain="[('is_sub_project', '=', False)]", string='Parent Project') - @api.onchange('parent_project', 'sub_project') - def onchange_parent_project_sub_project(self): - if self.parent_project.sub_project: - if self.parent_project: - user_list = self.parent_project.sub_project.ids - user_list.append(self._origin.id) - self.parent_project.sub_project = user_list + # @api.onchange('parent_project', 'sub_project') + # def onchange_parent_project_sub_project(self): + # if self.parent_project.sub_project: + # if self.parent_project: + # user_list = self.parent_project.sub_project.ids + # print('11111111111', self, self.id, self._origin.id) + # user_list.append(self._origin.id) + # self.parent_project.sub_project = user_list + # else: + # self.parent_project.sub_project = self.ids + # if self.sub_project: + # for rec in self.sub_project: + # sub_project = self.env['project.project'].search([('id', '=', rec._origin.id)], limit=1) + # sub_project.write({'parent_project': self._origin.id}) + + @api.model + def create(self, vals): + value = super(SubProject, self).create(vals) + if value and value.parent_project: + if value.parent_project.sub_project: + user_list = value.parent_project.sub_project.ids + user_list.append(value.id) + value.parent_project.sub_project = user_list else: - self.parent_project.sub_project = self.ids - if self.sub_project: - for rec in self.sub_project: - sub_project = self.env['project.project'].search([('id', '=', rec._origin.id)], limit=1) - sub_project.write({'parent_project': self._origin.id}) + value.parent_project.sub_project = value.ids + if value and value.sub_project: + value.write({'parent_project': value.id}) + return value + def write(self, vals): + list1 = self.sub_project.ids + res = super(SubProject, self).write(vals) + if vals.get('parent_project'): + parent_prjt = self.env['project.project'].search([('id', '=', vals.get('parent_project'))], limit=1) + user_list = parent_prjt.sub_project.ids + user_list.append(self.id) + parent_prjt.sub_project = user_list + if vals.get('sub_project'): + list2 = self.sub_project.ids + if len(list2) > len(list1): + list3 = (set(list2)) - (set(list1)) + for record in list(list3): + self.env['project.project'].search([('id', '=', int(record))], limit=1).write( + {'parent_project': self.id}) + if len(list1) > len(list2): + list3 = (set(list1)) - (set(list2)) + for record in list(list3): + self.env['project.project'].search([('id', '=', int(record))], limit=1).write( + {'parent_project': False, 'is_sub_project': False}) + return res class InheritProjectTask(models.Model):