Browse Source

Inverse values of name if required at creation.

14.0
Jairo Llopis 9 years ago
committed by Luis Torres
parent
commit
a6de37e6b6
  1. 15
      partner_firstname/models.py

15
partner_firstname/models.py

@ -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."""

Loading…
Cancel
Save