AddRecord from one table to another

I was looking around the docs and the forum but could not find a clear answer : is there a way to copy a whole ligne from one table to another (they share exactly the same structure) using an action button and the AddRecord function ?

Thanks !

This should be possible. Essentially, what you’d need to do is:

  1. Have a formula gather info about the record you want to copy. For this, I happily point you to a ‘get_fields’ function I wrote a while ago (instructions how to use this are here). It will give you all columns of a given record (just the current record, rec, here) as a list of column names.
  2. Using this list, grab all the values from the current record – either by using the builtin RECORD(rec) or by doing something like this: values = [getattr(rec, col_name) for col_name in list_of_column_names if not col_name == "name of this formula column itself goes here"].
  3. Have the same formula mesh together the column names and values into a list in the correct format for use with the action button. I don’t quite remember what that is right now, but the info is around here somewhere.

Then just map that formula column to your action button widget.