|
@ -38,6 +38,21 @@ class ResPartner(models.Model): |
|
|
required=False, |
|
|
required=False, |
|
|
store=True) |
|
|
store=True) |
|
|
|
|
|
|
|
|
|
|
|
@api.model |
|
|
|
|
|
def create(self, vals): |
|
|
|
|
|
"""Add inverted names at creation if unavailable.""" |
|
|
|
|
|
if "name" in vals: |
|
|
|
|
|
inverted = self._get_inverse_name( |
|
|
|
|
|
vals.get("name"), |
|
|
|
|
|
vals.get("is_company", |
|
|
|
|
|
self.default_get(["is_company"])["is_company"])) |
|
|
|
|
|
|
|
|
|
|
|
for key, value in inverted.iteritems(): |
|
|
|
|
|
if not vals.get(key): |
|
|
|
|
|
vals[key] = value |
|
|
|
|
|
|
|
|
|
|
|
return super(ResPartner, self).create(vals) |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
|
def default_get(self, fields_list): |
|
|
def default_get(self, fields_list): |
|
|
"""Invert name when getting default values.""" |
|
|
"""Invert name when getting default values.""" |
|
|