Remove number from street before saving it or extracting it from Territories

This commit is contained in:
Youssef Elouahby 2018-11-17 22:24:39 +01:00
parent 3764bb0f9e
commit fc943bf71e

View File

@ -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
)