[IMP]GOLEM Member : better regexp for area street auto completion

This commit is contained in:
Fabien BOURGEOIS 2019-01-21 05:46:46 +01:00
parent fc943bf71e
commit 5318431970
2 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2018 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2016-2019 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2018 Michel Dessenne <michel@yaltik.com>
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
@ -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',

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2016-2018 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2016-2019 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
#
# 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
)