hello everybody, i have this situation: a model A with a Many2One
field to a model B and a DateTime field whose default value shuld be
based on a model B datetime value. Here is a simplified code of the
situation:
................................................................................................
class Lesson(ModelSQL, ModelView):
.....
StartDateTime = fields.DateTime(string='Start')
Activities = fields.One2Many('train.Activity', 'Lesson',
string='Activities')
......
class Activity(ModelSQL, ModelView):
......
Lesson = fields.Many2One('train.Lesson', string='Lesson')
StartDateTime = fields.DateTime(string='Start Date Time',
depends=['Lesson'])
def default_StartDateTime(self):
#lesson_obj = Pool().get('train.Lesson')
lesson = Transaction().context.get('Lesson')
return ''
................................................................................................
The logic is that the activity is created starting from the One2Many
Activities field of the Lesson form and that the activity start time
proposed into the form is the Lesson one (that should be te norm,
unless a student comes late to the lesson)
I understand that i must use the default_StartDateTime function to set
the default value but:
- getting the Lesson object through the Pool seems to return only the
Lesson model definition and not the current value of the Lesson record
I started from (or at least I'm not able to get those values)
- the Transaction().context object is only filled with the locale,
timezone, etc data and nothing about the current records
- I couldnt figure out how into the default_StartDateTims function to
get any ids of the current records starting from 'self'
thanks in advance
leo venturini
--
[email protected] mailing list