fix
This commit is contained in:
parent
c56cb67f2e
commit
6f841b0286
|
@ -28,22 +28,6 @@ from trytond.ir.attachment import AttachmentCopyMixin
|
||||||
from trytond.ir.note import NoteCopyMixin
|
from trytond.ir.note import NoteCopyMixin
|
||||||
from trytond.modules.company.model import employee_field, set_employee
|
from trytond.modules.company.model import employee_field, set_employee
|
||||||
|
|
||||||
# class PartyEvaluationConcept(ModelSQL, ModelView):
|
|
||||||
# ''' Model to create concepts to Party Evaluation '''
|
|
||||||
# 'Party Evaluation Concept'
|
|
||||||
# __name__ = 'crm.party_evaluation_concept'
|
|
||||||
# name = fields.Char('Concept Name', required=True)
|
|
||||||
#
|
|
||||||
# class PartyEvaluation(ModelSQL, ModelView):
|
|
||||||
# ''' Model to make analisys of economic behavior of party'''
|
|
||||||
# 'Party Evaluation'
|
|
||||||
# __name__ = 'crm.party_evaluation'
|
|
||||||
# concept = fields.Many2One('crm.party_evaluation_concept', 'Concept', required=True )
|
|
||||||
# opportunity = fields.Many2One('crm.opportunity', 'Opportunity', required=True )
|
|
||||||
# date = fields.Date('Date', required=True)
|
|
||||||
# observation = fields.Text('Observation')
|
|
||||||
# approved = fields.Boolean('Approved')
|
|
||||||
|
|
||||||
|
|
||||||
class Opportunity(
|
class Opportunity(
|
||||||
Workflow, ModelSQL, ModelView,
|
Workflow, ModelSQL, ModelView,
|
||||||
|
@ -74,19 +58,10 @@ class Opportunity(
|
||||||
states={
|
states={
|
||||||
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review'])
|
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review'])
|
||||||
})
|
})
|
||||||
|
|
||||||
# reference = fields.Selection([
|
|
||||||
# ('physical', "Physical"),
|
|
||||||
# ('electronic', "Electronic")], "Reference", select=True, sort=False,
|
|
||||||
# states={
|
|
||||||
# 'readonly': ~Eval('state').in_(['prospecting', 'analysis'])
|
|
||||||
# })
|
|
||||||
|
|
||||||
party = fields.Many2One(
|
party = fields.Many2One(
|
||||||
'party.party', "Party", select=True,
|
'party.party', "Party", select=True,
|
||||||
states={
|
states={
|
||||||
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
||||||
# 'required': ~Eval('state').in_(['lead', 'lost', 'cancelled']),
|
|
||||||
},
|
},
|
||||||
context={
|
context={
|
||||||
'company': Eval('company', -1),
|
'company': Eval('company', -1),
|
||||||
|
@ -224,7 +199,6 @@ class Opportunity(
|
||||||
'get_total_opportunity')
|
'get_total_opportunity')
|
||||||
total_without_tax = fields.Function(fields.Float('Total'),
|
total_without_tax = fields.Function(fields.Float('Total'),
|
||||||
'get_total_without_tax_opportunity')
|
'get_total_without_tax_opportunity')
|
||||||
|
|
||||||
# cancelled_reason = fields.Selection([
|
# cancelled_reason = fields.Selection([
|
||||||
# ('',''),
|
# ('',''),
|
||||||
# ('Sin acuerdo', "No se llego a un acuerdo"),
|
# ('Sin acuerdo', "No se llego a un acuerdo"),
|
||||||
|
@ -249,8 +223,6 @@ class Opportunity(
|
||||||
is_approved = fields.Function(fields.Boolean('Is Approved'), 'get_is_approved')
|
is_approved = fields.Function(fields.Boolean('Is Approved'), 'get_is_approved')
|
||||||
traceability = fields.One2Many('crm.opportunity_traceability',
|
traceability = fields.One2Many('crm.opportunity_traceability',
|
||||||
'opportunity', 'Opportunity Traceability', readonly=False)
|
'opportunity', 'Opportunity Traceability', readonly=False)
|
||||||
# del _states_start, _depends_start
|
|
||||||
# del _states_stop, _depends_stop
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
@ -339,15 +311,15 @@ class Opportunity(
|
||||||
})
|
})
|
||||||
|
|
||||||
@fields.depends('party')
|
@fields.depends('party')
|
||||||
def get_is_prospect(self,name=None):
|
def get_is_prospect(self, name=None):
|
||||||
res = True
|
res = True
|
||||||
if self.party:
|
if self.party:
|
||||||
Invoice = Pool().get('account.invoice')
|
Invoice = Pool().get('account.invoice')
|
||||||
invoices = Invoice.search([
|
invoices = Invoice.search([
|
||||||
('party','=',self.party.id),
|
('party','=',self.party.id),
|
||||||
('type','=','out'),
|
('type','=','out'),
|
||||||
('state','!=','draft')
|
('state','!=','draft')
|
||||||
])
|
])
|
||||||
if len(invoices) > 0:
|
if len(invoices) > 0:
|
||||||
res = False
|
res = False
|
||||||
return res
|
return res
|
||||||
|
@ -587,62 +559,58 @@ class Opportunity(
|
||||||
|
|
||||||
traceability = Pool().get('crm.opportunity_traceability')
|
traceability = Pool().get('crm.opportunity_traceability')
|
||||||
history = []
|
history = []
|
||||||
for record in records:
|
for record in records:
|
||||||
value = {
|
value = {
|
||||||
'opportunity':record.id,
|
'opportunity': record.id,
|
||||||
'validated_by':Transaction().user,
|
'validated_by': Transaction().user,
|
||||||
'create_date':date.today(),
|
'create_date': date.today(),
|
||||||
'action':'Cambio de estado a Análisis'
|
'action':'Cambio de estado a Análisis'
|
||||||
}
|
}
|
||||||
history.append(value)
|
history.append(value)
|
||||||
history = traceability.create(history)
|
history = traceability.create(history)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_party(cls,records):
|
def check_party(cls, records):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
ValidationTemplate = pool.get('crm.validation_template')
|
ValidationTemplate = pool.get('crm.validation_template')
|
||||||
ValidationLine = pool.get('crm.opportunity.validation')
|
ValidationLine = pool.get('crm.opportunity.validation')
|
||||||
|
|
||||||
def get_lines(template,validation_lines):
|
def get_lines(template, validation_lines):
|
||||||
lines = []
|
lines = []
|
||||||
for line in template.lines:
|
for line in template.lines:
|
||||||
print(line.id, 'validation')
|
|
||||||
if line.id not in validation_lines:
|
if line.id not in validation_lines:
|
||||||
value = {
|
value = {
|
||||||
'opportunity':record.id,
|
'opportunity': record.id,
|
||||||
'party':record.party.id,
|
'party': record.party.id,
|
||||||
'sequence':line.sequence,
|
'sequence': line.sequence,
|
||||||
'line_ask':line.ask,
|
'line_ask': line.ask,
|
||||||
'template':line.id
|
'template': line.id
|
||||||
}
|
}
|
||||||
lines.append(value)
|
lines.append(value)
|
||||||
lines = ValidationLine.create(lines)
|
lines = ValidationLine.create(lines)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
for record in records:
|
for record in records:
|
||||||
lines = None
|
lines = None
|
||||||
party_validations = [v.template.id for v in record.party_validations]
|
party_validations = [
|
||||||
if record.is_prospect:
|
v.template.id for v in record.party_validations
|
||||||
templates = ValidationTemplate.search([
|
]
|
||||||
('type','=','prospect'),
|
|
||||||
])
|
|
||||||
if not templates:
|
|
||||||
continue
|
|
||||||
lines = get_lines(templates[0], party_validations)
|
|
||||||
|
|
||||||
else:
|
_type = 'client'
|
||||||
templates = ValidationTemplate.search([
|
if record.is_prospect:
|
||||||
('type','=','client'),
|
_type = 'prospect'
|
||||||
])
|
|
||||||
if not templates:
|
templates = ValidationTemplate.search([
|
||||||
continue
|
('type', '=', _type),
|
||||||
lines = get_lines(templates[0], party_validations)
|
])
|
||||||
|
print( 'templates ...', templates)
|
||||||
|
|
||||||
|
if not templates:
|
||||||
|
continue
|
||||||
|
lines = get_lines(templates[0], party_validations)
|
||||||
|
|
||||||
if lines:
|
if lines:
|
||||||
cls.write([record],{'party_validations':[('add', lines)]})
|
cls.write([record], {'party_validations': [('add', lines)]})
|
||||||
# record.party_validations = [('create',lines)]
|
|
||||||
# record.party_validations = ('add', lines)
|
|
||||||
# record.save()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
|
|
|
@ -8,11 +8,9 @@ from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from .exceptions import CrmConfigurationError
|
from .exceptions import CrmConfigurationError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
# from sql import Null, Literal
|
|
||||||
# from sql.functions import CurrentTimestamp
|
|
||||||
from trytond.modules.company.model import employee_field, set_employee
|
from trytond.modules.company.model import employee_field, set_employee
|
||||||
|
|
||||||
# Templates for prospects and Cients...
|
|
||||||
class ValidationTemplate(ModelSQL, ModelView):
|
class ValidationTemplate(ModelSQL, ModelView):
|
||||||
"Validation Template"
|
"Validation Template"
|
||||||
__name__ = "crm.validation_template"
|
__name__ = "crm.validation_template"
|
||||||
|
@ -26,9 +24,10 @@ class ValidationTemplate(ModelSQL, ModelView):
|
||||||
lines = fields.One2Many('crm.validation_template.ask',
|
lines = fields.One2Many('crm.validation_template.ask',
|
||||||
'template', 'Asks')
|
'template', 'Asks')
|
||||||
|
|
||||||
# Ask/concept for each template
|
|
||||||
class ValidationTemplateAsk(ModelSQL, ModelView):
|
class ValidationTemplateAsk(ModelSQL, ModelView):
|
||||||
"Validation Template Ask"
|
"Validation Template Ask"
|
||||||
|
# Ask/concept for each template
|
||||||
__name__ = "crm.validation_template.ask"
|
__name__ = "crm.validation_template.ask"
|
||||||
_rec_name = 'ask'
|
_rec_name = 'ask'
|
||||||
template = fields.Many2One('crm.validation_template',
|
template = fields.Many2One('crm.validation_template',
|
||||||
|
@ -36,9 +35,10 @@ class ValidationTemplateAsk(ModelSQL, ModelView):
|
||||||
sequence = fields.Integer('Sequence', required=True, select=True)
|
sequence = fields.Integer('Sequence', required=True, select=True)
|
||||||
ask = fields.Char('Ask', required=True, select=True)
|
ask = fields.Char('Ask', required=True, select=True)
|
||||||
|
|
||||||
# Validation for each opportunity
|
|
||||||
class OpportunityValidation(ModelSQL, ModelView):
|
class OpportunityValidation(ModelSQL, ModelView):
|
||||||
"Opportunity Validation"
|
"Opportunity Validation"
|
||||||
|
# Validation for each opportunity
|
||||||
__name__ = "crm.opportunity.validation"
|
__name__ = "crm.opportunity.validation"
|
||||||
_history = True
|
_history = True
|
||||||
opportunity = fields.Many2One('crm.opportunity', 'Opportunity',
|
opportunity = fields.Many2One('crm.opportunity', 'Opportunity',
|
||||||
|
@ -55,10 +55,7 @@ class OpportunityValidation(ModelSQL, ModelView):
|
||||||
('approved', 'Approved'),
|
('approved', 'Approved'),
|
||||||
('rejected', 'Rejected'),
|
('rejected', 'Rejected'),
|
||||||
], "Response")
|
], "Response")
|
||||||
# required=True, select=True,
|
|
||||||
# sort=False, readonly=True
|
|
||||||
comment = fields.Text('Comments')
|
comment = fields.Text('Comments')
|
||||||
# validated_by = employee_field("Validated By")
|
|
||||||
validated_by = fields.Many2One('res.user', 'User')
|
validated_by = fields.Many2One('res.user', 'User')
|
||||||
blocked = fields.Boolean('Blocked', readonly=True)
|
blocked = fields.Boolean('Blocked', readonly=True)
|
||||||
history = fields.Function(fields.Text('history'), 'get_history')
|
history = fields.Function(fields.Text('history'), 'get_history')
|
||||||
|
|
Loading…
Reference in New Issue