Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

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.

Ảnh đại diện
Huỷ bỏ

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()
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 20
14973
1
thg 4 25
3665
3
thg 12 22
11575
5
thg 4 24
42130
6
thg 4 24
38989