From fc943bf71e9ac5c6af12d13e993ef1ddc209715a Mon Sep 17 00:00:00 2001 From: youssef Date: Sat, 17 Nov 2018 22:24:39 +0100 Subject: [PATCH 1/2] Remove number from street before saving it or extracting it from Territories --- golem_member/models/golem_member.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/golem_member/models/golem_member.py b/golem_member/models/golem_member.py index b706530..87d2253 100644 --- a/golem_member/models/golem_member.py +++ b/golem_member/models/golem_member.py @@ -19,6 +19,7 @@ """ GOLEM Members """ import logging +import re from datetime import date, timedelta from dateutil.relativedelta import relativedelta from odoo import models, fields, api, _ @@ -161,6 +162,8 @@ class ResPartner(models.Model): for member in self: if member.street and not member.area_from_street: mstreet = member.street.strip() + p = re.compile(r'^\d+') + mstreet = p.sub('', mstreet).strip() street_id = self.env['golem.partner.area.street'].search( [('name', 'ilike', mstreet)] ) @@ -274,6 +277,8 @@ class GolemMember(models.Model): for member in self: mstreet = member.street.strip() if member.street else False if mstreet and not member.area_id: + p = re.compile(r'^\d+') + mstreet = p.sub('', mstreet).strip() street_id = self.env['golem.partner.area.street'].search( [('name', 'ilike', mstreet)], limit=1 ) From 531843197025ec18da3b4312bc69d19a0a509aba Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Mon, 21 Jan 2019 05:46:46 +0100 Subject: [PATCH 2/2] [IMP]GOLEM Member : better regexp for area street auto completion --- golem_member/__manifest__.py | 4 ++-- golem_member/models/golem_member.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/golem_member/__manifest__.py b/golem_member/__manifest__.py index e7e366e..c036a48 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 87d2253..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,13 +19,16 @@ """ GOLEM Members """ import logging -import re +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: @@ -162,8 +165,7 @@ class ResPartner(models.Model): for member in self: if member.street and not member.area_from_street: mstreet = member.street.strip() - p = re.compile(r'^\d+') - mstreet = p.sub('', mstreet).strip() + mstreet = street_number.sub(u'', mstreet).strip() street_id = self.env['golem.partner.area.street'].search( [('name', 'ilike', mstreet)] ) @@ -277,8 +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: - p = re.compile(r'^\d+') - mstreet = p.sub('', mstreet).strip() + mstreet = street_number.sub('', mstreet).strip() street_id = self.env['golem.partner.area.street'].search( [('name', 'ilike', mstreet)], limit=1 )