diff --git a/golem_member/__manifest__.py b/golem_member/__manifest__.py index 6a62439..ed28cd1 100644 --- a/golem_member/__manifest__.py +++ b/golem_member/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016-2018 Fabien Bourgeois +# Copyright 2016-2019 Fabien Bourgeois # Copyright 2018 Michel Dessenne # Copyright 2018 Youssef El Ouahby @@ -21,7 +21,7 @@ 'name': 'GOLEM non-profit members', 'summary': 'Extends Odoo contacts for MJC', 'description': 'Extends Odoo contacts for MJC', - 'version': '10.0.2.5.0', + 'version': '10.0.2.5.1', 'category': 'GOLEM', 'author': 'Fabien Bourgeois, Michel Dessenne', 'license': 'AGPL-3', diff --git a/golem_member/models/golem_member.py b/golem_member/models/golem_member.py index b706530..706bec2 100644 --- a/golem_member/models/golem_member.py +++ b/golem_member/models/golem_member.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2016-2018 Fabien Bourgeois +# Copyright 2016-2019 Fabien Bourgeois # Copyright 2018 Youssef El Ouahby # # This program is free software: you can redistribute it and/or modify @@ -19,12 +19,16 @@ """ GOLEM Members """ import logging +from re import compile as rcompile from datetime import date, timedelta from dateutil.relativedelta import relativedelta from odoo import models, fields, api, _ from odoo.exceptions import UserError, ValidationError _LOGGER = logging.getLogger(__name__) + +street_number = rcompile(r'^(\d-?(bis)*(ter)*,?\s*)+') + def get_root_area(area_id): """ Get root area """ if not area_id.parent_id: @@ -161,6 +165,7 @@ class ResPartner(models.Model): for member in self: if member.street and not member.area_from_street: mstreet = member.street.strip() + mstreet = street_number.sub(u'', mstreet).strip() street_id = self.env['golem.partner.area.street'].search( [('name', 'ilike', mstreet)] ) @@ -274,6 +279,7 @@ class GolemMember(models.Model): for member in self: mstreet = member.street.strip() if member.street else False if mstreet and not member.area_id: + mstreet = street_number.sub('', mstreet).strip() street_id = self.env['golem.partner.area.street'].search( [('name', 'ilike', mstreet)], limit=1 )