I have this situation w/c i don't know what to do about it. The case is this: In class sale_order I have this definition:
...
'sched_lines' : fields.one2many('schedule.schedule','Schedule'),
'factor_lines' : fields.one2many('sale.order.factor','Factor'),
So does, in class account_invoice i also have this definition:
...
'sched_lines' : fields.one2many('schedule.schedule','Schedule'),
'factor_lines' : fields.one2many('sale.order.factor','Factor'),
Back to class sale_order i override the method manual_invoice ,
...
for sale_order in self.browse(cr,uid,ids,context=context):
_logger.info("\n\t\t\tFACTOR LINES IN SALE ORDER ... %s"%(str(sale_order.factor_lines)))
_logger.info("\n\t\t\tHISTORY IN SALE ORDER ... %s"%(str(sale_order.sched_lines)))
inv_id = self.pool.get('account.invoice').search(cr,uid,[('id','in',[new_inv_ids]),('origin','=',sale_order.name)])
factor_list = self.pool.get('sale.order.factor').search(cr,uid,[('invoice_id','=',inv_id[0])])
_logger.info("\n\t\t\tfactor_list...%s"%(str(factor_list)))
factor_lines1 = [factors.id for factors in self.pool.get('sale.order.factor').browse(cr,uid,factor_list,context=context)]
_logger.info("\n\t\t\tfactor_lines1...%s"%(str(factor_lines1)))
# cr.execute('select id from sale_order_factor where invoice_id = %s', (tuple(inv_id)))
#---------------- factor_lines1 = map(lambda x: x[0], cr.fetchall())
# factor_lines1 = [(1,0,[factors.id for factors in sale_order.factor_lines])]
#--- _logger.info("\n\t\t\tfactor_lines1...%s"%(str(factor_lines1)))
self.pool.get('account.invoice').write(cr,uid,inv_id,{
'sched_lines': [(6,0,[sched.id for sched in sale_order.sched_lines])],
'factor_lines': [(6,0,[factor.id for factor in sale_order.factor_lines])],#factor_lines1
}
what i can't understand is that this statement "[(6,0,[factor.id for factor in sale_order.factor_lines])]" does not work. When i view the invoice it has not populated. It's source, that is the factor_lines in sale_order, is not empty. While this statement "[(6,0,[sched.id for sched in sale_order.sched_lines])]" works fine. What's inside in sched_lines from sale_order is being carried fine. Does anyone can point out what's the missing, if there is any, in my code? I am really stuck in this.
Any help is very much appreciated.