crm
This commit is contained in:
parent
ea3b49c336
commit
d0a5dfd266
|
@ -106,12 +106,12 @@ class Opportunity(
|
|||
},
|
||||
depends=['party', 'company'])
|
||||
address = fields.Many2One('party.address', 'Address',
|
||||
domain=[('party', '=', Eval('party'))],
|
||||
select=True, depends=['party', 'state'],
|
||||
states={
|
||||
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
||||
# 'required': ~Eval('state').in_(['lead', 'lost', 'cancelled']),
|
||||
})
|
||||
domain=[('party', '=', Eval('party'))],
|
||||
select=True, depends=['party', 'state'],
|
||||
states={
|
||||
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
||||
# 'required': ~Eval('state').in_(['lead', 'lost', 'cancelled']),
|
||||
})
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
select=True,
|
||||
states={
|
||||
|
@ -162,8 +162,7 @@ class Opportunity(
|
|||
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
||||
# 'required': ~Eval('state').in_(['lead', 'lost', 'cancelled']),
|
||||
})
|
||||
comment = fields.Text('Comment', states=_states_stop,
|
||||
depends=_depends_stop)
|
||||
comment = fields.Text('Comment', states=_states_stop, depends=_depends_stop)
|
||||
lines = fields.One2Many('crm.opportunity.line', 'opportunity', 'Lines',
|
||||
states={
|
||||
'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
||||
|
@ -351,15 +350,12 @@ class Opportunity(
|
|||
res = False
|
||||
return res
|
||||
|
||||
# @fields.depends('party')
|
||||
def get_is_approved(self,name=None):
|
||||
def get_is_approved(self, name=None):
|
||||
res = True
|
||||
if self.party_validations:
|
||||
for validation in self.party_validations:
|
||||
print(validation.response,'response')
|
||||
if (validation.response !='approved'):
|
||||
res = False
|
||||
print(res,'res')
|
||||
return res
|
||||
|
||||
|
||||
|
@ -601,8 +597,10 @@ class Opportunity(
|
|||
|
||||
@classmethod
|
||||
def check_party(cls,records):
|
||||
ValidationTemplate = Pool().get('crm.validation_template')
|
||||
ValidationLine = Pool().get('crm.opportunity.validation')
|
||||
pool = Pool()
|
||||
ValidationTemplate = pool.get('crm.validation_template')
|
||||
ValidationLine = pool.get('crm.opportunity.validation')
|
||||
|
||||
def get_lines(template,validation_lines):
|
||||
lines = []
|
||||
for line in template.lines:
|
||||
|
@ -623,16 +621,21 @@ class Opportunity(
|
|||
lines = None
|
||||
party_validations = [v.template.id for v in record.party_validations]
|
||||
if record.is_prospect:
|
||||
template, = ValidationTemplate.search([
|
||||
('type','=','prospect'),
|
||||
])
|
||||
lines = get_lines(template, party_validations)
|
||||
templates = ValidationTemplate.search([
|
||||
('type','=','prospect'),
|
||||
])
|
||||
if not templates:
|
||||
continue
|
||||
lines = get_lines(templates[0], party_validations)
|
||||
|
||||
else:
|
||||
template, = ValidationTemplate.search([
|
||||
('type','=','client'),
|
||||
])
|
||||
lines = get_lines(template,party_validations)
|
||||
templates = ValidationTemplate.search([
|
||||
('type','=','client'),
|
||||
])
|
||||
if not templates:
|
||||
continue
|
||||
lines = get_lines(templates[0], party_validations)
|
||||
|
||||
if lines:
|
||||
cls.write([record],{'party_validations':[('add', lines)]})
|
||||
# record.party_validations = [('create',lines)]
|
||||
|
@ -1311,7 +1314,7 @@ class OpportunityReport(CompanyReport):
|
|||
|
||||
class OpportunityOnlyReport(CompanyReport):
|
||||
__name__ = 'crm.opportunity_only'
|
||||
|
||||
|
||||
|
||||
class OpportunityWithoutTaxReport(CompanyReport):
|
||||
__name__ = 'crm.opportunity_without_tax'
|
||||
|
|
|
@ -12,15 +12,16 @@ from trytond.i18n import gettext
|
|||
# from sql.functions import CurrentTimestamp
|
||||
from trytond.modules.company.model import employee_field, set_employee
|
||||
|
||||
# STATES = {'readonly': (Eval('state') != 'draft')}
|
||||
|
||||
# Templates for prospects and Cients...
|
||||
class ValidationTemplate(ModelSQL, ModelView):
|
||||
"Validation Template"
|
||||
__name__ = "crm.validation_template"
|
||||
name = fields.Char('Name', required=True, select=True)
|
||||
code = fields.Char('Code', required=True, select=True)
|
||||
type = fields.Selection([('prospect','Prospect'),('client','Client')],'Type')
|
||||
type = fields.Selection([
|
||||
('prospect', 'Prospect'),
|
||||
('client', 'Client')
|
||||
],'Type')
|
||||
active = fields.Boolean('Active')
|
||||
lines = fields.One2Many('crm.validation_template.ask',
|
||||
'template', 'Asks')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.1
|
||||
version=6.0.2
|
||||
depends:
|
||||
party
|
||||
sale
|
||||
|
|
|
@ -49,7 +49,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="end_date"/>
|
||||
<label name="payment_term"/>
|
||||
<field name="payment_term"/>
|
||||
|
||||
|
||||
<label name="cancelled_reason"/>
|
||||
<field name="cancelled_reason"/>
|
||||
<separator name="comment" colspan="4"/>
|
||||
|
@ -59,7 +59,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="lines"/>
|
||||
</page>
|
||||
|
||||
|
||||
<page string="Party Validation" name="party_validations">
|
||||
<field name="party_validations" view_ids="crm.opportunity_validation_view_tree,crm.opportunity_validation_view_form" colspan="4"/>
|
||||
</page>
|
||||
|
|
Loading…
Reference in New Issue