2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
from flectra import fields, models, api
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ResCompany(models.Model):
|
|
|
|
_inherit = 'res.company'
|
|
|
|
|
|
|
|
l10n_fr_closing_sequence_id = fields.Many2one('ir.sequence', 'Sequence to use to build sale closings', readonly=True)
|
|
|
|
|
|
|
|
@api.model
|
|
|
|
def create(self, vals):
|
|
|
|
company = super(ResCompany, self).create(vals)
|
|
|
|
#when creating a new french company, create the securisation sequence as well
|
|
|
|
if company._is_accounting_unalterable():
|
|
|
|
sequence_fields = ['l10n_fr_closing_sequence_id']
|
|
|
|
company._create_secure_sequence(sequence_fields)
|
|
|
|
return company
|
|
|
|
|
|
|
|
@api.multi
|
|
|
|
def write(self, vals):
|
|
|
|
res = super(ResCompany, self).write(vals)
|
|
|
|
#if country changed to fr, create the securisation sequence
|
|
|
|
for company in self:
|
|
|
|
if company._is_accounting_unalterable():
|
|
|
|
sequence_fields = ['l10n_fr_closing_sequence_id']
|
|
|
|
company._create_secure_sequence(sequence_fields)
|
|
|
|
return res
|