Helper process "Make Table a Document"

Description

On ticket it was noticed that creating a document table is a bit complex, it requires to create many columns and the workflow is tricky to do it correctly.

That's why a helper process that allows the user to make the table a document will be a big improvement.

I think the process must suggest the user to create the following columns (maybe a flag per each column):

  • DocAction

  • DocStatus

  • Processing

  • C_DocTypeTarget_ID

  • C_DocType_ID

  • DateAcct

  • DateTrx

  • IsApproved

  • Processed

  • DocumentNo

  • Description

  • SalesRep_ID

  • AD_User_ID

  • C_Currency_ID

If the column already exists do nothing, just create the columns that the user selects and doesn't exist in the table.

Additionally a flag asking the user if is required to create a valid initial workflow, in this case it must be created for the table with the common 4 nodes (Start, Auto, Prepare, Complete) and the three common transitions between nodes.

Environment

None

Attachments

2

relates to

Activity

Show:

Nicolas Micoud July 21, 2021 at 11:47 AM

Hi ,

That’s weird, don’t you get last updates from

 

I can see there correct migration scripts with the register at the end

+ add org.idempiere.process in imported packages if org.adempiere.ui.zk

Carlos Ruiz July 21, 2021 at 11:41 AM

Hi

  • the migration scripts have wrong name and don’t have the register_migration_script at the end

  • when compiling in eclipse is throwing error

  • the org.adempiere.base.process is not available for the org.adempiere.ui.zk plugin (that’s the reason why I have created some process in org.adempiere.base), so this can have two solutions:

    • move the process to org.adempiere.base

    • add the plugin org.adempiere.base.process as required plugin in org.adempiere.ui.zk

    • - which one would you recommend for this case?

  • I tried the second option (required plugin) and still eclipse throws error saying CreateTable.WORKFLOW_COLUMNS is not API

Regards,

Carlos Ruiz

Nicolas Micoud July 20, 2021 at 2:10 PM

Hi

All changes commited ; I think we’re close of the final version.

I’ve made some tests and I think is ok, but as there was lots of changes, I may have missed something.

 

Thanks,

 

Nicolas

Carlos Ruiz July 20, 2021 at 11:37 AM

In this case, I would replace the numeric fields with checkbox (IsCreateValue/IsCreateName). And if selected, then set 40/60 as default length

Yes, that sounds good

Nicolas Micoud July 20, 2021 at 10:50 AM

Hi,
Ok, I’ll add and code the flags

For the EntityType, this was available in my version but forgot to add, I will do it :)

Not sure about the default length for Value/Name ; because if you don’t want those columns, you’ll have to empty the fields.
In this case, I would replace the numeric fields with checkbox (IsCreateValue/IsCreateName). And if selected, then set 40/60 as default length

wdyt?

Carlos Ruiz July 20, 2021 at 10:30 AM

Hi

  • I think flags are more “user-friendly” than a “chosen list”. I mean, it sounds easier just to click on flags, than selecting columns from a list one by one

  • CreateWorkflow → yes, there are some mandatory columns, we can simply create them ignoring the flag, or force the flags to be true using a callout - and make them, readonly with read-only-logic

  • I made another test and I think it would be good to default these:

    • Entity Type → @SQL=select get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) from dual

    • Length of Value Column → 40

    • Length of Name Column → 60

    • You can also add the “Leave empty if not needed” message to the description of the parameters, that way it can be seen in the tooltip at the right panel

  • I noticed too that the System Element for the table_ID is setting the same columnname as the name. I think the usual is to assign the table name in the element name and print text, and same in the description (see for example the element C_Charge_ID)

Nicolas Micoud July 20, 2021 at 6:55 AM

Hi,

I’ve commited changes.

 

For the optional columns part, I can use the “Chosen Multiple List” field.

If the CreateWorkflow checkbox is ticked, “mandatory” columns will be created (and I think I can remove them from the field using a dynamic validation).

In any case, user can select some columns from the editor and that should be easy to get the value from the java class and add them to the table (so we won’t have to use default value as it not working as expected).

wdyt?

Carlos Ruiz July 19, 2021 at 10:42 AM

Yes, I expressed it wrongly, user friendliness is important also for developers, I tried to say is that having many parameters doesn’t make a process unfriendly, if they are properly explained, or intuitive to understand their meaning.

I think a set of flags is not a big issue, every flag is an optional column, if we want to improve usability on process parameters, then I think there is a ticket open to allow field groups on parameters, in the meantime, we can use the flags, doesn’t sound like a big deal.

Another way to improve the idea can be to add a parameter “Select Columns” - and show the flags for the optional columns just when that parameter is selected, but I think that’s over-engineering something that in principle is simple.

Heng Sin Low July 19, 2021 at 10:21 AM

Oracle 11 is very old now, we should remove that restriction.

Btw, I haven’t tested this but I do strongly disagree that we shouldn’t concern too much about user friendliness if the intended audience is developer instead of end user.

Carlos Ruiz July 19, 2021 at 9:55 AM

Hi

  • the usual java notation is that constants are all uppercase, it looks better if we follow that notation here

  • the file name of the scripts are still wrong (4658)

  • max table length would need to be 26 if is translatable (to have space for the 4 characters on _trl) - or 27 if is not translatable (to allow space for the _ID and _UU prefixes on columns). This restrictions is imposed by oracle 11, I think in the end we recently decided to stop support for oracle 11, maybe we can remove this restriction ( WDYT )

  • About column sync at the end - you’re right - that’s desirable but can be made in a different ticket - indeed I would like the idea to make the ColumnSync process better synchronizing ALL columns modified after the last execution on the same table (can be discovered in Process Audit)

  • About all optional columns, I think is worthy

    • => Not sure, I fear the panel will become too big and not user friendly.

    • A big panel is not an issue, look for example the Initial Tenant Setup process. And this is not a process for end-users so I’m not too concerned about user-friendliness. I think is very simple to add all those parameters and the resulting process will be a lot more robust and useful - I think this will become my preferred way to create tables from now on :-)

Regards,

Carlos Ruiz

Nicolas Micoud July 8, 2021 at 3:30 PM

HI ,

What has been fixed in the last commit

  • CreateTable doesn’t compile → org.tgi.model.SystemIDs_Tgi.REFERENCE_DOCUMENTSTATUS → org.compiere.model.SystemIDs.REFERENCE_DOCUMENTSTATUS

  • createAndSynchronizeColumn must be named createColumn (is not synchronizing, which is OK)

  • All the hardcoded numbers, for example the max table length, the IDs (19, 110, 106), the column lengths (0, 30, 22, 7, 36, 6), is better to define them as constants

  • trl table must have marked -> IsDeleteable=N (mettre à Y pour les autres)

  • a minor typo in the placeholder text → Leave empty if not needed (is -> if)

  • wf.setAuthor("osef"); → who is “osef” maybe better to put there “iDempiere” ? - or the name of the user running the process

    osef means "on s'en fout" in French which means something like "we don't care" ; iDempiere is definitely better :)

  • p_isCreateKeyColumn…

The process was written long time before and at that time I was sometimes creating table without a single key column.
But now, all tables have a single key, so what you suggest makes sense

  • On the other hand - ALL tables must have the UUID column - that must be always created independently if there is key column or not (same for _trl table).

  • Also I think that AD_Table.IsChangeLog=Y is better default

I also change the name of the scripts (4628 != 4858)

 

Remainings points

  • max table length is 27, not 25

AFAIR, is 25 if you need translation as you add TRL, I'll redo tests

 

  • it can be worthy maybe to add a flag parameter to sync the table(s) at the end of the process - by default can be false (not synchronize)

I had this parameter in my process but at the end I never use it as there is almost always a need to add some columns.
And is faster to run it a single time when all columns are in the table
Otherwise, you have to sync the table for each new column.

If you want to have it, I think we need to extract the logic from the process so it can be called from ColumnSync and CreateTable processes.

 

  • All optional columns

=> Not sure, I fear the panel will become too big and not user friendly.
If there is need to add those columns, you add them in Table>Column (with the callout is really easy) ; anyway a link in the description of the process to a wiki page can be useful?
Or… we can have a list (RefList) of those columns and let user choose them using the new MultipleListChoice editor. But we need to first fix the setting of several default values (see )

 

Regards,

Nicolas

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created June 30, 2021 at 2:49 PM
Updated July 16, 2024 at 6:43 AM
Resolved November 19, 2021 at 4:03 PM