mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
ir.sequence : Replace deprecated get() by next_by_code()
Avoid double increment of sequence when creating an SDD mandate.
This commit is contained in:
@@ -191,8 +191,7 @@ class sdd_mandate(orm.Model):
|
||||
'company_id': lambda self, cr, uid, context:
|
||||
self.pool['res.company']._company_default_get(
|
||||
cr, uid, 'sdd.mandate', context=context),
|
||||
'unique_mandate_reference': lambda self, cr, uid, ctx:
|
||||
self.pool['ir.sequence'].get(cr, uid, 'sdd.mandate.reference'),
|
||||
'unique_mandate_reference': '/',
|
||||
'state': 'draft',
|
||||
'sepa_migrated': True,
|
||||
}
|
||||
@@ -203,6 +202,13 @@ class sdd_mandate(orm.Model):
|
||||
'A Mandate with the same reference already exists for this company !'
|
||||
)]
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if vals.get('unique_mandate_reference', '/') == '/':
|
||||
vals['unique_mandate_reference'] = \
|
||||
self.pool['ir.sequence'].next_by_code(
|
||||
cr, uid, 'sdd.mandate.reference', context=context)
|
||||
return super(sdd_mandate, self).create(cr, uid, vals, context=context)
|
||||
|
||||
def _check_sdd_mandate(self, cr, uid, ids):
|
||||
for mandate in self.browse(cr, uid, ids):
|
||||
if (mandate.signature_date and
|
||||
|
||||
Reference in New Issue
Block a user