chore(ContactMethod): refactor - se centraliza lógica de actualización de colaboradores
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
a1d1e019ec
commit
f4566b7db4
@ -54,7 +54,7 @@ class Prospect(ModelSQL, ModelView, DeactivableMixin):
|
||||
@fields.depends('prospect_trace', 'contact_methods')
|
||||
def on_change_contact_methods(self):
|
||||
for contact in self.contact_methods:
|
||||
contact.prospect_trace = self.prospect_trace
|
||||
contact.update_collaborators(changed_from='prospect')
|
||||
|
||||
@fields.depends('city', 'department')
|
||||
def on_change_city(self):
|
||||
@ -89,6 +89,12 @@ class ContactMethod(ModelSQL, ModelView):
|
||||
def default_contact_type(cls):
|
||||
return 'mobile'
|
||||
|
||||
def update_collaborators(self, changed_from):
|
||||
if (changed_from == 'prospect'):
|
||||
self.prospect_trace = self.prospect.prospect_trace
|
||||
if (changed_from == 'prospect_trace'):
|
||||
self.prospect = self.prospect_trace.prospect
|
||||
|
||||
def get_rec_name(self, name):
|
||||
fields = [self.name, self.job, self.value]
|
||||
contact_rec_name = ''
|
||||
|
@ -52,7 +52,7 @@ class ProspectTrace(ModelSQL, ModelView):
|
||||
@fields.depends('prospect_contacts', 'prospect')
|
||||
def on_change_prospect_contacts(self):
|
||||
for contact in self.prospect_contacts:
|
||||
contact.prospect = self.prospect
|
||||
contact.update_collaborators(changed_from='prospect_trace')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
Loading…
Reference in New Issue
Block a user