I having one field, I set that auto generation field. There are 5 more branches in that company if one branch user is open and create the that number is QWE001 at the same time another branch user open and create the form that number is ASD001, other branch ZXC001 like this how to do in OpenERP is it possible to do. This is my code how to do it.
class abc_product(osv.osv):
_name = 'abc.product'
_columns = {
'branch_id':fields.many2one('branch', 'Branch', required=True,),
'sample_s_no':fields.char('Sample S.No', size=12, readonly=True, states={'draft': [('readonly', False)], 'waiting_approve': [('readonly', False)]}),
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
context['force_branch'] = vals['branch_id']
print context['force_branch'],"ddddddddddddddddddddd"
if vals.get('sample_s_no', '/') == False:
vals['sample_s_no'] = self.pool.get('ir.sequence').next_by_code(
cr, uid, 'abc.product', context=context) or '/'
return super(abc_product, self).create(cr, uid, vals, context=context)
and the XML is <record id="seq_type_abc_product" model="ir.sequence.type"> <field name="name">ABC Product</field> <field name="code">abc.product</field> </record>
<record id="seq_abc_product" model="ir.sequence">
<field name="name">Abc Product</field>
<field name="code">abc.product</field>
<field name="prefix">KKR</field>
<field name="padding">4</field>
<field name="suffix">-%(year)s</field>
<field name="branch_id" eval="1"/>
</record>
<record id="seq_abc_products" model="ir.sequence">
<field name="name">ABC Product</field>
<field name="code">abc.product</field>
<field name="prefix">AMN</field>
<field name="padding">4</field>
<field name="suffix">-%(year)s</field>
<field name="branch_id" eval="2"/>
</record>
How to solve this.
@Sridhar. Did you solve the issue? Please help me too.
No, I dont complete this, I put Nehal's function in my code this code is calling, thats why i put pending this task, if you complete help me.