mirror of
https://bitbucket.org/presik/trytonpsk-crm.git
synced 2023-12-14 05:22:56 +01:00
Fix bugs and set states and transitions
This commit is contained in:
parent
0e698853a5
commit
1e0454a6d1
10
danny.html
10
danny.html
|
@ -1,10 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
ul>li>a
|
||||
</body>
|
||||
</html>
|
|
@ -35,7 +35,7 @@ class Opportunity(
|
|||
_depends_start = ['state']
|
||||
_states_stop = {
|
||||
'readonly': Eval('state').in_(
|
||||
['converted', 'won', 'lost', 'cancelled']),
|
||||
['revision', 'accepted', 'lost', 'cancelled']),
|
||||
}
|
||||
_depends_stop = ['state']
|
||||
|
||||
|
@ -120,10 +120,10 @@ class Opportunity(
|
|||
'invisible': Eval('state') != 'lost',
|
||||
}, depends=['state'])
|
||||
sales = fields.One2Many('sale.sale', 'origin', 'Sales')
|
||||
# contracts = fields.One2Many('sale.contract', 'origin', 'Contracts')
|
||||
contracts = fields.One2Many('sale.contract', 'origin', 'Contracts')
|
||||
|
||||
converted_by = employee_field(
|
||||
"Converted By", states=['converted', 'won', 'lost', 'cancelled'])
|
||||
"Converted By", states=['accepted', 'lost', 'cancelled'])
|
||||
state = fields.Selection([
|
||||
('prospecting', "Prospecting"),
|
||||
('analysis', "Analysis"),
|
||||
|
@ -155,6 +155,7 @@ class Opportunity(
|
|||
('analysis', 'review'),
|
||||
('review', 'quotation'),
|
||||
('review', 'cancelled'),
|
||||
('review', 'analysis'),
|
||||
('quotation', 'analysis'),
|
||||
('quotation', 'revision'),
|
||||
('quotation', 'cancelled'),
|
||||
|
@ -169,18 +170,25 @@ class Opportunity(
|
|||
cls._buttons.update({
|
||||
'prospecting': {
|
||||
'invisible': ~Eval('state').in_(
|
||||
['lost', 'analysis', 'revision']),
|
||||
'icon': If(Eval('state').in_(['lost']),
|
||||
'tryton-undo', 'tryton-back'),
|
||||
['analysis']),
|
||||
'icon': If(Eval('state').in_(['analysis']),
|
||||
'tryton-back', 'tryton-forward'),
|
||||
},
|
||||
'analysis': {
|
||||
'invisible': ~Eval('state').in_(['prospecting', 'quotation']),
|
||||
'invisible': ~Eval('state').in_(['prospecting', 'review', 'quotation']),
|
||||
'icon': If(Eval('state').in_(['review','quotation']),
|
||||
'tryton-back', 'tryton-forward'),
|
||||
},
|
||||
'quotation': {
|
||||
'invisible': ~Eval('state').in_(['analysis', 'revision']),
|
||||
'invisible': ~Eval('state').in_(['analysis', 'revision', 'cancelled']),
|
||||
'icon': If(Eval('state').in_(['analysis']),
|
||||
'tryton-forward', 'tryton-back'),
|
||||
},
|
||||
'review': {
|
||||
'invisible': ~Eval('state').in_(['analysis']),
|
||||
},
|
||||
'revision': {
|
||||
'invisible': ~Eval('state').in_(['prospecting', 'accepted', 'quotation']),
|
||||
'invisible': ~Eval('state').in_(['quotation', 'accepted', 'lost']),
|
||||
'icon': If(Eval('state').in_(['accepted']),
|
||||
'tryton-undo', 'tryton-back'),
|
||||
},
|
||||
|
@ -190,14 +198,10 @@ class Opportunity(
|
|||
'tryton-undo', 'tryton-back'),
|
||||
},
|
||||
'lost': {
|
||||
'invisible': ~Eval('state').in_(['prospecting', 'analysis',
|
||||
'quotation', 'revision']),
|
||||
'depends': ['state'],
|
||||
'invisible': ~Eval('state').in_(['revision']),
|
||||
},
|
||||
'cancelled': {
|
||||
'invisible': ~Eval('state').in_(['prospecting',
|
||||
'analysis']),
|
||||
'depends': ['state'],
|
||||
'invisible': ~Eval('state').in_(['prospecting']),
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -338,17 +342,24 @@ class Opportunity(
|
|||
def analysis(cls, records):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('review')
|
||||
def review(cls, records):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('revision')
|
||||
def revision(cls, records):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('quotation')
|
||||
@set_employee('converted_by')
|
||||
def convert(cls, records):
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
sales = [o.create_sale() for o in opportunities if not o.sales]
|
||||
Sale.save(sales)
|
||||
for sale in sales:
|
||||
sale.origin.copy_resources_to(sale)
|
||||
def quotation(cls, records):
|
||||
pass
|
||||
|
||||
@property
|
||||
def is_forecast(self):
|
||||
|
@ -360,12 +371,7 @@ class Opportunity(
|
|||
@classmethod
|
||||
@Workflow.transition('accepted')
|
||||
def accepted(cls, records):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
cls.write([o for o in records if o.is_forecast], {
|
||||
'end_date': Date.today(),
|
||||
'state': 'won',
|
||||
})
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
|
@ -380,11 +386,12 @@ class Opportunity(
|
|||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('cancelled')
|
||||
def cancel(cls, records):
|
||||
Date = Pool().get('ir.date')
|
||||
cls.write([o for o in records if o.is_forecast], {
|
||||
'end_date': Date.today(),
|
||||
})
|
||||
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():
|
||||
|
@ -454,7 +461,7 @@ class CrmOpportunityLine(sequence_ordered(), ModelSQL, ModelView):
|
|||
_history = True
|
||||
_states = {
|
||||
'readonly': Eval('opportunity_state').in_(
|
||||
['analysis', 'quotation', 'revision', 'accepted', 'lost', 'cancelled']),
|
||||
['revision', 'accepted', 'lost', 'cancelled']),
|
||||
}
|
||||
_depends = ['opportunity_state']
|
||||
|
||||
|
|
|
@ -70,43 +70,62 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_leads">
|
||||
<field name="name">Leads</field>
|
||||
id="act_crm_opportunity_form_domain_prospecting">
|
||||
<field name="name">Prospecting</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain" eval="[('state', '=', 'lead')]" pyson="1"/>
|
||||
<field name="domain" eval="[('state', '=', 'prospecting')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_opportunities">
|
||||
<field name="name">Opportunities</field>
|
||||
id="act_crm_opportunity_form_domain_analysis">
|
||||
<field name="name">Analysis</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain" eval="[('state', '=', 'analysis')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_quotation">
|
||||
<field name="name">Quotation</field>
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="domain" eval="[('state', '=', 'quotation')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_revision">
|
||||
<field name="name">Revision</field>
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="domain"
|
||||
eval="[('state', '=', 'opportunity')]" pyson="1"/>
|
||||
eval="[('state', '=', 'revision')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_converted">
|
||||
<field name="name">Converted</field>
|
||||
id="act_crm_opportunity_form_domain_review">
|
||||
<field name="name">Review</field>
|
||||
<field name="sequence" eval="30"/>
|
||||
<field name="domain"
|
||||
eval="[('state', '=', 'converted')]" pyson="1"/>
|
||||
eval="[('state', '=', 'review')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
id="act_crm_opportunity_form_domain_won">
|
||||
id="act_crm_opportunity_form_domain_accepted">
|
||||
<field name="name">Accepted</field>
|
||||
<field name="sequence" eval="40"/>
|
||||
<field name="domain" eval="[('state', '=', 'accepted')]" pyson="1"/>
|
||||
<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"/>
|
||||
<field name="domain"
|
||||
eval="[('state', '=', 'cancelled')]" pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.domain"
|
||||
|
@ -115,13 +134,15 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="sequence" eval="60"/>
|
||||
<field name="domain"
|
||||
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>
|
||||
<field name="sequence" eval="9999"/>
|
||||
<field name="domain"></field>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="act_crm_opportunity_form"/>
|
||||
</record>
|
||||
<menuitem
|
||||
|
@ -238,7 +259,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="keyword">form_relate</field>
|
||||
<field name="model">crm.opportunity,-1</field>
|
||||
<field name="action" ref="act_open_sale_form"/>
|
||||
</record>
|
||||
</record> -->
|
||||
|
||||
<record model="ir.ui.view" id="crm_opportunity_line_view_form">
|
||||
<field name="model">crm.opportunity.line</field>
|
||||
|
@ -251,7 +272,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="name">opportunity_line_tree</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="crm_opportunity_employee_view_tree">
|
||||
<!-- <record model="ir.ui.view" id="crm_opportunity_employee_view_tree">
|
||||
<field name="model">crm.opportunity_employee</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">opportunity_employee_tree</field>
|
||||
|
|
|
@ -64,9 +64,9 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<button name="analysis" string="Analysis" icon="tryton-forward"/>
|
||||
<button name="quotation" string="Quotation" icon="tryton-forward"/>
|
||||
<button name="revision" string="Revision" icon="tryton-forward"/>
|
||||
<button name="review" string="Review" icon="tryton-forward"/>
|
||||
<button name="accepted" string="Accepted" icon="tryton-forward"/>
|
||||
<button name="lost" string="Lost" icon="tryton-cancel"/>
|
||||
<!-- <button name="lead" icon="tryton-back"/> -->
|
||||
<!-- <button name="opportunity" icon="tryton-forward"/> -->
|
||||
</group>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue