Exemplo n.º 1
0
    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
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 def test_54_strip_space(self):
     """Strip string with white space only."""
     s = formatting.strip_space('\tabc ')
     self.assertEqual(s, 'abc')
Exemplo n.º 4
0
 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')
Exemplo n.º 5
0
 def test_53_strip_space(self):
     """Strip string without spaces."""
     s = formatting.strip_space('abc')
     self.assertEqual(s, 'abc')