One more point: looks like
person__get_my_entity_id() is being called to retrieve the
person_id. The function makes this call:
SELECT entity_id from users where username = SESSION_USER; If you are running a database tool like PgAdmin, you may be connected as the postgres user, which probably doesn't have a corresponding row in the users table. As a workaround, I've modified the function to add a default person_id to the defaults table and then select it if the initial select does not return any rows. -- Function: person__get_my_entity_id() -- DROP FUNCTION person__get_my_entity_id(); CREATE OR REPLACE FUNCTION person__get_my_entity_id() RETURNS integer AS $BODY$ --insert a default person ID if it does not exist INSERT INTO defaults (setting_key, value) SELECT 'default_person_id', 1 WHERE NOT EXISTS (SELECT 1 FROM defaults WHERE setting_key = 'default_person_id'); --select entity ID based on current user or default person_id if null SELECT entity_id FROM ( SELECT entity_id, 1 as seq FROM users WHERE username = SESSION_USER UNION SELECT (SELECT value::integer FROM defaults WHERE setting_key = 'default_person_id'), 2 as seq ORDER BY seq LIMIT 1 ) A $BODY$ LANGUAGE sql VOLATILE COST 100; ALTER FUNCTION person__get_my_entity_id() OWNER TO postgres; COMMENT ON FUNCTION person__get_my_entity_id() IS ' Returns the entity_id of the current, logged in user.'; Thanks. Brian Brian Wolf
Phone: 410.367.2958
Email: ..hidden..
When adding a sales invoice, a row is added to the AR table. One of the columns to set is person_id. |