reports improvements (ref:nch)
bzr revid: hda@hda-20090506062802-hfrthq5lv51qqigt
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
@@ -40,8 +40,8 @@ class journal_print(report_sxw.rml_parse):
|
||||
'sum_credit': self._sum_credit
|
||||
})
|
||||
|
||||
def preprocess(self, objects, datas, ids):
|
||||
super(journal_print, self).preprocess(objects, datas, ids)
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
super(journal_print, self).set_context(objects, data, ids, report_type)
|
||||
self.cr.execute('select period_id, journal_id from account_journal_period where id in (' + ','.join([str(id) for id in ids]) + ')')
|
||||
res = self.cr.fetchall()
|
||||
self.period_ids = ','.join([str(x[0]) for x in res])
|
||||
|
||||
@@ -39,7 +39,7 @@ class general_ledger(rml_parse.rml_parse):
|
||||
|
||||
|
||||
|
||||
def preprocess(self, objects, data, ids):
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
##
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class general_ledger(rml_parse.rml_parse):
|
||||
|
||||
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
|
||||
|
||||
super(general_ledger, self).preprocess(objects, data, new_ids)
|
||||
super(general_ledger, self).set_context(objects, data, ids, report_type)
|
||||
|
||||
def __init__(self, cr, uid, name, context):
|
||||
super(general_ledger, self).__init__(cr, uid, name, context)
|
||||
|
||||
@@ -147,7 +147,7 @@ class partner_balance(report_sxw.rml_parse):
|
||||
else:
|
||||
return self.comma_me(new)
|
||||
|
||||
def preprocess(self, objects, data, ids):
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
# Transformation des date
|
||||
#
|
||||
#
|
||||
@@ -168,7 +168,7 @@ class partner_balance(report_sxw.rml_parse):
|
||||
self.date_lst_string =''
|
||||
if self.date_lst:
|
||||
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
|
||||
|
||||
|
||||
|
||||
## Compute Code
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
@@ -189,7 +189,7 @@ class partner_balance(report_sxw.rml_parse):
|
||||
"AND a.active", (data['form']['company_id'],))
|
||||
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
|
||||
|
||||
super(partner_balance, self).preprocess(objects, data, ids)
|
||||
super(partner_balance, self).set_context(objects, data, ids, report_type)
|
||||
|
||||
def lines(self,data):
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
@@ -138,7 +138,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
string_map = date_string + ','
|
||||
return string_map
|
||||
|
||||
def preprocess(self, objects, data, ids):
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
PARTNER_REQUEST = ''
|
||||
if (data['model'] == 'res.partner'):
|
||||
## Si on imprime depuis les partenaires
|
||||
@@ -160,7 +160,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
self.transform_period_into_date_array(data)
|
||||
elif data['form']['state'] == 'all':
|
||||
self.transform_both_into_date_array(data)
|
||||
|
||||
|
||||
self.date_lst_string = ''
|
||||
if self.date_lst:
|
||||
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
|
||||
@@ -182,12 +182,12 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
'AND a.type IN ' + self.ACCOUNT_TYPE + " " \
|
||||
"AND a.active", (data['form']['company_id'],))
|
||||
self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
|
||||
|
||||
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
partner_to_use = []
|
||||
|
||||
if self.date_lst and data['form']['soldeinit'] :
|
||||
|
||||
|
||||
self.cr.execute(
|
||||
"SELECT DISTINCT line.partner_id " \
|
||||
"FROM account_move_line AS line, account_account AS account " \
|
||||
@@ -202,7 +202,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
"AND account.active " ,
|
||||
(self.date_lst[0],self.date_lst[len(self.date_lst)-1],data['form']['company_id']))
|
||||
# else:
|
||||
#
|
||||
#
|
||||
# self.cr.execute(
|
||||
# "SELECT DISTINCT line.partner_id " \
|
||||
# "FROM account_move_line AS line, account_account AS account " \
|
||||
@@ -214,16 +214,16 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
# "AND account.company_id = %s " \
|
||||
# "AND account.active " ,
|
||||
# (data['form']['company_id']))
|
||||
|
||||
|
||||
res = self.cr.dictfetchall()
|
||||
|
||||
|
||||
for res_line in res:
|
||||
partner_to_use.append(res_line['partner_id'])
|
||||
new_ids = partner_to_use
|
||||
|
||||
|
||||
self.partner_ids = ','.join(map(str, new_ids))
|
||||
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
|
||||
super(third_party_ledger, self).preprocess(objects, data, new_ids)
|
||||
super(third_party_ledger, self).set_context(objects, data, new_ids, report_type)
|
||||
|
||||
def lines(self, partner,data):
|
||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
@@ -232,9 +232,9 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
RECONCILE_TAG = " "
|
||||
else:
|
||||
RECONCILE_TAG = "AND l.reconcile_id IS NULL"
|
||||
|
||||
|
||||
# if data['form']['soldeinit'] :
|
||||
#
|
||||
#
|
||||
# self.cr.execute(
|
||||
# "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \
|
||||
# "FROM account_move_line l " \
|
||||
@@ -271,8 +271,8 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
sum = r['debit'] - r['credit']
|
||||
r['progress'] = sum
|
||||
full_account.append(r)
|
||||
|
||||
return full_account
|
||||
|
||||
return full_account
|
||||
|
||||
def _sum_debit_partner(self, partner,data):
|
||||
|
||||
@@ -306,7 +306,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") " ,
|
||||
(partner.id,))
|
||||
|
||||
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
@@ -336,7 +336,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
else:
|
||||
result_tmp = result_tmp + 0.0
|
||||
|
||||
if self.date_lst_string:
|
||||
if self.date_lst_string:
|
||||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line " \
|
||||
@@ -345,7 +345,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") " ,
|
||||
(partner.id,))
|
||||
|
||||
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
@@ -386,7 +386,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
" " + RECONCILE_TAG + " " \
|
||||
"AND date IN (" + self.date_lst_string + ") "
|
||||
)
|
||||
|
||||
|
||||
contemp = self.cr.fetchone()
|
||||
if contemp != None:
|
||||
result_tmp = contemp[0] or 0.0
|
||||
@@ -419,7 +419,7 @@ class third_party_ledger(rml_parse.rml_parse):
|
||||
result_tmp = contemp[0] or 0.0
|
||||
else:
|
||||
result_tmp = result_tmp + 0.0
|
||||
|
||||
|
||||
if self.date_lst_string:
|
||||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
@@ -37,8 +37,29 @@ import wizard
|
||||
import photo_shadow
|
||||
from tools import config
|
||||
|
||||
def escape(s):
|
||||
return str(s or '').replace('<br/>','').decode('latin1','replace').encode('utf-8')
|
||||
def _to_unicode(s):
|
||||
try:
|
||||
return s.decode('utf-8')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.decode('latin')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.encode('ascii')
|
||||
except UnicodeError:
|
||||
return s
|
||||
|
||||
def _to_decode(s):
|
||||
try:
|
||||
return s.encode('utf-8')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.encode('latin')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.decode('ascii')
|
||||
except UnicodeError:
|
||||
return s
|
||||
|
||||
|
||||
class auction_catalog(report_rml):
|
||||
@@ -71,22 +92,22 @@ class auction_catalog(report_rml):
|
||||
# name emelment
|
||||
key = 'name'
|
||||
categ = doc.createElement(key)
|
||||
categ.appendChild(doc.createTextNode(escape(res[0]["name"])))
|
||||
categ.appendChild(doc.createTextNode(_to_decode(res[0]["name"])))
|
||||
catalog.appendChild(categ)
|
||||
|
||||
#Auctuion Date element
|
||||
categ = doc.createElement("AuctionDate1")
|
||||
categ.appendChild(doc.createTextNode(escape(res[0]['auction1'])))
|
||||
categ.appendChild(doc.createTextNode(_to_decode(res[0]['auction1'])))
|
||||
catalog.appendChild(categ)
|
||||
|
||||
# Action Date 2 element
|
||||
categ = doc.createElement("AuctionDate2")
|
||||
categ.appendChild(doc.createTextNode(escape(res[0]['auction2'])))
|
||||
categ.appendChild(doc.createTextNode(_to_decode(res[0]['auction2'])))
|
||||
catalog.appendChild(categ)
|
||||
|
||||
# promotion element
|
||||
promo = doc.createElement('promotion1')
|
||||
|
||||
|
||||
fp = file(config['addons_path']+'/auction/report/images/flagey_logo.jpg','r')
|
||||
file_data = fp.read()
|
||||
promo.appendChild(doc.createTextNode(base64.encodestring(file_data)))
|
||||
@@ -113,15 +134,15 @@ class auction_catalog(report_rml):
|
||||
products.appendChild(product)
|
||||
if cat['obj_desc']:
|
||||
infos = doc.createElement('infos')
|
||||
lines = re.split('<br/>|\n', unicode(cat['obj_desc'],'utf-8').encode('latin1'))
|
||||
lines = re.split('<br/>|\n', _to_unicode(cat['obj_desc']))
|
||||
for line in lines:
|
||||
xline = doc.createElement('info')
|
||||
xline.appendChild(doc.createTextNode(escape(line.decode('latin-1','replace').encode('utf-8'))))
|
||||
xline.appendChild(doc.createTextNode(_to_decode(line)))
|
||||
infos.appendChild(xline)
|
||||
product.appendChild(infos)
|
||||
if cat['lot_num']:
|
||||
lnum = doc.createElement('lot_num')
|
||||
lnum.appendChild(doc.createTextNode(escape(cat['lot_num'])))
|
||||
lnum.appendChild(doc.createTextNode(_to_decode(str(cat['lot_num']))))
|
||||
infos.appendChild(lnum)
|
||||
|
||||
if cat['image']:
|
||||
@@ -146,7 +167,7 @@ class auction_catalog(report_rml):
|
||||
|
||||
for key in ('lot_est1','lot_est2'):
|
||||
ref2 = doc.createElement(key)
|
||||
ref2.appendChild(doc.createTextNode( escape(cat[key] or 0.0)))
|
||||
ref2.appendChild(doc.createTextNode( _to_decode(str(cat[key] or 0.0))))
|
||||
product.appendChild(ref2)
|
||||
oldlength = length
|
||||
length += 2.0
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<!-- <stroke color="(0.6,0.3,0.1)"/>-->
|
||||
<!-- <fill color="(0.6,0.3,0.1)"/>-->
|
||||
|
||||
<image x="7cm" y="25cm" file="/home/tiny/terp/4.2/server/bin/addons/auction/report/images/aeko_logo.jpg"/>
|
||||
<image x="7cm" y="25cm" file="/home/pinky/code/terp/branches/extra_addons/trunk/auction/report/images/flagey_logo.jpg"/>
|
||||
<image x="7cm" y="25cm" file="addons/auction/report/images/aeko_logo.jpg"/>
|
||||
<image x="7cm" y="25cm" file="addons/auction/report/images/flagey_logo.jpg"/>
|
||||
<lines>1cm 3.0cm 20cm 3.0cm</lines>
|
||||
<setFont name="Helvetica" size="15"/>
|
||||
<drawCentredString x="105mm" y="2.2cm">Hotel des ventes Flagey</drawCentredString>
|
||||
@@ -30,7 +30,7 @@
|
||||
<pageTemplate id="first">
|
||||
<pageGraphics>
|
||||
<!-- <image x="1.0cm" y="27.3cm" file="/home/tiny/terp/4.2/server/bin/addons/auction/report/images/flagey_head.png"/>-->
|
||||
- <image x="1.0cm" y="27.3cm" file="/home/pinky/code/terp/branches/extra_addons/trunk/auction/report/images/flagey_logo.jpg"/>
|
||||
- <image x="1.0cm" y="27.3cm" file="addons/auction/report/images/flagey_logo.jpg"/>
|
||||
<drawRightString x="19.0cm" y="27.6cm"> Vente antiquitée le <xsl:value-of select="date:day-name(catalog/AuctionDate1)"/>  <xsl:value-of select="date:day-in-month(catalog/AuctionDate1)"/> <xsl:value-of select="date:month-name(catalog/AuctionDate1)"/>  <xsl:value-of select="date:year(catalog/AuctionDate1)"/></drawRightString>-->
|
||||
<lineMode width="1mm"/>
|
||||
<setFont name="Helvetica" size="26"/>
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">Invoiced to</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.partner_id.name or '']]</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.name or '']]</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.street or '']]</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.zip or '']]</para>
|
||||
@@ -122,6 +123,7 @@
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_invoice_id and o.sale_id.partner_invoice_id.country_id and o.sale_id.partner_invoice_id.country_id.name or '']]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.partner_id.name or '']]</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.name or '']]</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.street or '']]</para>
|
||||
<para style="terp_default_9">[[ o.sale_id and o.sale_id.partner_shipping_id and o.sale_id.partner_shipping_id.zip or '']]</para>
|
||||
|
||||
Reference in New Issue
Block a user