跳至內容
選單
此問題已被標幟
5667 瀏覽次數

I created a text file in the same directory as models.py and wrote a file opening and reading code in models.py to open and append to the file content. But the file stays empty. my code work well as python script, but not within odoo. Help please.

頭像
捨棄

did you create the file with script or manual. if you did it manual and you're on linux look at the file owner and permissions.

Can you paste the code?

yes i created the file manually and i checked the permissions the are set for read & write to all users , this is the function inside models.py

# -*- coding: utf-8 -*-

from datetime import timedelta, date, datetime

import pytz

from openerp import models, fields, api, _, tools
from openerp.exceptions import Warning
from openerp.osv import osv, fields, orm

from pyimppn import imppn_line
import psycopg2
import os

import logging
_logger = logging.getLogger(__name__)

class companyimppn(models.Model):
    _inherit = 'res.company'

    x_teamsystemid = fields.integer(string='Teamsystem id')

class view(osv.osv):
    _inherit = ['ir.ui.view']

    def __init__(self, pool, cr):
        super(view, self).__init__(pool, cr)
        super(view, self)._columns['type'].selection.append(('odooimppnview','OdooimppnView'))
 
class odooimppn(models.Model):
    _name = 'odoo_imppn.content'
    _description = 'Odoo imppn content'


    def testing(self):
        results = "this is a test to see if we are able to write on a text file located inside the module"
        path = os.path.expanduser('./etc/odoo/addons/odoo_imppn/IMPPN_tests.txt')
        # path = os.path.expanduser('./home/mounirlahsini/Downloads/IMPPN_tests.txt')
        fileIMPPN = open(path, 'r+')
        fileIMPPN.write(results)
        fileIMPPN.close()


testing()
相關帖文 回覆 瀏覽次數 活動
1
1月 20
14978
1
4月 25
3665
3
12月 22
11579
5
4月 24
42140
6
4月 24
38992