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

OpenERP7: Sequence Number

By
Silviaa
on 1/27/14, 2:40 AM 1,059 views

How to make a sequence number increment by 10 in Openenerp

For Example: In POLine have added new colum Line NO , When Adding an item Line no value should be set as increment by 10.

PO001
   LineNo   Product    Quantity
   10           Pdt1          10
   20           Pdt2          10
   30           Pdt3          10
PO002
   LineNo   Product    Quantity
   10           Pdt1          10
   20           Pdt2          10

My Code:

'line_no':fields.integer('Line No'),
_defaults = {
    'line_no':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'purchase.order.line'),    
}

sequence.xml

<record id="seq_type_purchase_order_line" model="ir.sequence.type">
     <field name="name">Purchase Order Line</field>
     <field name="code">purchase.order.line</field>
</record>
<record id="seq_purchase_order_line" model="ir.sequence">
     <field name="name">Purchase Order Line</field>
     <field name="code">purchase.order.line</field>            
     <field name="padding">4</field>
     <field name="number_increment">10</field>
 </record>

I got the below error:

Error: [_.sprintf] expecting number but found string

Any advice would be appreciated.

2
jamesbale
On 1/27/14, 5:56 AM

0 down vote

what you have done, it is correct , you have done one single mistake,

you have to define 'line_no' as char type field not as interger

define like this: 'line_no':fields.char('Line No'),

ir.sequence return string and your line_no is integer

what increment next number is return by get method is combile of prefix field,

interpolated_prefix + '%%0%sd' % seq['padding'] % seq['number_next'] + interpolated_suffix

so it is a string type sequence return from get method

Hope this help

2

Atul Kumar jain

--Atul Kumar jain--
914
| 5 3 7
Indore, India
--Atul Kumar jain--

.

Atul Kumar jain
On 4/10/14, 3:54 AM

Hello I think you should have try onchange method this method is perfectly working for me

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

and call the onchange method in purchase order line

1

Nehal

--Nehal--
2090
| 5 2 8
Ahmadabad, India
--Nehal--
Nehal
On 1/27/14, 3:58 AM

Hello,

You can do it by giving number_increment as 10 in your sequence file.

For example: <field name="padding">4</field> <field name="number_increment">10</field>

Created Sequence with number_increment as 10 ,Im getting Error: [_.sprintf] expecting number but found string

Silviaa
on 1/27/14, 4:18 AM

As same as i written please check my updated post

Silviaa
on 1/27/14, 4:30 AM

Error Exist

Silviaa
on 1/27/14, 5:24 AM

@nehal@ updated in post

Silviaa
on 1/27/14, 5:49 AM

Replace your line_no field with 'line_no':fields.char('Line No'),

Nehal
on 1/27/14, 6:07 AM

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

0 follower(s)

Stats

Asked: 1/27/14, 2:40 AM
Seen: 1059 times
Last updated: 3/16/15, 8:10 AM