Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3454 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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.

Post correlati Risposte Visualizzazioni Attività
3
ott 23
7862
1
set 23
2872
1
mag 23
1865
2
apr 23
2409
1
mar 23
1809