Create a table in postgres - if model/ Fields is given on front-end

I want to create a table with column in PostgreSQL from front-end (on a click of button).

I gave Model name from which table should create:
Model Name: test.model

And create One2many field which store details of a column of a table(Model Name), example- technical name, field description, field type, field relation.

Can someone tell me How I can create a table in database, when a button is clicked ?

Hi,

In Tryton, we have a strong reluctance to schema created by users for those reasons:

  • it is not testable by the CI because it is custom
  • it may introduce security issues
  • users are not the best to design the schema of the database
  • bad foreign keys can slowdown the application

If you need to store custom data on record, you should look at the Dict field like the product_attribute module does.

But I want user can design the schema of the database from front-end.

If you really want it then you’re on your own: you should design yourself a Tryton modules that allow to do that.

But what is exactly your issue?

@ced @nicoe Thanks for your answers.

We are trying to develop a module that works like CPRS VistA (ref - https://en.wikipedia.org/wiki/VistA). For this the a user group (lets call them Semi-Technical Consultants) should be able to define templates for the end users. And the data given by the end-users should be persisted in the database in respective data tables.

The key ideas are -

  1. For any template that needs to be defined, the developer should not be called upon.
  2. Any template is editable by the Semi-Technical Consultants.
  3. The template should render a proper view where the end-users should be able to store data.

Note - We are working on version 5.0

Thanks in advance. Any support on this idea will be helpful.

I think a template could be a DictSchema and a form is a record with a link to a dictschema and a dict field.
You may have a default value for the dict with all the keys so it will look like a form to fill.

1 Like