From ed603399f9e03c98c488d53ff2ea50399e651aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 19 May 2017 20:58:16 +0200 Subject: [PATCH] [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. --- addons/mrp/models/mrp_unbuild.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_unbuild.py b/addons/mrp/models/mrp_unbuild.py index 31cd5226346..75d56a0c958 100644 --- a/addons/mrp/models/mrp_unbuild.py +++ b/addons/mrp/models/mrp_unbuild.py @@ -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):