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