[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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user