diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index ce6341cc9b2..003a33b5e1d 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -42,7 +42,7 @@ class account_analytic_line(osv.osv): } _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c), + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), } _order = 'date' diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index c23bd35b6a7..9fd609c7ed3 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -630,7 +630,7 @@ class account_bank_statement_line(osv.osv): 'statement_id': fields.many2one('account.bank.statement', 'Statement', select=True, required=True, ondelete='cascade'), 'reconcile_id': fields.many2one('account.bank.statement.reconcile', - 'Reconcile', states={'confirm':[('readonly',True)]}), + 'Reconcile'), 'move_ids': fields.many2many('account.move', 'account_bank_statement_line_move_rel', 'move_id','statement_id', 'Moves'), diff --git a/addons/account/i18n/th.po b/addons/account/i18n/th.po index 320fdc82290..7389cdda788 100644 --- a/addons/account/i18n/th.po +++ b/addons/account/i18n/th.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-03-15 03:12+0000\n" +"PO-Revision-Date: 2010-05-20 07:09+0000\n" "Last-Translator: Songpon Phusing \n" "Language-Team: Thai \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-04-17 04:08+0000\n" +"X-Launchpad-Export-Date: 2010-05-21 03:38+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -51,7 +51,7 @@ msgstr "" #. module: account #: model:account.account.type,name:account.account_type_asset msgid "Asset" -msgstr "" +msgstr "สินทรัพย์" #. module: account #: constraint:ir.actions.act_window:0 @@ -106,7 +106,7 @@ msgstr "" #: model:ir.actions.wizard,name:account.wizard_vat_declaration #: model:ir.ui.menu,name:account.menu_wizard_vat_declaration msgid "Print Taxes Report" -msgstr "" +msgstr "พิมพ์รายงานภาษี" #. module: account #: field:account.account,parent_id:0 @@ -2133,7 +2133,8 @@ msgid "Analytic Entry" msgstr "" #. module: account -#: view:res.company:0 field:res.company,overdue_msg:0 +#: view:res.company:0 +#: field:res.company,overdue_msg:0 msgid "Overdue Payments Message" msgstr "" diff --git a/addons/auction/__openerp__.py b/addons/auction/__openerp__.py index 8918a6394aa..cd27c60fdb7 100644 --- a/addons/auction/__openerp__.py +++ b/addons/auction/__openerp__.py @@ -50,8 +50,10 @@ 'wizard/auction_payer_sel_view.xml', 'wizard/auction_lots_sms_send_view.xml', 'wizard/auction_catalog_flagey_view.xml', +# 'wizard/auction_aie_send_view.xml', # 'wizard/auction_aie_send_result_view.xml', 'wizard/auction_lots_buyer_map_view.xml', +# 'wizard/auction_lots_numerotate_view.xml', 'auction_view.xml', 'auction_report.xml', diff --git a/addons/auction/wizard/__init__.py b/addons/auction/wizard/__init__.py index 957ab02b053..41ada315889 100644 --- a/addons/auction/wizard/__init__.py +++ b/addons/auction/wizard/__init__.py @@ -31,8 +31,10 @@ import auction_lots_sms_send import auction_catalog_flagey_report #import auction_lots_cancel #import auction_transfer_unsold_object +#import auction_aie_send #import auction_aie_send_result import auction_lots_buyer_map +#import auction_lots_numerotate # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/auction/wizard/auction_aie_send.py b/addons/auction/wizard/auction_aie_send.py new file mode 100644 index 00000000000..51368349a98 --- /dev/null +++ b/addons/auction/wizard/auction_aie_send.py @@ -0,0 +1,223 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +# +# Does not properly work concurrently !!! +# +import base64 +import mimetypes +import httplib +import threading +from tools.translate import _ +from osv import fields,osv + +class auction_lots_send_aie(osv.osv_memory): + _name = 'auction.lots.send.aie' + _descritption = 'Send to website' + + def _date_get(self, cr, uid, context={}): + selection = context and context.get('selection') + if selection: + return [('','')] + selection + return [('','')] + + _columns = { + 'uname': fields.char('Login', size=64), + 'password': fields.char('Password', size=64), + 'objects': fields.integer('# of objects', readonly=True), + 'lang': fields.selection([('fr','fr'),('ned','ned'),('eng','eng'),('de','de')],'Language'), + 'numerotation': fields.selection([('prov','Provisoire'),('definite','Definitive (ordre catalogue)')],'Numerotation'), + 'dates': fields.selection(_date_get,'Auction Date'), + 'img_send': fields.boolean('Send Image also ?'), + } + + def default_get(self, cr, uid, fields, context): + """ + To get default values for the object. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. + """ + res = super(auction_lots_send_aie, self).default_get(cr, uid, fields, context=context) + if 'uname' in fields and context.get('uname',False): + res['uname'] = context.get('uname') + if 'password' in fields and context.get('password',False): + res['password'] = context.get('password') + return res + + def _catalog_send(uname, passwd, lang, did, catalog): + def post_multipart(host, selector, fields, files): + def encode_multipart_formdata(fields, files): + BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' + CRLF = '\r\n' + L = [] + for (key, value) in fields: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"' % key) + L.append('') + L.append(value) + for (key,value) in files: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, key+'.pickle')) + L.append('Content-Type: application/octet-stream') + L.append('') + L.append(value) + L.append('--' + BOUNDARY + '--') + L.append('') + body = CRLF.join(L) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + content_type, body = encode_multipart_formdata(fields, files) + import httplib + + headers = {"Content-type": content_type, "Accept": "*/*"} + conn = httplib.HTTPConnection(host) + conn.request("POST", '/bin/catalog.cgi', body, headers = headers) + response = conn.getresponse() + val = response.status + conn.close() + return val + return post_multipart('auction-in-europe.com', "/bin/catalog.cgi", (('uname',uname),('password',passwd),('did',did),('lang',lang)),(('file',catalog),)) + + def _photo_bin_send(uname, passwd, ref, did, photo_name, photo_data): + def get_content_type(filename): + return mimetypes.guess_type(filename)[0] or 'application/octet-stream' + + def post_multipart(host, selector, fields, files): + def encode_multipart_formdata(fields, files): + BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' + CRLF = '\r\n' + L = [] + for (key, value) in fields: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"' % key) + L.append('') + L.append(value) + for (key, filename, data) in files: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename)) + L.append('Content-Type: %s' % get_content_type(filename)) + L.append('') + L.append(data) + L.append('--' + BOUNDARY + '--') + L.append('') + body = CRLF.join(L) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + content_type, body = encode_multipart_formdata(fields, files) + + headers = {"Content-type": content_type, "Accept": "*/*"} + conn = httplib.HTTPConnection(host) + conn.request("POST", '/bin/photo.cgi', body, headers = headers) + response = conn.getresponse() + val = response.status + conn.close() + return val + return post_multipart('auction-in-europe.com', "/bin/photo.cgi", (('uname',uname),('ref',ref),('passwd',passwd),('did',did)),(('file',photo_name,photo_data),)) + + + def _photos_send(cr, uid, uname, passwd, did, ids): + service = netsvc.LocalService("object_proxy") + for (ref,id) in ids: + + # ids_attach = service.execute(db_name,uid, 'ir.attachment', 'search', [('res_model','=','auction.lots'), ('res_id', '=',id)]) + datas = service.execute(cr.db_name,uid, 'auction.lots', 'read',[id], ['name','image']) + if len(datas): + bin = base64.decodestring(datas[0]['image']) + fname = datas[0]['name'] + _photo_bin_send(uname, passwd, ref, did, fname, bin) + + def get_dates(self, cr, uid, ids, context={}): + import httplib + data_obj = self.pool.get('ir.model.data') + conn = httplib.HTTPConnection('www.auction-in-europe.com') + datas = self.read(cr, uid, ids[0],['uname','password']) + conn.request("GET", "/aie_upload/dates_get.php?uname=%s&passwd=%s" % (datas['uname'], datas['password'])) + response = conn.getresponse() + if response.status == 200: + def _date_decode(x): + return (x.split(' - ')[0], (' - '.join(x.split(' - ')[1:]).decode('latin1','replace').encode('utf-8','replace'))) + context['selection'] = map(_date_decode, response.read().split('\n')) + self._date_get(cr, uid, context=context) + else: + raise osv.except_osv(_('Error'), _("Connection to WWW.Auction-in-Europe.com failed !")) + id1 = data_obj._get_id(cr, uid, 'auction', 'view_auction_lots_send') + res_id = data_obj.browse(cr, uid, id1, context=context).res_id + context.update(datas) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'auction.lots.send.aie', + 'views': [(res_id,'form')], + 'type': 'ir.actions.act_window', + 'target':'new', + 'context': context + } + + def _send(self, cr, uid, ids, context={}): + import pickle, thread, sql_db + cr.execute('select name,aie_categ from auction_lot_category') + vals = dict(cr.fetchall()) + cr.close() + + service = netsvc.LocalService("object_proxy") + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ']) + lots_ids = [] + datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates']) + for l in lots: + if datas['numerotation']=='prov': + l['ref']='%s%03d' % (l['bord_vnd_id'][1],l['lot_num']) + l['ref2']='%s%03d' % (l['bord_vnd_id'][1],l['lot_num']) + else: + l['ref']='%04d' % (l['obj_num'],) + l['ref2']='%s%03d' % (l['bord_vnd_id'][1],l['lot_num']) + if l['artist_id']: + l['artist_id'] = l['artist_id'][1] + else: + l['artist_id'] = '' + for n in ('obj_desc','artist_id','lot_type'): + try: + l[n]=l[n].decode('utf-8','replace').encode('latin1','replace') + except: + l[n]='' + del l['lot_num'] + del l['obj_num'] + del l['bord_vnd_id'] + l['aie_categ'] = vals.get(l['lot_type'], False) + lots_ids.append((l['ref'], l['id'])) + args = pickle.dumps(lots) + thread.start_new_thread(_catalog_send, (datas['uname'],datas['password'],datas['lang'],datas['dates'], args)) + if(datas['form']['img_send']==True): + thread.start_new_thread(_photos_send, (cr.dbname, uid, datas['uname'], datas['password'],datas['dates'], lots_ids)) + return {} + + def send_pdf(self, cr, uid, ids, context): + threaded_calculation = threading.Thread(target=self._send, args=(cr, uid, ids, context)) + threaded_calculation.start() + return {} + +auction_lots_send_aie() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/auction/wizard/auction_aie_send_result.py b/addons/auction/wizard/auction_aie_send_result.py new file mode 100644 index 00000000000..404881b2d6b --- /dev/null +++ b/addons/auction/wizard/auction_aie_send_result.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +# +# Does not properly work concurrently !!! +# + +import netsvc +from tools.translate import _ +from osv import fields, osv + +class auction_lots_pay(osv.osv_memory): + _name = 'auction.lots.send.aie.results' + _description = 'Send results to Auction-in-europe.com' + + + def _date_get(self, cr, uid, context={}): + selection = context and context.get('selection') + if selection: + return [('','')] + selection + return [('','')] + + _columns = { + 'uname': fields.char('Login', size=64), + 'password': fields.char('Password', size=64), + 'objects': fields.integer('# of objects'), + 'dates': fields.selection(_date_get,'Auction Date'), + } + + def default_get(self, cr, uid, fields, context): + """ + To get default values for the object. + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. + """ + res = super(auction_lots_pay, self).default_get(cr, uid, fields, context=context) + if 'uname' in fields and context.get('uname',False): + res['uname'] = context.get('uname') + if 'password' in fields and context.get('password',False): + res['password'] = context.get('password') + return res + + def _catalog_send(self, uname, passwd, did, catalog): + def post_multipart(host, selector, fields, files): + def encode_multipart_formdata(fields, files): + BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' + CRLF = '\r\n' + L = [] + for (key, value) in fields: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"' % key) + L.append('') + L.append(value) + for (key,value) in files: + L.append('--' + BOUNDARY) + L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, key+'.pickle')) + L.append('Content-Type: application/octet-stream') + L.append('') + L.append(value) + L.append('--' + BOUNDARY + '--') + L.append('') + body = CRLF.join(L) + content_type = 'multipart/form-data; boundary=%s' % BOUNDARY + return content_type, body + content_type, body = encode_multipart_formdata(fields, files) + import httplib + + headers = {"Content-type": content_type, "Accept": "*/*"} + conn = httplib.HTTPConnection(host) + conn.request("POST", '/bin/catalog_result.cgi', body, headers = headers) + response = conn.getresponse() + val = response.status + conn.close() + return val + return post_multipart('auction-in-europe.com', "/bin/catalog_result.cgi", (('uname',uname),('password',passwd),('did',did)),(('file',catalog),)) + + def get_dates(self, cr, uid, ids, context): + import httplib + conn = httplib.HTTPConnection('www.auction-in-europe.com') + data_obj = self.pool.get('ir.model.data') + datas = self.read(cr, uid, ids[0],['uname','password']) + conn.request("GET", "/aie_upload/dates_get_result.php?uname=%s&passwd=%s" % (datas['uname'], datas['password'])) + response = conn.getresponse() + if response.status == 200: + def _date_decode(x): + return (x.split(' - ')[0], (' - '.join(x.split(' - ')[1:]).decode('latin1').encode('utf-8'))) + context['selection'] = map(_date_decode, response.read().split('\n')) + self._date_get(cr, uid, context=context) + else: + raise osv.except_osv(_('Error'), + _("Connection to WWW.Auction-in-Europe.com failed !")) + id1 = data_obj._get_id(cr, uid, 'auction', 'view_auction_lots_send_result_send') + res_id = data_obj.browse(cr, uid, id1, context=context).res_id + context.update(datas) + return { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'auction.lots.send.aie.results', + 'views': [(res_id,'form')], + 'type': 'ir.actions.act_window', + 'target':'new', + 'context': context + } + + def send(self, cr, uid, ids, context): + import pickle + service = netsvc.LocalService("object_proxy") + datas = self.read(cr, uid, ids[0],['uname','password','dates']) + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','obj_price']) + args = pickle.dumps(lots) + self._catalog_send(datas['uname'], datas['password'], datas['dates'], args) + return {} + +auction_lots_pay() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/auction/wizard/auction_aie_send_result_view.xml b/addons/auction/wizard/auction_aie_send_result_view.xml new file mode 100644 index 00000000000..7056e88b20e --- /dev/null +++ b/addons/auction/wizard/auction_aie_send_result_view.xml @@ -0,0 +1,58 @@ + + + + + + + + Auction lots send result - Login + auction.lots.send.aie.results + form + +
+ + + + +