コード例 #1
0
ファイル: res_partner.py プロジェクト: focusate/misc
    def write(self, vals):
        """Extend to update related company with company registry.

        Also formats company_registry value.
        """
        if vals.get(REGISTRY_KEY):
            vals[REGISTRY_KEY] = strip_space(vals[REGISTRY_KEY])
        res = super().write(vals)
        # Note this is only valid for write, because on create, we know
        # there won't be any related company (this is different than
        # `company_id` relation).
        if REGISTRY_KEY in vals:
            # Value to set for related company.
            self._set_company_registry_on_company(vals[REGISTRY_KEY])
        return res
コード例 #2
0
ファイル: res_partner.py プロジェクト: focusate/misc
 def create(self, vals_list):
     """Extend to format company_registry without any spaces."""
     for vals in vals_list:
         if vals.get(REGISTRY_KEY):
             vals[REGISTRY_KEY] = strip_space(vals[REGISTRY_KEY])
     return super().create(vals_list)
コード例 #3
0
ファイル: test_formatting.py プロジェクト: focusate/footil
 def test_54_strip_space(self):
     """Strip string with white space only."""
     s = formatting.strip_space('\tabc ')
     self.assertEqual(s, 'abc')
コード例 #4
0
ファイル: test_formatting.py プロジェクト: focusate/footil
 def test_55_strip_space(self):
     """Strip string with white space and space around chars."""
     s = formatting.strip_space('\tab c \nd\r')
     self.assertEqual(s, 'abcd')
コード例 #5
0
ファイル: test_formatting.py プロジェクト: focusate/footil
 def test_53_strip_space(self):
     """Strip string without spaces."""
     s = formatting.strip_space('abc')
     self.assertEqual(s, 'abc')