OCA / server-env

Tools to manage environment-dependent configuration
GNU Affero General Public License v3.0
57 stars 157 forks source link

[Fix] server env tech name unique constraint #104

Closed santostelmo closed 2 years ago

santostelmo commented 2 years ago

Default tech_name field is filled from record name. We have an issue with multi companies. For example, if we tr to set the char of accounts for 2 companies, jornal names and tech_names are populated with the same values in both companies. To avoid that for models defined per company, we change the tech_name unique constraint rule.

santostelmo commented 2 years ago

@simahawk keeping the original code and doing that could be acceptable for you ?

    def _handle_tech_name(self, vals):
        # make sure technical names are always there
        if not vals.get("tech_name") and vals.get("name"):
            name = vals.get("name")
            if self.search_count([('name', '=', name)]) >= 1 and vals.get("company_id"):
                # Name suffix with company ID to avoid duplicated technames in multy company
                name += "-" +  str(vals["company_id"])
            vals["tech_name"] = self._normalize_tech_name(name)
github-actions[bot] commented 2 years ago

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.