diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-07-27 13:41:57 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-07-27 16:00:07 +0000 |
| commit | 5670a102acde112115dbdc7a98b2aa39a89b6970 (patch) | |
| tree | 0085a2876838557e3e468ad3cbfb3ec58e6db01d /addons | |
| parent | 054894c35c2d958d72351696d7f233d09fee1c36 (diff) | |
[FIX] repair: sequence at creation
- Create a repair order
- Cancel the creation
- Create another repair order
There is a gap in the sequence number.
The gap is due to the fact that the sequence number is consumed by the
`default_get`.
Although this is a change of behavior, the actual one is not really
expected. Even if a gap is possible with the sequence, we don't want to
consume a number every time we get the default values.
opw-2301412
closes odoo/odoo#55005
X-original-commit: 9d7d618220e27024321a75be0058db2289115af2
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/repair/models/repair.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 6a28defd8d2..20c5a003d31 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -22,7 +22,7 @@ class Repair(models.Model): name = fields.Char( 'Repair Reference', - default=lambda self: self.env['ir.sequence'].next_by_code('repair.order'), + default='/', copy=False, required=True, states={'confirmed': [('readonly', True)]}) product_id = fields.Many2one( @@ -203,6 +203,12 @@ class Repair(models.Model): raise UserError(_('You can not delete a repair order which is linked to an invoice which has been posted once.')) return super().unlink() + @api.model + def create(self, vals): + if vals.get('name', '/') == '/': + vals['name'] = self.env['ir.sequence'].next_by_code('repair.order') or '/' + return super(Repair, self).create(vals) + def button_dummy(self): # TDE FIXME: this button is very interesting return True |
