Skip to content

Commit

Permalink
Merge pull request #22 from Antiun/pr-event_project_fix
Browse files Browse the repository at this point in the history
[FIX] Bufixes in event to project sync
  • Loading branch information
rafaelbn committed Dec 3, 2015
2 parents bd1a9e8 + ff640d3 commit 8c61f3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 11 additions & 7 deletions event_project/models/event_event.py
Expand Up @@ -25,9 +25,9 @@ def _count_tasks(self):
self.count_tasks = len(self.task_ids)

def project_data_update(self, vals):
recalculate = False
if self.project_id:
project_vals = {}
recalculate = False
if vals.get('name'):
project_vals['name'] = self.name
if vals.get('date_begin'):
Expand All @@ -38,9 +38,12 @@ def project_data_update(self, vals):
recalculate = True
if project_vals:
self.project_id.write(project_vals)
if recalculate:
self.project_id.project_recalculate()
return True
return recalculate
return False

def project_free(self, vals):
if self.project_id and vals.get('project_id') is False:
self.project_id.write({'event_id': False})

@api.model
def create(self, vals):
Expand All @@ -50,8 +53,9 @@ def create(self, vals):

@api.one
def write(self, vals):
self.project_free(vals)
super(EventEvent, self).write(vals)
if self.env.context.get('no_recalculate'):
return True
self.project_data_update(vals)
recalculate = self.project_data_update(vals)
if recalculate and not self.env.context.get('no_recalculate'):
self.project_id.project_recalculate()
return True
3 changes: 2 additions & 1 deletion event_project/views/event_event_view.xml
Expand Up @@ -23,7 +23,8 @@
name="%(action_project_template_wizard)d" type="action"/>
</button>
<field name="date_tz" position="after">
<field name="project_id"/>
<field name="project_id"
domain="[('event_id', '=', False), ('state', 'not in', ('template', 'cancelled', 'close'))]"/>
</field>
<div class="oe_right oe_button_box" position="inside">
<button name="%(act_event_task_list)d"
Expand Down

0 comments on commit 8c61f3b

Please sign in to comment.