set opportunity's party as default party value
This commit is contained in:
parent
c03757df13
commit
3c10daaf5b
|
@ -7,5 +7,6 @@ from .activity import *
|
|||
|
||||
def register():
|
||||
Pool.register(
|
||||
Activity,
|
||||
SaleOpportunity,
|
||||
module='sale_opportunity_activity', type_='model')
|
||||
|
|
19
activity.py
19
activity.py
|
@ -2,16 +2,20 @@
|
|||
# copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__metaclass__ = PoolMeta
|
||||
__all__ = ['SaleOpportunity']
|
||||
__all__ = ['Activity', 'SaleOpportunity']
|
||||
|
||||
|
||||
class SaleOpportunity:
|
||||
__name__ = 'sale.opportunity'
|
||||
|
||||
activities = fields.One2Many('activity.activity', 'resource',
|
||||
'Activities')
|
||||
'Activities', context={
|
||||
'opportunity_party': Eval('party'),
|
||||
}, depends=['party'])
|
||||
last_action_date = fields.Function(fields.DateTime('Last Action'),
|
||||
'get_last_action_date')
|
||||
|
||||
|
@ -24,3 +28,14 @@ class SaleOpportunity:
|
|||
],
|
||||
order=[('dtstart', 'desc')], limit=1)
|
||||
return act and act[0].dtstart or None
|
||||
|
||||
|
||||
class Activity:
|
||||
__name__ = 'activity.activity'
|
||||
|
||||
@classmethod
|
||||
def default_party(cls):
|
||||
opportunity_party_id = Transaction().context.get('opportunity_party')
|
||||
if opportunity_party_id:
|
||||
return opportunity_party_id
|
||||
return super(Activity, cls).default_party()
|
||||
|
|
Loading…
Reference in New Issue