Browse Source

[IMP] agreement: Provide the value to copy for non-relational fields

pull/293/head
Maxime Chambreuil 6 years ago
parent
commit
499ab4bcb7
  1. 4
      agreement/models/agreement.py
  2. 4
      agreement/models/agreement_appendix.py
  3. 4
      agreement/models/agreement_clause.py
  4. 4
      agreement/models/agreement_recital.py
  5. 11
      agreement/models/agreement_section.py

4
agreement/models/agreement.py

@ -342,6 +342,10 @@ class Agreement(models.Model):
@api.onchange('sub_model_object_field_id', 'default_value')
def onchange_copyvalue(self):
if self.field_id or self.default_value:
self.copyvalue = "${object.%s or %s}" % \
(self.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,

4
agreement/models/agreement_appendix.py

@ -57,6 +57,10 @@ class AgreementAppendix(models.Model):
@api.onchange('sub_model_object_field_id', 'default_value')
def onchange_copyvalue(self):
if self.field_id or self.default_value:
self.copyvalue = "${object.%s or %s}" % \
(self.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,

4
agreement/models/agreement_clause.py

@ -66,6 +66,10 @@ class AgreementClause(models.Model):
@api.onchange('sub_model_object_field_id', 'default_value')
def onchange_copyvalue(self):
if self.field_id or self.default_value:
self.copyvalue = "${object.%s or %s}" % \
(self.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,

4
agreement/models/agreement_recital.py

@ -58,6 +58,10 @@ class AgreementRecital(models.Model):
@api.onchange('sub_model_object_field_id', 'default_value')
def onchange_copyvalue(self):
if self.field_id or self.default_value:
self.copyvalue = "${object.%s or %s}" % \
(self.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,

11
agreement/models/agreement_section.py

@ -54,11 +54,18 @@ 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.field_id or self.default_value:
self.copyvalue = "${object.%s or %s}" % \
(self.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.copyvalue = "${object.%s.%s or %s}" %\
(self.field_id.name,
self.sub_model_object_field_id.name,
self.default_value or '\'\'')

Loading…
Cancel
Save