Skip to content

Instantly share code, notes, and snippets.

@ianjosephwilson
Last active December 12, 2015 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianjosephwilson/4710012 to your computer and use it in GitHub Desktop.
Save ianjosephwilson/4710012 to your computer and use it in GitHub Desktop.
Reload wizard start data.
# Updated, try to use the existing state if possible otherwise use the model defaults.
def default_start(self, fields):
LookupConfig = Pool().get('product_lookup.lookup.config')
if self.start.forecast_date:
defaults['forecast_date'] = self.start.forecast_date
else:
defaults['forecast_date'] = LookupConfig.default_forecast_date()
return defaults
Traceback (most recent call last):
File "/trytond/protocols/jsonrpc.py", line 123, in _marshaled_dispatch
response['result'] = dispatch_method(method, params)
File "/trytond/protocols/jsonrpc.py", line 156, in _dispatch
res = dispatch(*args)
File "/trytond/protocols/dispatcher.py", line 154, in dispatch
result = rpc.result(meth(*args, **kwargs))
File "/trytond/wizard/wizard.py", line 259, in execute
return wizard._execute(state_name)
File "/trytond/wizard/wizard.py", line 271, in _execute
view['fields'].keys())
File "/trytond/wizard/wizard.py", line 87, in get_defaults
defaults.update(default(fields))
File "/trytond/modules/product_lookup_stock/lookup.py", line 65, in default_start
if self.start.forecast_date:
File "/trytond/model/model.py", line 629, in __getattr__
% (self.__name__, name, self._values))
AttributeError: 'product_lookup.lookup.config' Model has no attribute 'forecast_date': None
# Extends the original ModelView defined in another module.
class LookupConfig:
__name__ = 'product_lookup.lookup.config'
forecast_date = fields.Date(
'At Date', help='Compute the expected '\
'stock quantities for this date.\n'\
'* An empty value is an infinite date in the future.\n'\
'* A date in the past will provide historical values.')
@staticmethod
def default_forecast_date():
Date = Pool().get('ir.date')
return Date.today()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment