Make Opportunity employee not required
issue6135 review29871002
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Make Opportunity employee not required on leads
|
||||
|
||||
Version 4.2.0 - 2016-11-28
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Change probability into conversion probability
|
||||
|
||||
+13
-6
@@ -5,7 +5,7 @@ import datetime
|
||||
|
||||
from sql import Literal, Null
|
||||
from sql.aggregate import Max, Count, Sum
|
||||
from sql.conditionals import Case
|
||||
from sql.conditionals import Case, Coalesce
|
||||
from sql.functions import Extract
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields, \
|
||||
@@ -71,9 +71,13 @@ class SaleOpportunity(Workflow, ModelSQL, ModelView):
|
||||
['converted', 'lost', 'cancelled']),
|
||||
},
|
||||
depends=['state'])
|
||||
employee = fields.Many2One('company.employee', 'Employee', required=True,
|
||||
states=_STATES_STOP, depends=['state', 'company'],
|
||||
domain=[('company', '=', Eval('company'))])
|
||||
employee = fields.Many2One('company.employee', 'Employee',
|
||||
states={
|
||||
'readonly': _STATES_STOP['readonly'],
|
||||
'required': ~Eval('state').in_(['lead', 'lost', 'cancelled']),
|
||||
},
|
||||
depends=['state', 'company'],
|
||||
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,
|
||||
@@ -152,6 +156,9 @@ class SaleOpportunity(Workflow, ModelSQL, ModelView):
|
||||
table.drop_constraint('check_percentage')
|
||||
table.drop_column('probability')
|
||||
|
||||
# Migration from 4.2: make employee not required
|
||||
table.not_null_action('employee', action='remove')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(SaleOpportunity, cls).__setup__()
|
||||
@@ -609,7 +616,7 @@ class SaleOpportunityEmployee(SaleOpportunityReportMixin, ModelSQL, ModelView):
|
||||
query = super(SaleOpportunityEmployee, cls).table_query()
|
||||
opportunity, = query.from_
|
||||
query.columns += (
|
||||
opportunity.employee.as_('id'),
|
||||
Coalesce(opportunity.employee, 0).as_('id'),
|
||||
opportunity.employee,
|
||||
)
|
||||
where = Literal(True)
|
||||
@@ -694,7 +701,7 @@ class SaleOpportunityEmployeeMonthly(
|
||||
query.columns += (
|
||||
Max(Extract('MONTH', opportunity.start_date)
|
||||
+ Extract('YEAR', opportunity.start_date) * 100
|
||||
+ opportunity.employee * 1000000
|
||||
+ Coalesce(opportunity.employee, 0) * 1000000
|
||||
).cast(type_id).as_('id'),
|
||||
year_column,
|
||||
month_column,
|
||||
|
||||
@@ -98,7 +98,6 @@ Create an lead::
|
||||
>>> config.user = sale_opportunity_user.id
|
||||
>>> Opportunity = Model.get('sale.opportunity')
|
||||
>>> opportunity = Opportunity()
|
||||
>>> opportunity.employee = employee
|
||||
>>> opportunity.description = 'Opportunity'
|
||||
>>> opportunity.save()
|
||||
>>> opportunity.state
|
||||
@@ -110,6 +109,7 @@ Convert to opportunity::
|
||||
>>> opportunity.address, = customer.addresses
|
||||
>>> opportunity.payment_term = payment_term
|
||||
>>> opportunity.amount = Decimal(100)
|
||||
>>> opportunity.employee = employee
|
||||
>>> opportunity.click('opportunity')
|
||||
>>> opportunity.state
|
||||
u'opportunity'
|
||||
|
||||
Reference in New Issue
Block a user