diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-09-27 17:13:44 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-09-27 17:18:20 +0200 | 
| commit | 69b20d50aed1e20cb3a76652fac671efea4e3991 (patch) | |
| tree | 6036ccfb226f94417ebc292c7d6cfe445cf4fdd4 /ishtar_common/models_common.py | |
| parent | ccac2c5da06d2cf6cc0c7c9aee56cbb4cda9a319 (diff) | |
| download | Ishtar-69b20d50aed1e20cb3a76652fac671efea4e3991.tar.bz2 Ishtar-69b20d50aed1e20cb3a76652fac671efea4e3991.zip  | |
Merge page - add more fields on table (refs #5447)
Diffstat (limited to 'ishtar_common/models_common.py')
| -rw-r--r-- | ishtar_common/models_common.py | 55 | 
1 files changed, 34 insertions, 21 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index e164677ba..22244e4e2 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2248,38 +2248,51 @@ class Address(BaseHistorizedItem):          lbl += self.address_lbl()          return lbl -    def address_lbl(self): -        lbl = "" +    def address_lbl(self, list=False): +        lbls = []          prefix = ""          if self.alt_address_is_prefered:              prefix = "alt_"          if getattr(self, prefix + "address"): -            lbl += getattr(self, prefix + "address") +            lbls.append(( +                getattr(self, prefix + "address"), +                _("Address") +            ))          if getattr(self, prefix + "address_complement"): -            if lbl: -                lbl += "\n" -            lbl += getattr(self, prefix + "address_complement") +            lbls.append(( +                getattr(self, prefix + "address_complement"), +                _("Address complement") +            ))          postal_code = getattr(self, prefix + "postal_code")          town = getattr(self, prefix + "town")          if postal_code or town: -            if lbl: -                lbl += "\n" -            lbl += "{}{}{}".format( -                postal_code or "", " " if postal_code and town else "", town or "" -            ) +            lbls.append(( +                " ".join([postal_code, town]), +                _("Postal code - Town") +            ))          if self.phone: -            if lbl: -                lbl += "\n" -            lbl += "{} {}".format(str(_("Tel: ")), self.phone) +            lbls.append(( +                self.phone, +                _("Phone") +            ))          if self.mobile_phone: -            if lbl: -                lbl += "\n" -            lbl += "{} {}".format(str(_("Mobile: ")), self.mobile_phone) +            lbls.append(( +                self.mobile_phone, +                _("Mobile") +            ))          if self.email: -            if lbl: -                lbl += "\n" -            lbl += "{} {}".format(str(_("Email: ")), self.email) -        return lbl +            lbls.append(( +                self.email, +                _("Email") +            )) +        if list: +            return lbls +        return "\n".join([ +            value for value, lbl in lbls +        ]) + +    def address_lbl_list(self): +        return self.address_lbl(list=True)  class Merge(models.Model):  | 
