From fc943bf71e9ac5c6af12d13e993ef1ddc209715a Mon Sep 17 00:00:00 2001 From: youssef Date: Sat, 17 Nov 2018 22:24:39 +0100 Subject: [PATCH] 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 )