Dear all, I need your help with a problem I am having on Manufacturing Order Sequence Number The problem is that, everytime I click Create and then Discard the document, the sequence number increases. This is bad, because the Manufacturnig Order was discarded and not Saved. If I click on Create and then Discard several times, the sequence number will increase the number of times clicked.
How can I prevent OpenERP, from doing it and just increase the number when Manufacturing Order is saved?
I have been searching the forum, and found a "closed" post:
help.openerp.com/question/22373/control-on-autogenerated-sequence-number/
Unfortunetly this is not very clear for a newbie like me.
What I have tried to do:
- On my mrp.py file:
Found the line " 'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'mrp.production') or '/', " on my "class mrp_production(osv.osv)". The full _defaults statement is below.
_ defaults = {
'priority': lambda *a: '1',
'state': lambda *a: 'draft',
'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'product_qty': lambda *a: 1.0,
'user_id': lambda self, cr, uid, c: uid,
THE BELOW LINE
'name': lambda x, y, z, c: x.pool.get('ir.sequence').get(y, z, 'mrp.production') or '/',
THE ABOVE LINE
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c),
'location_src_id': _src_id_default,
'location_dest_id': _dest_id_default
}
But the problem is that I do not know how will I override de create() method according to instructions from the post. I do not find a create() method on mrp.py file. The instructions say that I should override this method with the following code:
(where to put this code)
def create(self,cr,uid, vals,context=None):
vals = {}
if context is None:
context = {}
vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'object.object')
return super(object, self).create(cr, uid, vals, context=context)
" Paulo