コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

generate xls or csv file

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
csvxlsodoo8.0
1 返信
9837 ビュー
アバター
Abderrahmen

Plz i need to know how can i generate xls or csv file filled with data for exemple an array. Thank you.

0
アバター
破棄
OdooBot
Thank you friend,
the thing is, creating a file is not a problem but my probleme that i want to generate a file after click event in a button to show the save file window. 

2015-11-19 19:45 GMT+01:00 Drees Far <far.drees@gmail.com>:

A new answer for generate xls or csv file has been posted. Click here to access the post.

--
Drees Far
Sent by Odoo S.A. using Odoo about Forum Post generate xls or csv file



--

 

Abderrahmen KHALLEDI
Développeur Odoo/OpenERP
Villa n°5, rue Haroun El Rachid Mutuelle ville
Tél. : +216 55 521 232
Mail : abderrahmen@techcare.tn
Linkedin : tn.linkedin.com/in/abderrahmenkhalledi/
Site : http://www.techcare-group.tn

アバター
Rihene
最善の回答

Hello my friend;

here is some useful links that can help you a lot:

http://stackoverflow.com/questions/2084069/create-a-csv-file-with-values-from-a-python-list

http://stackoverflow.com/questions/14037540/writing-a-python-list-of-lists-to-a-csv-file

http://gis.stackexchange.com/questions/72458/export-list-of-values-into-csv-or-txt-file

https://docs.python.org/2/library/csv.html

You can use the ir.attachment module. I fact, you will create a .csv file in your pc and then a button which will call a function that you define in you python.And here is an example:

def print_declaration(self, cr, uid, ids, id, context=None):

print ids

dec = self.pool.get('declaration.cnss')

obj = dec.search(cr, uid, [('id','in', ids)])

cns = dec.read(cr, uid, obj, ['id', 'year','trimester','company_id'], context=False)

year = cns[0]['year']

company = cns[0]['company_id'][0]

print company

trimester = cns[0]['trimester']

filename="/opt/file.txt"

lines = open(filename).readlines()  

open(filename, 'w').writelines(lines[-1:-1])

writepath = '/opt/file.txt'

mode = 'a' if os.path.exists(writepath) else 'w' 

var = 0

i = 0

j = 0

page =1

res_list=[]

payslip_line = self.pool.get('hr.payslip')

obj_ids = payslip_line.search(cr, uid, [('company_id','=', company)]) 

for res in payslip_line.read(cr, uid, obj_ids, ['id', 'employee_id','date_from'], context=False):

date = res['date_from']

var = var + 1

if var == 12:

var = 1

obj = {}

obj['matricule'] = res['employee_id'][0]

a = str(obj['matricule'])

obj['numero'] = var

matricule = res['employee_id'][0]

obj['name'] = res['employee_id'][1]

payslip_lines = self.pool.get('hr.employee')

obj_ids2 = payslip_lines.search(cr, uid, [('id', '=', matricule)])

for res in payslip_lines.read(cr, uid, obj_ids2, ['id', 'n_cnss', 'momo_category','address_id','name_employee','surname_emloyee','name_fother','marital','gender','nic_id'], context=False):

marital = res['marital']

gender = res['gender']

nom_employe = res['name_employee']

prenom_employe = res['surname_emloyee']

nom_pere = res['name_fother']

if nom_employe== False:

My_error_Msg = 'Please, enter the name of your employee'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

if prenom_employe== False:

My_error_Msg = 'Please, enter the surname of your employee'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

if nom_pere== False:

My_error_Msg = 'Please, enter the surname of your Employee Fother'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

nom = prenom_employe+''+nom_employe

if gender=='male':

nom = prenom_employe+' B '+nom_pere+ ' ' +nom_employe

if gender=='female' and marital=='single':

nom = prenom_employe+' BT '+nom_pere+ ' ' +nom_employe

if gender=='female' and marital=='married':

nom = prenom_employe+ ' ' +nom_employe

if gender=='female' and marital=='widower':

nom = prenom_employe+' BT '+nom_pere+ ' ' +nom_employe

if gender=='female' and marital=='divorced':

nom = prenom_employe+' BT '+nom_pere+ ' ' +nom_employe

company = self.pool.get('res.partner')

company_ids = company.search(cr, uid, [('id','=',res['address_id'][0])]) 

for test in company.read(cr, uid, company_ids, ['id', 'company_id'], context=False):

companys = self.pool.get('res.company')

companys_ids = companys.search(cr, uid, [('id','=',test['company_id'][0])])

for tests in companys.read(cr, uid, company_ids, ['id', 'cnss'], context=False):

j = j + 1

if j %12==0:

page = page +1

c = str(0)

d = str(page)

pages = c+c+d

var1 = map(int, str(tests['cnss']))

var2 = var1[-1]

var3 = var1[-2]

var4 = int(str(var3) + str(var2))

var5 = var1.remove(var2)

var6 = var1.remove(var3)

s = map(str, var1)

s = ''.join(s)

s = int(s)

obj['matricule_employeur'] = s

obj['cle_employeur'] = var4

test = str(var4)

test2 = str(s)

test2 = '00'+test2

if len (test2) <> 8:

My_error_Msg = 'Taille de la matricule CNSS non compatible'

raise osv.except_osv(_("Erreur!"), _(My_error_Msg))

return False

taux_cotisation = str(0000)

variable1 = map(int, str(res['n_cnss']))

variable2 = variable1[-1]

variable3 = variable1[-2]

variable4 = int(str(variable3) + str(variable2))

cle_assure = variable4

variable5 = variable1.remove(variable2)

variable6 = variable1.remove(variable3)

matricule_assure = map(str, variable1)

matricule_assure = ''.join(matricule_assure)

if len (matricule_assure) <> 8:

My_error_Msg = 'Taille du numero Assure social non compatible'

raise osv.except_osv(_("Erreur!"), _(My_error_Msg))

return False

matricules_assure = str(matricule_assure)

cles_assure = str(cle_assure)

print ('---------------------------en test--------------------------------')

marital = res['marital']

gender = res['gender']

nom_employe = res['name_employee']

prenom_employe = res['surname_emloyee']

nom_pere = res['name_fother']

if nom_employe== False:

My_error_Msg = 'Please, enter the name of your employee'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

if prenom_employe== False:

My_error_Msg = 'Please, enter the surname of your employee'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

if nom_pere== False:

My_error_Msg = 'Please, enter the surname of your Employee Fother'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

nom = prenom_employe+''+nom_employe

if gender=='male':

nom = prenom_employe+' B '+nom_pere+ ' ' +nom_employe

if gender=='female' and marital=='single':

nom = prenom_employe+' BT '+nom_pere+ ' ' +nom_employe

if gender=='female' and marital=='married':

nom = prenom_employe+ ' ' +nom_employe

if gender=='female' and marital=='widower':

nom = prenom_employe+' BT '+nom_pere+ ' ' +nom_employe

if gender=='female' and marital=='divorced':

nom = prenom_employe+' BT '+nom_pere+ ' ' +nom_employe

if len(nom) > 60:

My_error_Msg = 'Please, The size of your employee name is incorrect'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

num_cin = res['nic_id']

cin = str(num_cin)

if num_cin ==False:

My_error_Msg = 'Please, enter the CIN of your employee'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

if len(cin) > 8:

My_error_Msg = 'Please, the size of the CIN of your employee is incorrect'

raise osv.except_osv(_("Error!"), _(My_error_Msg))

return False

taille_nom = len(nom)

nbr_espace = 60 - taille_nom

for i in range (nbr_espace):

nom = nom+' '

if taille_nom < 60:

nom = nom+''

brut_line = self.pool.get('declaration.cnss.line')

brut_ids= brut_line.search(cr, uid, [])

somme_brut1 = 0

somme_brut2 = 0

somme_brut3 = 0

for res in brut_line.read(cr, uid, brut_ids, ['id', 'brut','brut2','brut3'], context=False):

obj['brut'] = res['brut']

obj['brut2'] = res['brut2']

obj['brut3'] = res['brut3']

somme_brut1 = somme_brut1 + res['brut']

somme_brut2 = somme_brut2 + res['brut2']

somme_brut3 = somme_brut3 + res['brut3']

somme = res['brut'] + res['brut2'] + res['brut3']

somme_brut = somme_brut1 + somme_brut2 + somme_brut3

sommes = 1000*somme

obj['somme_brut1'] = somme_brut1

obj['somme_brut2'] = somme_brut2

obj['somme_brut3'] = somme_brut3

obj['somme_brut'] = somme_brut

obj['somme'] = sommes

salaire = str(int(sommes))

nbr_espace2 = 10 - len (salaire)

j = 0

for j in range (nbr_espace2):

salaire = '0'+salaire

a = str(var)

b = str(0)

ligne = b+a

print len (test2+test+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+trimester+year+pages+ligne+matricules_assure+cles_assure+nom+cin+salaire+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation)

with open(writepath, mode) as f:

f.write(test2+test+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+trimester+year+pages+ligne+matricules_assure+cles_assure+nom+cin+salaire+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+taux_cotisation+'\n')

res_list.append(obj)

filename="/opt/file.txt"

files = open(filename,'rb').read()

point = "."

nom_fichier = "DS"+test2+test+taux_cotisation+taux_cotisation+taux_cotisation+str(6)+point+trimester+year

files = open(filename,'rb').read().encode('base64')

ir_values={

'name': nom_fichier,

'datas_fname': nom_fichier,

'type': 'binary',

'datas': files,

'create_uid': uid,

# 'partner_id': ids[0],

'res_model': 'declaration.cnss',

'res_id': ids[0],

} 

self.pool.get('ir.attachment').create(cr,uid,ir_values,context=context)

here is an example that i have wirked with but a text file and i am certain that it will work with the csv

Best Regards.

1
アバター
破棄
Abderrahmen
著作者

Thank you my friend, the thing is, creating a file is not a problem but my probleme that i want to generate a file after click event in a button to show the save file window.

Rihene

its an example of a file that i have created and it works perfectly :) plz vote and upvote ;)

ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
customization on base export functionality
export csv xls
アバター
0
9月 18
4565
TypeError: error.data.arguments is undefined
csv typeerror odoo8.0 importing data from excel file
アバター
0
1月 17
5872
Custom Import method - how to ?
import csv order.lines odoo8.0
アバター
アバター
2
2月 16
8693
how to implement joint piece in odoo 8 in one view
odoo8.0
アバター
0
4月 24
2576
what is the reason behind extra move? in stock
odoo8.0
アバター
アバター
アバター
アバター
4
11月 23
6731
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now