From 15ae3bda39b84ac18cd04113870964e424940129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pigeon=20=28ACSONE=29?= Date: Mon, 29 May 2017 13:05:15 +0200 Subject: [PATCH] [CHG] re-introduce _get_next_ref method to allow overriding (#417) --- base_partner_sequence/models/partner.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/base_partner_sequence/models/partner.py b/base_partner_sequence/models/partner.py index 7924c2120..9ddb630ca 100644 --- a/base_partner_sequence/models/partner.py +++ b/base_partner_sequence/models/partner.py @@ -30,18 +30,21 @@ class ResPartner(models.Model): _inherit = 'res.partner' + @api.multi + def _get_next_ref(self, vals=None): + return self.env['ir.sequence'].next_by_code('res.partner') + @api.model def create(self, vals): if not vals.get('ref') and self._needsRef(vals=vals): - vals['ref'] = self.env['ir.sequence'].next_by_code('res.partner') + vals['ref'] = self._get_next_ref(vals=vals) return super(ResPartner, self).create(vals) @api.multi def copy(self, default=None): default = default or {} if self._needsRef(): - default['ref'] = self.env['ir.sequence'].\ - next_by_code('res.partner') + default['ref'] = self._get_next_ref() return super(ResPartner, self).copy(default) @api.multi @@ -49,8 +52,7 @@ class ResPartner(models.Model): for partner in self: if not vals.get('ref') and partner._needsRef(vals) and \ not partner.ref: - vals['ref'] = self.env['ir.sequence'].\ - next_by_code('res.partner') + vals['ref'] = self._get_next_ref(vals=vals) super(ResPartner, partner).write(vals) return True