forked from Yaltik/golem
area autocompletion and street sauvegarde
This commit is contained in:
parent
a9888427ec
commit
51ab81f916
@ -149,6 +149,7 @@ class GolemFamily(models.Model):
|
|||||||
'golem.partner.area', index=True, auto_join=True, string='Area',
|
'golem.partner.area', index=True, auto_join=True, string='Area',
|
||||||
help="Area, quarter... for statistics and activity price."
|
help="Area, quarter... for statistics and activity price."
|
||||||
)
|
)
|
||||||
|
area_from_street = fields.Boolean(store=False, default=False)
|
||||||
|
|
||||||
@api.depends('member_ids')
|
@api.depends('member_ids')
|
||||||
def _compute_count(self):
|
def _compute_count(self):
|
||||||
@ -166,6 +167,33 @@ class GolemFamily(models.Model):
|
|||||||
'zip': family.member_ids[0].zip,
|
'zip': family.member_ids[0].zip,
|
||||||
'city': family.member_ids[0].city})
|
'city': family.member_ids[0].city})
|
||||||
|
|
||||||
|
@api.onchange('street')
|
||||||
|
def onchange_street(self):
|
||||||
|
""" Area auto assignement """
|
||||||
|
for family in self:
|
||||||
|
mstreet = family.street.strip() if family.street else False
|
||||||
|
if mstreet and not family.area_id:
|
||||||
|
street_id = self.env['golem.partner.area.street'].search(
|
||||||
|
[('name', 'ilike', mstreet)], limit=1
|
||||||
|
)
|
||||||
|
if street_id:
|
||||||
|
|
||||||
|
family.area_id = street_id.area_id
|
||||||
|
member.area_from_street = True
|
||||||
|
@api.constrains('street')
|
||||||
|
def save_street(self):
|
||||||
|
""" Save street if no exist """
|
||||||
|
for family in self:
|
||||||
|
if family.street and not family.area_from_street:
|
||||||
|
mstreet = family.street.strip()
|
||||||
|
street_id = self.env['golem.partner.area.street'].search(
|
||||||
|
[('name', 'ilike', mstreet)]
|
||||||
|
)
|
||||||
|
if not street_id:
|
||||||
|
self.env['golem.partner.area.street'].create(
|
||||||
|
{'name': mstreet, 'area_id': family.area_id.id}
|
||||||
|
)
|
||||||
|
|
||||||
class GolemFamilyRole(models.Model):
|
class GolemFamilyRole(models.Model):
|
||||||
""" GOLEM Family Role """
|
""" GOLEM Family Role """
|
||||||
_name = 'golem.family.role'
|
_name = 'golem.family.role'
|
||||||
|
Loading…
Reference in New Issue
Block a user