This question has been flagged
2593 Views

class purchase_requisition_line(osv.osv):
      _inherit = 'purchase.requisition.line'
      
      def _default_sequence(self, cr, uid, ids, context=None):
            if not context:
            context = {}
            max_sequence = 0
            print "order_id",context.get('requisition_id')
            if context.get('requisition_id'):
               order_line = self.search(cr, uid, [('requisition_id', '=', context['requisition_id'])])
              if order_line:
                 max_sequence = max([line['serial_no'] for line in self.read(cr, uid, order_line, ['serial_no'])])
            return max_sequence + 1

      _columns={
            'serial_no':fields.integer('Serial No'),
      }

      _defaults = {
             'serial_no': _default_sequence
      }
purchase_requisition_line()

 

But i doesnt get the context.get('requisition_id') value. so function always return value 1.

http://stackoverflow.com/questions/21495783/openerpv7-numbeing-in-orderline

I refer the above link. In that link, it also contains another code. But no output. I changed field name corresponding purchase_requisition_line.

Did i want to again add below field line_ids again in my custom module?

 

<field name="line_ids" on_change="onchange_line(order_line)">

def onchange_line(self, cr, uid, ids, lines,context=None): result = {} result['value'] = {} #do the proper checking count_dict = {} count = 10 had_seq = 0 for index,line in enumerate(lines): if line[0] == 0: count_dict[index] = count count +=10 else: had_seq +=1 #seqnece_no is the new sequence field defined for k in count_dict: if had_seq: lines[k][2]['sequence_no'] = had_seq*10 + count_dict[k] else: lines[k][2]['sequence_no'] = count_dict[k] result['value'].update({'order_line':lines}) return result

Avatar
Discard