Skip to Content
Menu
This question has been flagged
1 Reply
3325 Views

I have created a folder locally in my computer. The invoice value are saved in logging and i want to save same  logging value into a folder available locally. I am able to access the folder and file and also able to create a file but with the empty value in the file. Is it the problem with the sql command or what.

If anyone have any idea plz help me.

Avatar
Discard
Best Answer

please try to give user odoo permissions and also access rights to that folder. eg: chown odoo:odoo path and also chmod -R 777 path

Please try this and I am not sure whether this works. If not working then please update your question with more details including test code.

Avatar
Discard
Author

The file is created in the path provided but with no value. Even though log file in odoo has several values. I have used following code to create an save value in the file:

@api.model

def archive_and_delete_old_logs(self, nb_days=90, archive_path=''):

if archive_path:

file_name= time.strftime("%Y%m%d_%H%M%S.csv")

file_path= os.path.join(archive_path, file_name)

self.env.cr.execute("""COPY (SELECT * FROM smile_log WHERE log_date + interval '%s days' < NOW() at time zone 'UTC')

TO %s WITH(FORMAT csv, ENCODING utf8)""", (nb_days, file_path,))

self.env.cr.execute("DELETE FROM smile_log WHERE log_date + interval '%s days' < NOW() at time zone 'UTC'",

(nb_days,))

return True

The following model execute by automated action in odoo.

How to save value in the created file.

Related Posts Replies Views Activity
3
Oct 23
7368
1
Sep 23
2619
1
May 23
1598
2
Apr 23
2010
1
Mar 23
1545