I need the file & dcb fields to follow different sequecing ,
for example-
the field 'file' need to follow sequencing like F0001, F0002.....(or like F2500, F2501,...)
and the field 'dcb' neet to follow sequencing like D0001, D0002,....(or like D5600, D5601,...)
to achieve this,
i wrote the code in my py file given below,..
class easy_filedcb(osv.Model):
_name="easy.filedcb"
_columns={
'file': fields.char('File', size=64,readonly=True),
'dcb':fields.char('DCB', size=64,readonly=True),
}
def create(self, cr, uid, vals, context=None):
if vals.get('file','/')=='/':
vals['file'] = self.pool.get('ir.sequence').get(cr, uid, 'easy.filedcb') or '/'
return super(easy_filedcb, self).create(cr, uid, vals, context=context)
def create(self, cr, uid, vals, context=None):
if vals.get('dcb','/')=='/':
vals['dcb'] = self.pool.get('ir.sequence').get(cr, uid, 'easy.filedcb') or '/'
return super(easy_filedcb, self).create(cr, uid, vals, context=context)
_defaults = {
'dcb': lambda obj, cr, uid, context: '/',
'file': lambda obj, cr, uid, context: '/',
}
easy_filedcb()
and i created an xml file filedcb_sequence.xml and updated this in openerp.py file
the code is given below,
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="seq_easy_filedcb_type" model="ir.sequence.type">
<field name="name">dcb</field>
<field name="code">easy.filedcb</field>
</record>
<record id="seq_dcbnumber" model="ir.sequence">
<field name="name">dcb</field>
<field name="code">easy.filedcb</field>
<field name="prefix">D</field>
<field name="padding">4</field>
</record>
<record id="seq_easy_filedcb_type" model="ir.sequence.type">
<field name="name">file</field>
<field name="code">easy.filedcb</field>
</record>
<record id="seq_filenumber" model="ir.sequence">
<field name="name">file</field>
<field name="code">easy.filedcb</field>
<field name="prefix">F</field>
<field name="padding">4</field>
</record>
</data>
</openerp>
the result i got is not acceptable.
the field 'file' sequencing like D0001, D0002,.....
and the field 'dcb' sequencing like / , / , .....(ie, only front slash)
when i inter changed the position of 'def create' function for 'file' & 'dcb' in the class,
the field 'dcb' sequencing like D0001, D0002,.....
and the field 'file' sequencing like / , / , .....(ie, only front slash)
how can i solve this problem...?
(i achieved the result for single field with the code of same pattern, but when two field came the problem also came)
i need help.