mirror of
https://gitlab.com/flectra-community/l10n-switzerland-flectra.git
synced 2024-12-23 04:41:45 +00:00
[FIX] Use latest base location
This commit is contained in:
parent
9b0288fb15
commit
845e3fdc4d
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ from flectra.tools import convert_file
|
||||
def import_csv_data(cr, registry):
|
||||
"""Import CSV data as it is faster than xml and because we can't use
|
||||
noupdate anymore with csv"""
|
||||
filenames = ['data/res.better.zip.csv']
|
||||
filenames = ['data/res.city.csv', 'data/res.city.zip.csv']
|
||||
for filename in filenames:
|
||||
convert_file(
|
||||
cr, 'l10n_ch_zip',
|
||||
|
@ -1 +1 @@
|
||||
from . import better_zip
|
||||
from . import city_zip
|
||||
|
@ -1,65 +0,0 @@
|
||||
# Copyright 2011-2017 Camptocamp SA
|
||||
# Copyright 2014 Olivier Jossen (brain-tec AG)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from flectra import models, fields, api
|
||||
from flectra.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResBetterZip(models.Model):
|
||||
""" Inherit res.better.zip class in order to add swiss specific fields
|
||||
|
||||
Fields from the original file downloaded from here:
|
||||
https://match.post.ch/downloadCenter?product=2 -> File "PLZ Plus 1"
|
||||
|
||||
Documentation:
|
||||
http://www.swisspost.ch/post-startseite/post-adress-services-match/post-direct-marketing-datengrundlage/post-match-zip-factsheet.pdf
|
||||
"""
|
||||
|
||||
_inherit = 'res.better.zip'
|
||||
|
||||
active = fields.Boolean(string='Active', default=True)
|
||||
onrp = fields.Char(string='Swiss Post classification no. (ONRP)',
|
||||
size=5, help="Primary Key")
|
||||
zip_type = fields.Char(string='Postcode type', size=2)
|
||||
additional_digit = fields.Char(string='Additional poscode digits', size=2)
|
||||
lang = fields.Char(
|
||||
string='Language code', size=1,
|
||||
help="Language (language majority) within a postcode area. "
|
||||
"1 = German, 2 = French, 3 = Italian, 4 = Romansh. "
|
||||
"For multi-lingual localities, the main language is indicated.",
|
||||
)
|
||||
lang2 = fields.Char(
|
||||
'Alternative language code',
|
||||
size=1,
|
||||
help="Additional language within a postcode.\n"
|
||||
"One alternative language code may appear for each postcode.\n"
|
||||
"1 = German, 2 = French, 3 = Italian, 4 = Romansh.",
|
||||
)
|
||||
sort = fields.Boolean(
|
||||
string='Present in sort file',
|
||||
help="Indicates if the postcode is included in the «sort file»"
|
||||
"(MAT[CH]sort): 0 = not included, 1 = included. "
|
||||
"Delivery information with addresses (only postcode and "
|
||||
"streets) are published in the sort file.",
|
||||
)
|
||||
post_delivery_through = fields.Integer(
|
||||
string='Mail delivery by',
|
||||
help="Indicates the post office (ONRP) that delivers most of the "
|
||||
"letters to the postcode addresses. This information can be "
|
||||
"used for bag addresses too."
|
||||
)
|
||||
communitynumber_bfs = fields.Integer(
|
||||
string='FSO municipality number (BFSNR)',
|
||||
help="Numbering used by the Federal Statistical Office for "
|
||||
"municipalities in Switzerland and the Principality of "
|
||||
"Liechtenstein",
|
||||
)
|
||||
valid_from = fields.Date(string='Valid from')
|
||||
|
||||
@api.constrains('post_delivery_through','communitynumber_bfs')
|
||||
def _check_length(self):
|
||||
for record in self:
|
||||
if record.post_delivery_through > 99999:
|
||||
raise ValidationError("post_delivery_through cannot be greater than 99999")
|
||||
if record.communitynumber_bfs > 99999:
|
||||
raise ValidationError("communitynumber_bfs cannot be greater than 99999")
|
@ -1,8 +1,8 @@
|
||||
# Copyright 2011-2019 Camptocamp SA
|
||||
# Copyright 2014 Olivier Jossen (brain-tec AG)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from flectra import models, fields
|
||||
|
||||
from flectra import api, models, fields, _
|
||||
from flectra.exceptions import ValidationError
|
||||
|
||||
class ResCityZip(models.Model):
|
||||
""" Inherit res.city.zip class in order to add swiss specific fields
|
||||
@ -56,14 +56,12 @@ class ResCityZip(models.Model):
|
||||
)
|
||||
post_delivery_through = fields.Integer(
|
||||
string='Mail delivery by',
|
||||
size=5,
|
||||
help="Indicates the post office (ONRP) that delivers most of the "
|
||||
"letters to the postcode addresses. This information can be "
|
||||
"used for bag addresses too."
|
||||
)
|
||||
communitynumber_bfs = fields.Integer(
|
||||
string='FSO municipality number (BFSNR)',
|
||||
size=5,
|
||||
help="Numbering used by the Federal Statistical Office for "
|
||||
"municipalities in Switzerland and the Principality of "
|
||||
"Liechtenstein",
|
||||
@ -71,3 +69,11 @@ class ResCityZip(models.Model):
|
||||
valid_from = fields.Date(
|
||||
string='Valid from',
|
||||
)
|
||||
|
||||
@api.constrains('post_delivery_through', 'communitynumber_bfs')
|
||||
def _constrains_fields_length_check(self):
|
||||
for record in self:
|
||||
if(len(str(record.post_delivery_through)) > 5):
|
||||
raise ValidationError(_('Mail delivery by only allows 5 characters.'))
|
||||
if(len(str(record.communitynumber_bfs)) > 5):
|
||||
raise ValidationError(_('FSO municipality number (BFSNR) only allows 5 characters.'))
|
Loading…
Reference in New Issue
Block a user