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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
4858
Views
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Jan 20
|
13843 | ||
|
3
Dec 22
|
9952 | ||
|
5
Apr 24
|
39346 | ||
|
6
Apr 24
|
36751 | ||
|
3
Mar 24
|
9218 |
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?
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()