[FIX] mrp: always use sequence on 'unbuild' creation

The mrp.unbuild model creates a name based on a sequence if no name is
given in the value dictionary.  This was fine before the new views,
because the field name (in the form view) was marked readonly, so the
value 'New' was not actually sent to the server.

However, this was changed with the new views: readonly fields are always
sent on create/write operations, if they have been modified.  This is a
problem for the mrp.unbuild model, because this means that each new
record as effectively the same name: 'New'.

So, we simply always use the sequence-based names in the create
operation, when the name is 'New', instead of the value given as parameter.
This commit is contained in:
Géry Debongnie
2017-05-22 11:29:35 +02:00
parent 8b94bf8b28
commit ed603399f9
+2 -3
View File
@@ -77,10 +77,9 @@ class MrpUnbuild(models.Model):
@api.model
def create(self, vals):
if not vals.get('name'):
if vals['name'] == _('New'):
vals['name'] = self.env['ir.sequence'].next_by_code('mrp.unbuild') or _('New')
unbuild = super(MrpUnbuild, self).create(vals)
return unbuild
return super(MrpUnbuild, self).create(vals)
@api.multi
def action_unbuild(self):