diff --git a/agreement/models/agreement.py b/agreement/models/agreement.py index 58a930dd..1cf44a1f 100644 --- a/agreement/models/agreement.py +++ b/agreement/models/agreement.py @@ -342,11 +342,15 @@ class Agreement(models.Model): @api.onchange('sub_model_object_field_id', 'default_value') def onchange_copyvalue(self): - if self.sub_model_object_field_id or self.default_value: - self.copyvalue = "${object.%s.%s or %s}" % \ + if self.field_id or self.default_value: + self.copyvalue = "${object.%s or %s}" % \ (self.field_id.name, - self.sub_model_object_field_id.name, self.default_value or '\'\'') + if self.sub_model_object_field_id or self.default_value: + self.copyvalue = "${object.%s.%s or %s}" % \ + (self.field_id.name, + self.sub_model_object_field_id.name, + self.default_value or '\'\'') # Used for Kanban grouped_by view @api.model diff --git a/agreement/models/agreement_appendix.py b/agreement/models/agreement_appendix.py index 03ff8337..0d3d2a55 100644 --- a/agreement/models/agreement_appendix.py +++ b/agreement/models/agreement_appendix.py @@ -57,11 +57,15 @@ class AgreementAppendix(models.Model): @api.onchange('sub_model_object_field_id', 'default_value') def onchange_copyvalue(self): - if self.sub_model_object_field_id or self.default_value: - self.copyvalue = "${object.%s.%s or %s}" % \ + if self.field_id or self.default_value: + self.copyvalue = "${object.%s or %s}" % \ (self.field_id.name, - self.sub_model_object_field_id.name, self.default_value or '\'\'') + if self.sub_model_object_field_id or self.default_value: + self.copyvalue = "${object.%s.%s or %s}" % \ + (self.field_id.name, + self.sub_model_object_field_id.name, + self.default_value or '\'\'') # compute the dynamic content for mako expression @api.multi diff --git a/agreement/models/agreement_clause.py b/agreement/models/agreement_clause.py index fd3e979d..38e37ab6 100644 --- a/agreement/models/agreement_clause.py +++ b/agreement/models/agreement_clause.py @@ -66,11 +66,15 @@ class AgreementClause(models.Model): @api.onchange('sub_model_object_field_id', 'default_value') def onchange_copyvalue(self): - if self.sub_model_object_field_id or self.default_value: - self.copyvalue = "${object.%s.%s or %s}" % \ + if self.field_id or self.default_value: + self.copyvalue = "${object.%s or %s}" % \ (self.field_id.name, - self.sub_model_object_field_id.name, self.default_value or '\'\'') + if self.sub_model_object_field_id or self.default_value: + self.copyvalue = "${object.%s.%s or %s}" % \ + (self.field_id.name, + self.sub_model_object_field_id.name, + self.default_value or '\'\'') # compute the dynamic content for mako expression @api.multi diff --git a/agreement/models/agreement_recital.py b/agreement/models/agreement_recital.py index ea424310..4cc43db4 100644 --- a/agreement/models/agreement_recital.py +++ b/agreement/models/agreement_recital.py @@ -58,11 +58,15 @@ class AgreementRecital(models.Model): @api.onchange('sub_model_object_field_id', 'default_value') def onchange_copyvalue(self): - if self.sub_model_object_field_id or self.default_value: - self.copyvalue = "${object.%s.%s or %s}" % \ + if self.field_id or self.default_value: + self.copyvalue = "${object.%s or %s}" % \ (self.field_id.name, - self.sub_model_object_field_id.name, self.default_value or '\'\'') + if self.sub_model_object_field_id or self.default_value: + self.copyvalue = "${object.%s.%s or %s}" % \ + (self.field_id.name, + self.sub_model_object_field_id.name, + self.default_value or '\'\'') # compute the dynamic content for mako expression @api.multi diff --git a/agreement/models/agreement_section.py b/agreement/models/agreement_section.py index fe8e46d7..86e9db16 100644 --- a/agreement/models/agreement_section.py +++ b/agreement/models/agreement_section.py @@ -54,14 +54,21 @@ class AgreementSection(models.Model): if self.field_id and self.field_id.relation: self.sub_object_id = self.env['ir.model'].search( [('model', '=', self.field_id.relation)])[0] + else: + self.sub_object_id = False - @api.onchange('sub_model_object_field_id', 'default_value') + + @api.onchange('field_id', 'sub_model_object_field_id', 'default_value') def onchange_copyvalue(self): - if self.sub_model_object_field_id or self.default_value: - self.copyvalue = "${object.%s.%s or %s}" % \ + if self.field_id or self.default_value: + self.copyvalue = "${object.%s or %s}" % \ (self.field_id.name, - self.sub_model_object_field_id.name, self.default_value or '\'\'') + if self.sub_model_object_field_id or self.default_value: + self.copyvalue = "${object.%s.%s or %s}" %\ + (self.field_id.name, + self.sub_model_object_field_id.name, + self.default_value or '\'\'') # compute the dynamic content for mako expression @api.multi