Functionality tab Party Validation in state Analisys
This commit is contained in:
parent
53467e0d5b
commit
89ccbaa3de
16
locale/es.po
16
locale/es.po
|
@ -344,7 +344,7 @@ msgstr "Ventas"
|
|||
|
||||
msgctxt "field:crm.opportunity,source:"
|
||||
msgid "Source"
|
||||
msgstr "Original"
|
||||
msgstr "Origen"
|
||||
|
||||
msgctxt "field:crm.opportunity,start_date:"
|
||||
msgid "Start Date"
|
||||
|
@ -801,11 +801,23 @@ msgctxt ""
|
|||
msgid "Analysis"
|
||||
msgstr "Analisis"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_crm_opportunity_form_domain_cancelled"
|
||||
msgid "Cancelled"
|
||||
msgstr "Cancelado"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_crm_opportunity_form_domain_internal_validation"
|
||||
msgid "Internal Validation"
|
||||
msgstr "Validación Interna"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_crm_opportunity_form_domain_lost"
|
||||
msgid "Lost"
|
||||
msgstr "Perdido"
|
||||
|
||||
msgctxt ""
|
||||
"model:ir.action.act_window.domain,name:act_crm_opportunity_form_domain_prospecting"
|
||||
msgid "Prospecting"
|
||||
|
@ -2087,7 +2099,7 @@ msgstr "Teléfono"
|
|||
|
||||
msgctxt "selection:crm.opportunity,source:"
|
||||
msgid "Referred"
|
||||
msgstr ""
|
||||
msgstr "Referido"
|
||||
|
||||
msgctxt "selection:crm.opportunity,source:"
|
||||
msgid "Salesman"
|
||||
|
|
|
@ -168,6 +168,7 @@ class Opportunity(
|
|||
], "Source", required=True, select=True)
|
||||
# party_evaluations = fields.One2Many('crm.party_evaluation', 'opportunity', 'Party Evaluations')
|
||||
party_validations = fields.One2Many('crm.validation.line', 'origin', 'Party Validations')
|
||||
is_prospect = fields.Function(fields.Boolean('Is Prospect'), 'get_is_prospect')
|
||||
|
||||
|
||||
# del _states_start, _depends_start
|
||||
|
@ -239,11 +240,26 @@ class Opportunity(
|
|||
'lost': {
|
||||
'invisible': ~Eval('state').in_(['review', 'internal_validation']),
|
||||
},
|
||||
# 'cancelled': {
|
||||
# 'invisible': ~Eval('state').in_(['prospecting']),
|
||||
# },
|
||||
'cancelled': {
|
||||
'invisible': ~Eval('state').in_(['prospecting','quotation']),
|
||||
},
|
||||
})
|
||||
|
||||
@fields.depends('party')
|
||||
def get_is_prospect(self,name=None):
|
||||
res = True
|
||||
if self.party:
|
||||
Invoice = Pool().get('account.invoice')
|
||||
invoices = Invoice.search([
|
||||
('party','=',self.party.id),
|
||||
('type','=','out'),
|
||||
('state','!=','draft')
|
||||
])
|
||||
if len(invoices) > 0:
|
||||
res = False
|
||||
return res
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'prospecting'
|
||||
|
@ -416,7 +432,45 @@ class Opportunity(
|
|||
@ModelView.button
|
||||
@Workflow.transition('analysis')
|
||||
def analysis(cls, records):
|
||||
pass
|
||||
cls.check_party(records)
|
||||
|
||||
|
||||
@classmethod
|
||||
def check_party(cls,records):
|
||||
ValidationTemplate = Pool().get('crm.validation_template')
|
||||
ValidationLine = Pool().get('crm.validation.line')
|
||||
def get_lines(template):
|
||||
lines = []
|
||||
for line in template.lines:
|
||||
value = {
|
||||
'origin':record.id,
|
||||
'party':record.party.id,
|
||||
'sequence':line.sequence,
|
||||
'line_ask':line.ask
|
||||
}
|
||||
lines.append(value)
|
||||
lines = ValidationLine.create(lines)
|
||||
|
||||
return lines
|
||||
|
||||
for record in records:
|
||||
lines = None
|
||||
if record.is_prospect:
|
||||
template, = ValidationTemplate.search([
|
||||
('type','=','prospect'),
|
||||
])
|
||||
lines = get_lines(template)
|
||||
|
||||
else:
|
||||
template, = ValidationTemplate.search([
|
||||
('type','=','client'),
|
||||
])
|
||||
lines = get_lines(template)
|
||||
if lines:
|
||||
# cls.write([record.id],{'party_validation':lines})
|
||||
# record.party_validations = [('create',lines)]
|
||||
record.party_validations = lines
|
||||
record.save()
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
@ -441,7 +495,9 @@ class Opportunity(
|
|||
@Workflow.transition('quotation')
|
||||
@set_employee('converted_by')
|
||||
def quotation(cls, records):
|
||||
pass
|
||||
# Analyze if party validation is true in all lines
|
||||
cls.get_party_validation(records)
|
||||
# cls.procces_opportunity(records)
|
||||
|
||||
@property
|
||||
def is_forecast(self):
|
||||
|
@ -455,6 +511,19 @@ class Opportunity(
|
|||
def accepted(cls, records):
|
||||
cls.procces_opportunity(records)
|
||||
|
||||
@classmethod
|
||||
def get_party_validation(cls, records):
|
||||
|
||||
for opportunity in records:
|
||||
# print(opportunity,'Opportunity')
|
||||
# print(opportunity.party_validations,'validations')
|
||||
if opportunity.type == 'contract':
|
||||
pass
|
||||
# cls.procces_opportunity(records)
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def procces_opportunity(cls, records):
|
||||
for opportunity in records:
|
||||
|
@ -479,15 +548,15 @@ class Opportunity(
|
|||
'state': 'lost',
|
||||
})
|
||||
|
||||
# @classmethod
|
||||
# @ModelView.button
|
||||
# @Workflow.transition('cancelled')
|
||||
# def cancelled(cls, records):
|
||||
# pass
|
||||
# Date = Pool().get('ir.date')
|
||||
# cls.write([o for o in records if o.is_forecast], {
|
||||
# 'end_date': Date.today(),
|
||||
# })
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('cancelled')
|
||||
def cancelled(cls, records):
|
||||
pass
|
||||
Date = Pool().get('ir.date')
|
||||
cls.write([o for o in records if o.is_forecast], {
|
||||
'end_date': Date.today(),
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def _sale_won_states():
|
||||
|
|
|
@ -127,7 +127,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<!-- <record model="ir.action.act_window.domain"
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_cancelled">
|
||||
<field name="name">Cancelled</field>
|
||||
<field name="sequence" eval="50"/>
|
||||
|
@ -144,7 +144,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
eval="[('state', '=', 'lost')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record> -->
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_all">
|
||||
<field name="name">All</field>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
from trytond.report import Report
|
||||
from trytond.model import ModelView, ModelSQL, fields, Workflow
|
||||
from trytond.pyson import Eval, If, In, Get
|
||||
|
@ -39,7 +39,7 @@ class ValidationLine(ModelSQL, ModelView):
|
|||
party = fields.Many2One('party.party',
|
||||
'Party', required=True)
|
||||
sequence = fields.Integer('Sequence', required=True)
|
||||
date_validation = fields.Date('Date', required=True)
|
||||
date_validation = fields.Date('Date')
|
||||
line_ask = fields.Char('Ask', required=True, select=True)
|
||||
response = fields.Boolean('Response')
|
||||
comment = fields.Text('Comments')
|
||||
|
@ -48,3 +48,11 @@ class ValidationLine(ModelSQL, ModelView):
|
|||
def __setup__(cls):
|
||||
super(ValidationLine, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
@fields.depends('response')
|
||||
def on_change_response(self):
|
||||
if self.response:
|
||||
self.date_validation = date.today()
|
||||
else:
|
||||
self.date_validation = None
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<data>
|
||||
<xpath expr="/form/page[@name='party']" position="after">
|
||||
<page string="Party Validation" name="party_validations">
|
||||
<field name="party_validations" view_ids="crm.validation_line_view_tree,crm.validation_line_view_form" colspan="4"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</data>
|
|
@ -2,13 +2,12 @@
|
|||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="date_validation"/>
|
||||
<field name="date_validation"/>
|
||||
<label name="party" colspan="1"/>
|
||||
<field name="party" colspan="3"/>
|
||||
<!-- <label name="date_validation"/>
|
||||
<field name="date_validation"/> -->
|
||||
<label name="line_ask"/>
|
||||
<field name="line_ask"/>
|
||||
<field name="line_ask" />
|
||||
<label name="response"/>
|
||||
<field name="response"/>
|
||||
<separator name="comment" colspan="4"/>
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
|
||||
<field name="origin"/>
|
||||
<field name="party"/>
|
||||
<field name="date_validation"/>
|
||||
<field name="line_ask"/>
|
||||
<field name="response"/>
|
||||
<!-- <field name="origin"/>
|
||||
<field name="party"/> -->
|
||||
<field name="line_ask" colspan="10"/>
|
||||
<field name="response" colspan="2"/>
|
||||
<field name="comment" colspan="4"/>
|
||||
<field name="date_validation" colspan="2"/>
|
||||
|
||||
</tree>
|
||||
|
|
Loading…
Reference in New Issue