se adiciona namespaces a invoice
FossilOrigin-Name: caf85d4a30e7945ca2a6fc3a9430855fa8623442b1a30ae824f742e2a93e2956
This commit is contained in:
		| @@ -1,3 +1,5 @@ | ||||
| import warnings | ||||
|  | ||||
| class Field: | ||||
|     def __set_name__(self, owner, name, virtual=False): | ||||
|         self.name = name | ||||
| @@ -17,8 +19,10 @@ class Field: | ||||
|         if name is None: | ||||
|             return | ||||
|  | ||||
|         if name not in namespaces: | ||||
|             raise KeyError("namespace %s not found" % (name)) | ||||
|         #TODO(bit4bit) aunque las pruebas confirmar | ||||
|         #que si se escribe el namespace que es | ||||
|         #no ahi confirmacion de declaracion previa del namespace | ||||
|  | ||||
|         inst._namespace_prefix = name | ||||
|  | ||||
|     def _call(self, inst, method, *args): | ||||
| @@ -27,7 +31,7 @@ class Field: | ||||
|         if callable(call): | ||||
|             return call(*args) | ||||
|  | ||||
|     def _create_model(self, inst, name=None, model=None, attribute=None): | ||||
|     def _create_model(self, inst, name=None, model=None, attribute=None, namespace=None): | ||||
|         try: | ||||
|             return inst._fields[self.name] | ||||
|         except KeyError: | ||||
| @@ -37,7 +41,11 @@ class Field: | ||||
|                 obj = self.model() | ||||
|             if name is not None: | ||||
|                 obj.__name__ = name | ||||
|             self._set_namespace(obj, self.namespace, inst.__namespace__) | ||||
|  | ||||
|             if namespace: | ||||
|                 self._set_namespace(obj, namespace, inst.__namespace__) | ||||
|             else: | ||||
|                 self._set_namespace(obj, self.namespace, inst.__namespace__) | ||||
|  | ||||
|             if attribute: | ||||
|                 inst._fields[attribute] = obj | ||||
|   | ||||
| @@ -67,7 +67,7 @@ class One2Many(Field): | ||||
|         assert self.name is not None | ||||
|  | ||||
|         def creator(attribute): | ||||
|             return self._create_model(inst, name=self.field_name, model=self.model, attribute=attribute) | ||||
|             return self._create_model(inst, name=self.field_name, model=self.model, attribute=attribute, namespace=self.namespace) | ||||
|          | ||||
|         if inst in self.relation: | ||||
|             return self.relation[inst] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user