Odoo Help

0

Choose sequence to use in production Lot

By
Leopo
on 2/12/13, 5:45 PM 1,746 views

Hi,

How I can write some code to choose the sequence number in the production lot, because we need use different sequence depends of the products category. Using openERP v6.0.4.

in the stock module, the default code use: 'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'stock.lot.serial'), using the sequence: stock.lot.serial but how we can use a variable here to select the name of sequence to use. I tried some options using fields.selection and functions but doesn't work. Thanks.

When you say you tried some options, did you try (not sure if syntax is correct here): "'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, x.browse(y, z, [x.id]).sequence_to_use_field)" where 'sequence_to_use_field' is the fields.selection?

Geoff Galik
on 2/20/13, 6:02 AM
0
Leopo
On 3/11/13, 11:54 AM

Thanks,

After try some codes, I finally solved it using a select field: .xml

    'sequence_lot': fields.selection([("seq1",'Product 1'),("seq2",'Product 2'),("seq3",'Product 4'),("seq4",'Product '),("seq5",'Bases')],'Secuencia a usar '),

<field name="sequence_lot" on_change="onchange_sequence_lot(sequence_lot)"/>

.py Function onChange, using the id of sequence choosen, is posible use the name too.

def onchange_sequence_lot(self, cr, uid, ids, sequence_lot, context=None):
    result = {}
    if sequence_lot == "seq1":
        seq_choosen = self.pool.get('ir.sequence').get_id(cr, uid, 103, context={} ) #Using id of seq.
        result['value'] = {'name': seq_choosen,}    
        #raise osv.except_osv(_('Warning!'), _('Seq Conteo %s.'%str(seq_choosen)))
    elif sequence_lot == "seq2":
        seq_choosen = self.pool.get('ir.sequence').get_id(cr, uid, 30, context={} )
        result['value'] = {'name': seq_choosen,}
    elif sequence_lot == "seq3":
        seq_choosen = self.pool.get('ir.sequence').get_id(cr, uid, 27, context={} )
        result['value'] = {'name': seq_choosen,}
    elif sequence_lot == "seq4":
        seq_choosen = self.pool.get('ir.sequence').get_id(cr, uid, 39, context={} )
        result['value'] = {'name': seq_choosen,}
    elif sequence_lot == "seq5":
        seq_choosen = self.pool.get('ir.sequence').get_id(cr, uid, 39, context={} )
        result['value'] = {'name': seq_choosen,}
    else:
        seq_choosen = {}
        result['value'] = {'name': seq_choosen,}
    return result

You should mark your answer as correct.

Versão Integral, Anabela Damas
on 11/7/13, 9:37 AM
0

Fabrice Henrion (fhe)

--Fabrice Henrion (fhe)--
6108
| 7 7 9
San Francisco, United States
--Fabrice Henrion (fhe)--

Director Odoo USA

Fabrice Henrion (fhe)
On 3/11/13, 6:50 AM

To modify your sequences, go to Settings > Technical > Sequences and Identifiers.

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 2/12/13, 5:45 PM
Seen: 1746 times
Last updated: 3/16/15, 8:10 AM