Add commercial conditions
This commit is contained in:
parent
accf5d3dda
commit
7c5073f47a
|
@ -36,6 +36,7 @@ def register():
|
|||
opportunity.CrmOpportunityLine,
|
||||
opportunity.CrmOpportunityFollowUp,
|
||||
opportunity.OpportunityCancellReason,
|
||||
opportunity.OpportunitySaleConditions,
|
||||
ir.Cron,
|
||||
party_validation.ValidationTemplate,
|
||||
party_validation.ValidationTemplateAsk,
|
||||
|
|
|
@ -61,6 +61,7 @@ class Opportunity(
|
|||
'company': Eval('company', -1),
|
||||
},
|
||||
depends=['state', 'company'])
|
||||
party_category = fields.Many2One('party.category', 'Party Category')
|
||||
contact = fields.Many2One(
|
||||
'party.contact_mechanism', "Contact",
|
||||
domain=[('party', '=', Eval('party'))],
|
||||
|
@ -113,8 +114,8 @@ class Opportunity(
|
|||
domain=[('company', '=', Eval('company'))])
|
||||
start_date = fields.Date('Start Date', required=True, select=True,
|
||||
states=_states_start, depends=_depends_start)
|
||||
end_date = fields.Date('End Date', select=True,
|
||||
states=_states_stop, depends=_depends_stop)
|
||||
end_date = fields.Date('End Date', states=_states_stop,
|
||||
depends=_depends_stop)
|
||||
description = fields.Char('Description',
|
||||
states={
|
||||
'readonly': Eval('state').in_(['won', 'lost']),
|
||||
|
@ -146,25 +147,8 @@ class Opportunity(
|
|||
'invisible': Eval('state') != 'lost',
|
||||
}, depends=['state'])
|
||||
sales = fields.One2Many('sale.sale', 'origin', 'Sales')
|
||||
|
||||
# Must to add from sale_contract
|
||||
# contracts = fields.One2Many('sale.contract', 'origin', 'Contracts')
|
||||
|
||||
# converted_by = employee_field(
|
||||
# "Converted By", states=['converted', 'won', 'lost'])
|
||||
# state = fields.Selection([
|
||||
# ('prospecting', "Prospecting"),
|
||||
# ('analysis', "Analysis"),
|
||||
# ('quotation', "Quotation"),
|
||||
# ('quote_approbation', "Quote Approbation"),
|
||||
# ('quote_revision', "Quote Revision"),
|
||||
# ('review', "Review"),
|
||||
# ('customer_approbation', "Customer Approbation"),
|
||||
# ('accepted', "Accepted"),
|
||||
# ('cancelled', "Cancelled"),
|
||||
# ('lost', "Lost"),
|
||||
# ], "State", required=True, select=True,
|
||||
# sort=False, readonly=True)
|
||||
state = fields.Selection([
|
||||
('lead', 'Lead'),
|
||||
('opportunity', 'Opportunity'),
|
||||
|
@ -172,12 +156,12 @@ class Opportunity(
|
|||
('won', 'Won'),
|
||||
('cancelled', 'Cancelled'),
|
||||
('lost', 'Lost'),
|
||||
], "State", required=True, select=True,
|
||||
], "State", required=True,
|
||||
sort=False, readonly=True)
|
||||
type = fields.Selection([
|
||||
('sale', 'Sale'),
|
||||
('contract', 'Contract'),
|
||||
], "Type", required=True, select=True,
|
||||
], "Type", required=True,
|
||||
states={
|
||||
'readonly': Eval('state').in_(['won', 'lost'])
|
||||
})
|
||||
|
@ -185,27 +169,19 @@ class Opportunity(
|
|||
total = fields.Function(fields.Float('Total'), 'get_total_opportunity')
|
||||
total_without_tax = fields.Function(fields.Float('Total'),
|
||||
'get_total_without_tax_opportunity')
|
||||
# cancelled_reason = fields.Selection([
|
||||
# ('',''),
|
||||
# ('Sin acuerdo', "No se llego a un acuerdo"),
|
||||
# ('cliente_bloqueado', "No rentable para la empresa")], "Cancelled Reason", required=False,
|
||||
# states={
|
||||
# 'invisible': ~Eval('state').in_(['analysis', 'review', 'quote_revision', 'cancelled', 'lost'])
|
||||
# }, depends=['state'])
|
||||
# states={
|
||||
# 'readonly': ~Eval('state').in_(['prospecting', 'analysis'])
|
||||
# }
|
||||
conditions = fields.Many2Many('crm.opportunity-sale.condition',
|
||||
'opportunity', 'condition', 'Commercial Conditions')
|
||||
cancelled_reason = fields.Many2One(
|
||||
'crm.opportunity_cancelled_reason', 'Cancelled Reason Concept',
|
||||
select=True,
|
||||
states={
|
||||
#'readonly': ~Eval('state').in_(['prospecting', 'quote_revision', 'review']),
|
||||
'invisible': ~Eval('state').in_(['won'])
|
||||
}, depends=['state'])
|
||||
party_validations = fields.One2Many('crm.opportunity.validation',
|
||||
'opportunity', 'Party Validations')
|
||||
is_prospect = fields.Function(fields.Boolean('Is Prospect'), 'get_is_prospect')
|
||||
is_approved = fields.Function(fields.Boolean('Is Approved'), 'get_is_approved')
|
||||
is_prospect = fields.Function(fields.Boolean('Is Prospect'),
|
||||
'get_is_prospect')
|
||||
is_approved = fields.Function(fields.Boolean('Is Approved'),
|
||||
'get_is_approved')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -1158,3 +1134,12 @@ class SaleOpportunityEmployeeMonthly(
|
|||
query.group_by = (year_column, month.id,
|
||||
opportunity.employee, opportunity.company)
|
||||
return query
|
||||
|
||||
|
||||
class OpportunitySaleConditions(ModelSQL, ModelView):
|
||||
"Opportunity Sale Contitions"
|
||||
__name__ = 'crm.opportunity-sale.condition'
|
||||
opportunity = fields.Many2One('crm.opportunity', 'opportunity',
|
||||
ondelete='CASCADE')
|
||||
condition = fields.Many2One('sale.condition', 'Condition',
|
||||
ondelete='RESTRICT')
|
||||
|
|
2
sale.py
2
sale.py
|
@ -42,7 +42,7 @@ class Sale(metaclass=PoolMeta):
|
|||
raise AccessError(gettext(
|
||||
'sale_opportunity'
|
||||
'.msg_modify_origin_opportunity',
|
||||
sale=crm.rec_name))
|
||||
sale=sale.origin.rec_name))
|
||||
super().write(*args)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -5,6 +5,7 @@ depends:
|
|||
sale
|
||||
commission
|
||||
dash
|
||||
sale_co
|
||||
xml:
|
||||
crm.xml
|
||||
configuration.xml
|
||||
|
|
|
@ -6,6 +6,8 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="party_contact"/>
|
||||
<label name="contact_phone"/>
|
||||
<field name="contact_phone"/>
|
||||
<label name="party_category"/>
|
||||
<field name="party_category" widget="selection"/>
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="contact"/>
|
||||
|
@ -20,8 +22,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="type"/>
|
||||
<label name="lead_origin"/>
|
||||
<field name="lead_origin" widget="selection"/>
|
||||
<label name="reference"/>
|
||||
<field name="reference"/>
|
||||
<label name="amount"/>
|
||||
<field name="amount" symbol="currency"/>
|
||||
<label name="conversion_probability"/>
|
||||
|
@ -51,13 +51,15 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<page name="lines">
|
||||
<field name="lines"/>
|
||||
</page>
|
||||
<!-- <page string="Contracts" name="contracts">
|
||||
<field name="contracts" colspan="4"/>
|
||||
</page> -->
|
||||
<page name="sales">
|
||||
<field name="sales" colspan="4"/>
|
||||
</page>
|
||||
|
||||
<!-- <page string="Contracts" name="contracts">
|
||||
<field name="contracts" colspan="4"/>
|
||||
</page> -->
|
||||
<page string="Conditions" name="conditions">
|
||||
<field name="conditions"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
|
|
Loading…
Reference in New Issue