Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Openerpv7: Numbering in Purchase Requisition OrderLine? But python code is not working properly.

By
rosey
on 10/31/14, 8:31 AM 454 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/31/14, 8:31 AM
Seen: 454 times
Last updated: 3/16/15, 8:10 AM