When I needed to add another field to the invoice window I quickly was able to do that following this very instructive guide:
I had no problem adding the column to the c_invoice table and to add a referring field to the customer invoice window.
I now have to include the field also within the invoice printout and here I am really lost.
I rather would not change the original sql view that the invoice print format is based on because that will get me in trouble once I am going to update idempiere to a newer version.
I also can not use a modified copy of the sql view because there is no way to combine that with the existing print format. At least I could not find one. If there is a way I will be very happy to learn about it.
So I tried to use a virtual column. I have already had some success adding a virtual column to the c_invoice_header_v sql view but that one was just a calculated field that only drew its data from the view.
Now I have to access another table and that does not seem to work at all.
The method given in this guide works just fine to extend a table with a virtual column.
However I failed miserably when I tried to use it on the c_invoice_header_v sql view.
Here is m column sql together with the error message I am getting.
(mycolumn is the column that I have successfully added to the c_invoice table in the first step)
Column SQL:
(SELECT mycolumn FROM c_invoice i, c_invoice_header_v h WHERE i.c_invoice_id=h.c_invoice_id)
or
(SELECT mycolumn FROM c_invoice i WHERE i.c_invoice_id=c_invoice_id)
The Error message:
org.postgresql.util.PSQLException: ERROR: more than one row returned by a subquery used as an expression
Does anybody have a clue why the column SQL is not working? Is there a problem with using it on a sql view or is my sql query just buggy? I also have no real Idea how to debug my query. Since it depends on the state of the application (the invoice_id + my column sql) I also can not reproduce it in an external db management tool.
Is there a way to have a look the query that is finally built by the application?
Thanks for any hints and comments!