2017-08-10 5 views
0

Ich versuche, auf einen Wert zuzugreifen, der im verschachtelten Wörterbuch enthalten ist und am Ende steht;So rufen Sie Werte im verschachtelten Wörterbuch auf - Python/Openerp

raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf))) 
ValueError: Invalid field 'att_date_date' in leaf "<osv.ExtendedLeaf: ('att_date_date', '<=', '2017-08-01') on on_call_days (ctx:)>" 

Bitte helfen Sie mir, das zu beheben. Meine Klassen und andere notwendige Ausdrücke sind wie Balg;

Klasse on_call_days Felder;

'employee_id': fields.many2one('hr.employee', "Employee"), 
'catagory_id':fields.related('employee_id', 'category', string='Emp Category', relation='hr.employee',store=True), 
'oc_date':fields.date('From Date'), 
'oc_amount':fields.float('Amount for the period'), 
'processed_flag':fields.boolean("Entered flag"), 

Klasse allowance_attendances Felder;

'employee_id': fields.many2one('hr.employee', "Employee"), 
'catagory_id':fields.related('employee_id', 'category', string='Emp Category', relation='hr.employee',store=True),   
'attendance_id':fields.integer("Attendance ID"), 
'att_date':fields.char("Date"), 
'att_date_date':fields.date("Date Date"), 

Klasse allowance_request Felder und das ist die Klasse, die ich diese Ausdrücke zu verwenden versucht.

'allowance_attendances_id':fields.one2many('allowance.attendances','allowance_request_id','Allowance Attendance'), 
    'oc_days_id':fields.one2many('on.call.days','allowance_request_id','On Call Days'), 

Was ich ist

für diese Funktion und es wird Rückkehr val am Ende
def onchange_employee(self, cr, uid, ids, employee_id,start_date,end_date,context=None): 

     DATETIME_FORMAT2 = "%y/%m/%d" 
     allo_att_obj=self.pool.get('allowance.attendances') 
     on_call_obj=self.pool.get('on.call.days') 
     val = {'value': {'allowance_attendances_id': [],'oc_days_id':[]}} 
     if end_date:     

       filt +=[('att_date_date','<=', end_date)]    
      if start_date :    

       filt += [('att_date_date','>=', start_date)] 

Es gibt andere Sachen hier los zu tun versucht.

Das Problem kommt von filt + = [('att_date_date', '< =', end_date)], wo ich aus diesem verschachtelten Wörterbücher Wert abzurufen versucht. Bitte helfen Sie, das zu beheben.

Antwort

1

Hier haben Sie die filt nicht definiert, so wahrscheinlich erhalten Sie die Zurückverfolgungs

Traceback (most recent call last): 
File "<input>", line x, in <module> 
NameError: name 'filt' is not defined 

so änderte ich Code wie:

def onchange_employee(self, cr, uid, ids, employee_id,start_date,end_date,context=None): 

    DATETIME_FORMAT2 = "%y/%m/%d" 
    allo_att_obj=self.pool.get('allowance.attendances') 
    on_call_obj=self.pool.get('on.call.days') 
    val = {'value': {'allowance_attendances_id': [],'oc_days_id':[]}} 
    filt = [] 
    if end_date:     

      filt +=[('att_date_date','<=', end_date)]    
     if start_date :    

      filt += [('att_date_date','>=', start_date)] 

Wenn es muß nicht das Protokoll erhalten Sie mir bitte helfen.

Verwandte Themen