Пример #1
0
    def get_models(self, table_model_map=None):
        """Return list of model dicts for all available models."""
        self = self.with_context(lang=self.env.user.lang)
        model_table_map = defaultdict(list)
        for k, v in (table_model_map or {}).items():
            model_table_map[v].append(k)

        models = self.get_related_models(model_table_map)

        # filter out abstract models (they do not have DB tables)
        non_abstract_models = self.env.registry.models.keys()
        models = models.filtered(lambda m: m.model in non_abstract_models)

        return list(map(dict_for_model, models))
Пример #2
0
 def _constraint_line_ids(self):
     models_with_tables = self.env.registry.models.keys()
     for view in self:
         nodes = view.line_ids.filtered(lambda n: n.join_node)
         nodes_models = nodes.mapped('table_alias')
         nodes_models += nodes.mapped('join_node')
         not_nodes = view.line_ids.filtered(lambda n: not n.join_node)
         not_nodes_models = not_nodes.mapped('table_alias')
         err_msg = _('Inconsistent lines.')
         if set(nodes_models) - set(not_nodes_models):
             raise ValidationError(err_msg)
         if len(set(not_nodes_models) - set(nodes_models)) > 1:
             raise ValidationError(err_msg)
         models = view.line_ids.mapped('model_id')
         if models.filtered(lambda m: m.model not in models_with_tables):
             raise ValidationError(_('Abstract models not supported.'))
Пример #3
0
 def _get_models(self):
     # consider mail-thread models only
     models = super(BaseModuleUninstall, self)._get_models()
     return models.filtered('is_mail_thread')
Пример #4
0
 def _get_models(self):
     # consider mail-thread models only
     models = super(BaseModuleUninstall, self)._get_models()
     return models.filtered('is_mail_thread')