-
+
|
-
+
|
-
+
+
+
+ |
+
+
|
@@ -539,15 +517,15 @@
-
+
|
-
+
|
-
+
|
@@ -573,8 +551,5 @@
-
-
-
diff --git a/addons/account/report/overdue.py b/addons/account/report/overdue.py
index c37e2c98363..bf456e8256f 100644
--- a/addons/account/report/overdue.py
+++ b/addons/account/report/overdue.py
@@ -42,6 +42,7 @@ class Overdue(report_sxw.rml_parse):
'time' : time,
'adr_get' : self._adr_get,
'getLines' : self._lines_get,
+ 'tel_get' : self._tel_get,
})
def _adr_get(self, partner, type):
@@ -51,6 +52,20 @@ class Overdue(report_sxw.rml_parse):
adr_id = addresses and addresses[type] or False
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
+ def _tel_get(self,partner):
+ if not partner:
+ return False
+ res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
+ res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
+ addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice'])
+ adr_id = addresses and addresses['invoice'] or False
+ if adr_id:
+ adr=res_partner_address.read(self.cr, self.uid, [adr_id])[0]
+ return adr['phone']
+ else:
+ return partner.address and partner.address[0].phone or False
+ return False
+
def _lines_get(self, partner):
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
movelines = moveline_obj.search(self.cr, self.uid,
diff --git a/addons/account/report/overdue.rml b/addons/account/report/overdue.rml
index fc6dde92f50..f9f213f0d89 100644
--- a/addons/account/report/overdue.rml
+++ b/addons/account/report/overdue.rml
@@ -110,7 +110,7 @@
- Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at +32 81 81 37 00.
+ Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at [[ tel_get(company.partner_id) ]].
diff --git a/addons/account/report/rml_parse.py b/addons/account/report/rml_parse.py
new file mode 100755
index 00000000000..9f11a844260
--- /dev/null
+++ b/addons/account/report/rml_parse.py
@@ -0,0 +1,157 @@
+from report import report_sxw
+import xml.dom.minidom
+import os, time
+import osv
+import re
+import tools
+import pooler
+import re
+import sys
+
+
+class rml_parse(report_sxw.rml_parse):
+
+ def __init__(self, cr, uid, name, context):
+ super(rml_parse, self).__init__(cr, uid, name, context=None)
+ self.localcontext.update({
+ 'comma_me': self.comma_me,
+ 'format_date': self._get_and_change_date_format_for_swiss,
+ 'strip_name' : self._strip_name,
+ 'explode_name' : self._explode_name,
+ })
+
+ def comma_me(self,amount):
+ #print "#" + str(amount) + "#"
+ if not amount:
+ amount = 0.0
+ if type(amount) is float :
+ amount = str('%.2f'%amount)
+ else :
+ amount = str(amount)
+ if (amount == '0'):
+ return ' '
+ orig = amount
+ new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
+ if orig == new:
+ return new
+ else:
+ return self.comma_me(new)
+ def _ellipsis(self, string, maxlen=100, ellipsis = '...'):
+ ellipsis = ellipsis or ''
+ try:
+ return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen]
+ except Exception, e:
+ return False
+ def _strip_name(self, name, maxlen=50):
+ return self._ellipsis(name, maxlen, '...')
+
+ def _get_and_change_date_format_for_swiss (self,date_to_format):
+ date_formatted=''
+ if date_to_format:
+ date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
+ return date_formatted
+
+ def _explode_name(self,chaine,length):
+ # We will test if the size is less then account
+ full_string = ''
+ if (len(str(chaine)) <= length):
+ return chaine
+ #
+ else:
+ chaine = unicode(chaine,'utf8').encode('iso-8859-1')
+ rup = 0
+ for carac in chaine:
+ rup = rup + 1
+ if rup == length:
+ full_string = full_string + '\n'
+ full_string = full_string + carac
+ rup = 0
+ else:
+ full_string = full_string + carac
+
+ return full_string
+
+ def makeAscii(self,str):
+ try:
+ Stringer = str.encode("utf-8")
+ except UnicodeDecodeError:
+ try:
+ Stringer = str.encode("utf-16")
+ except UnicodeDecodeError:
+ print "UTF_16 Error"
+ Stringer = str
+ else:
+ return Stringer
+ else:
+ return Stringer
+ return Stringer
+ def explode_this(self,chaine,length):
+ #chaine = self.repair_string(chaine)
+ chaine = rstrip(chaine)
+ ast = list(chaine)
+ i = length
+ while i <= len(ast):
+ ast.insert(i,'\n')
+ i = i + length
+ chaine = str("".join(ast))
+ return chaine
+ def repair_string(self,chaine):
+ ast = list(chaine)
+ UnicodeAst = []
+ _previouslyfound = False
+ i = 0
+ #print str(ast)
+ while i < len(ast):
+ elem = ast[i]
+ try:
+ Stringer = elem.encode("utf-8")
+ except UnicodeDecodeError:
+ to_reencode = elem + ast[i+1]
+ print str(to_reencode)
+ Good_char = to_reencode.decode('utf-8')
+ UnicodeAst.append(Good_char)
+ i += i +2
+ else:
+ UnicodeAst.append(elem)
+ i += i + 1
+
+
+ return "".join(UnicodeAst)
+
+ def ReencodeAscii(self,str):
+ print sys.stdin.encoding
+ try:
+ Stringer = str.decode("ascii")
+ except UnicodeEncodeError:
+ print "REENCODING ERROR"
+ return str.encode("ascii")
+ except UnicodeDecodeError:
+ print "DECODING ERROR"
+ return str.encode("ascii")
+
+ else:
+ print Stringer
+ return Stringer
+
+
+ # def _add_header(self, node):
+ # rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read()
+ # head_dom = xml.dom.minidom.parseString(rml_head)
+ # #for frame in head_dom.getElementsByTagName('frame'):
+ # # frame.parentNode.removeChild(frame)
+ # node2 = head_dom.documentElement
+ # for tag in node2.childNodes:
+ # if tag.nodeType==tag.ELEMENT_NODE:
+ # found = self._find_node(node, tag.localName)
+ # # rml_frames = found.getElementsByTagName('frame')
+ # if found:
+ # if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'):
+ # found.appendChild(tag)
+ # else:
+ # found.parentNode.replaceChild(tag, found)
+ # # for frame in rml_frames:
+ # # tag.appendChild(frame)
+ # return True
+
+
+
diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py
old mode 100644
new mode 100755
index 01bf81a6aed..445ca968878
--- a/addons/account/report/tax_report.py
+++ b/addons/account/report/tax_report.py
@@ -1,9 +1,6 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -30,92 +27,206 @@
import time
import pooler
+import rml_parse
+import copy
from report import report_sxw
+import pdb
+import re
-class tax_report(report_sxw.rml_parse):
+class tax_report(rml_parse.rml_parse):
+ _name = 'report.account.vat.declaration'
+ def __init__(self, cr, uid, name, context):
+ super(tax_report, self).__init__(cr, uid, name, context)
+ self.localcontext.update({
+ 'time': time,
+ 'get_period': self._get_period,
+ 'get_codes': self._get_codes,
+ 'get_general': self._get_general,
+ 'get_company': self._get_company,
+ 'get_currency': self._get_currency,
+ 'get_lines' : self._get_lines,
+ })
- def __init__(self, cr, uid, name, context):
- super(tax_report, self).__init__(cr, uid, name, context)
- self.localcontext.update({
- 'time': time,
- 'get_period': self._get_period,
- 'get_codes': self._get_codes,
- 'get_general': self._get_general,
- 'get_company': self._get_company,
- 'get_currency': self._get_currency,
- })
+
+ def comma_me(self,amount):
+
+ if type(amount) is float :
+ amount = str('%.2f'%amount)
+ else :
+ amount = str(amount)
+ if (amount == '0'):
+ return ' '
+ orig = amount
+ new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
+ if orig == new:
+ return new
+ else:
+ return self.comma_me(new)
+ def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0):
+ res = self._get_codes(based_on,parent,level,period_list)
+ res = self._add_codes(based_on,res,period_list)
+
+ i = 0
+ top_result = []
+
+ while i < len(res):
+
+ res_dict = { 'code' : res[i][1].code,
+ 'name' : res[i][1].name,
+ 'debit' : 0,
+ 'credit' : 0,
+ 'tax_amount' : res[i][1].sum_period,
+ 'type' : 1,
+ 'level' : res[i][0],
+ 'pos' : 0
+ }
+
+ top_result.append(res_dict)
+ res_general = self._get_general(res[i][1].id,period_list,company_id,based_on)
+ ind_general = 0
+ while ind_general < len(res_general) :
+ res_general[ind_general]['type'] = 2
+ res_general[ind_general]['pos'] = 0
+ res_general[ind_general]['level'] = res_dict['level'] + ' '
+ top_result.append(res_general[ind_general])
+ ind_general+=1
+ i+=1
+ #array_result = self.sort_result(top_result)
+ return top_result
+ #return array_result
- def _add_header(self, node):
- return True
+ def _get_period(self, period_id):
+ return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
- def _get_period(self, period_id):
- return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
+ def _get_general(self, tax_code_id,period_list ,company_id, based_on):
+ res=[]
+ period_sql_list = ','.join(map(str, period_list[0][2]))
+
+ if based_on == 'payments':
+ self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
+ SUM(line.debit) AS debit, \
+ SUM(line.credit) AS credit, \
+ COUNT(*) AS count, \
+ account.id AS account_id, \
+ account.name AS name, \
+ account.code AS code \
+ FROM account_move_line AS line, \
+ account_account AS account, \
+ account_move AS move \
+ LEFT JOIN account_invoice invoice ON \
+ (invoice.move_id = move.id) \
+ WHERE line.state<>%s \
+ AND line.tax_code_id = %d \
+ AND line.account_id = account.id \
+ AND account.company_id = %d \
+ AND move.id = line.move_id \
+ AND ((invoice.state = %s) \
+ OR (invoice.id IS NULL)) \
+ GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
+ company_id, 'paid'))
- def _get_general(self, tax_code_id, period_id, company_id, based_on):
- res=[]
- if based_on == 'payments':
- self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
- SUM(line.debit) AS debit, \
- SUM(line.credit) AS credit, \
- COUNT(*) AS count, \
- account.id AS account_id \
- FROM account_move_line AS line, \
- account_account AS account, \
- account_move AS move \
- LEFT JOIN account_invoice invoice ON \
- (invoice.move_id = move.id) \
- WHERE line.state<>%s \
- AND line.period_id = %d \
- AND line.tax_code_id = %d \
- AND line.account_id = account.id \
- AND account.company_id = %d \
- AND move.id = line.move_id \
- AND ((invoice.state = %s) \
- OR (invoice.id IS NULL)) \
- GROUP BY account.id', ('draft', period_id, tax_code_id,
- company_id, 'paid'))
- else :
- self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
- SUM(line.debit) AS debit, \
- SUM(line.credit) AS credit, \
- COUNT(*) AS count, \
- account.id AS account_id \
- FROM account_move_line AS line, \
- account_account AS account \
- WHERE line.state <> %s \
- AND line.period_id = %d \
- AND line.tax_code_id = %d \
- AND line.account_id = account.id \
- AND account.company_id = %d \
- AND account.active \
- GROUP BY account.id', ('draft', period_id, tax_code_id,
- company_id))
- res = self.cr.dictfetchall()
- i = 0
- while i %s \
+ AND line.tax_code_id = %d \
+ AND line.account_id = account.id \
+ AND account.company_id = %d \
+ AND account.active \
+ GROUP BY account.id,account.name,account.code', ('draft',tax_code_id,
+ company_id))
+ res = self.cr.dictfetchall()
+ #AND line.period_id IN ('+ period_sql_list +') \
+
+ i = 0
+ while i= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ):
+ tot_elem = copy.copy(accounts[bcl_rup_ind])
+ res_tot = { 'code' : accounts[bcl_rup_ind]['code'],
+ 'name' : '',
+ 'debit' : 0,
+ 'credit' : 0,
+ 'tax_amount' : accounts[bcl_rup_ind]['tax_amount'],
+ 'type' : accounts[bcl_rup_ind]['type'],
+ 'level' : 0,
+ 'pos' : 0
+ }
+
+ if res_tot['type'] == 1:
+ # on change le type pour afficher le total
+ res_tot['type'] = 2
+ result_accounts.append(res_tot)
+ bcl_current_level = accounts[bcl_rup_ind]['level']
+ bcl_rup_ind -= 1
+
+ old_level = account_elem['level']
+ result_accounts.append(account_elem)
+ ind+=1
+
+
+ return result_accounts
+
report_sxw.report_sxw('report.account.vat.declaration', 'account.tax.code',
- 'addons/account/report/tax_report.rml', parser=tax_report, header=False)
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ 'addons/account/report/tax_report.rml', parser=tax_report, header=False)
diff --git a/addons/account/report/tax_report.rml b/addons/account/report/tax_report.rml
old mode 100644
new mode 100755
index ab2d3a0c24a..cd8ee532948
--- a/addons/account/report/tax_report.rml
+++ b/addons/account/report/tax_report.rml
@@ -2,7 +2,34 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ company.name ]]
+ Tax Report
+
+
+
+ [[ time.strftime("%Y-%m-%d %H:%M", time.localtime()) ]]
+ Page
+
+
+
+
+ 1cm 27.7cm 20cm 27.7cm
+
+
+
@@ -20,10 +47,21 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -36,131 +74,145 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
|
-
-
-
+ Code
|
- Tax Report
+ Débit
|
- Period: [[ get_period(data['form']['period_id']) ]]
+ Crédit
+ |
+
+ Solde
|
+
+
- |
- [[ get_company(data['form']) ]]
- |
-
-
-
-
- |
-
- Currency: [[ get_currency(data['form']) ]]
- |
+
+ [[ repeatIn(get_lines(data['form']['based_on'],data['form']['periods'],data['form']['company_id']), 'o') ]]
+
+ [[ o['level'] ]]
+ [[o['type']==1 and ( setTag('para','para',{'fontName':'Helvetica'}))]]
+ [[ setTag('tr','tr',{'style':'TrLevel'+str(o['level']), 'paraStyle':('Level'+str(o['level']))}) ]]
+ [[ o['code'] ]] [[ o['name'] ]]
+
+ |
+
+ [[o['type']==2 and (o['debit']) ]]
+ |
+
+ [[o['type']==2 and (o['credit']) ]]
+ |
+
+ [[ o['tax_amount'] ]]
+ |
+
-
-
-
-
- Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]
-
-
-
-
-
- |
- Tax Code / Account
- |
-
- General Account
- |
-
- Debit
- |
-
- Credit
- |
-
- Tax Amount
- |
-
-
-
-
-
-
- [[ repeatIn(get_codes(data['form']['period_id'], data['form']['based_on']), 'o') ]]
-
-
- |
- [[ o[0] ]] [[ o[1].code ]] - [[ o[1].name ]]
- |
-
-
-
-
- |
-
-
-
-
- |
-
- [[ o[1].sum_period and ('%.2f' % o[1].sum_period) or '' ]]
- |
-
-
-
-
- |
- [[repeatIn(get_general(o[1], data['form']['period_id'], data['form']['company_id'], data['form']['based_on']), 'g') ]]
- |
-
- [[ g['account'].code ]] - [[ g['account'].name ]]
- |
-
- [[ g['debit'] and '%.2f' % g['debit'] or '' ]]
- |
-
- [[ g['credit'] and '%.2f' % g['credit'] or '' ]]
- |
-
- [[ g['tax_amount'] and '%.2f' % g['tax_amount'] or '' ]]
- |
-
-
-
-
-
-
+
+
+
+
-
diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py
old mode 100644
new mode 100755
index bf060555e7e..c8bda2a3045
--- a/addons/account/report/third_party_ledger.py
+++ b/addons/account/report/third_party_ledger.py
@@ -1,9 +1,6 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -30,153 +27,364 @@
import pooler
import time
+import re
+import rml_parse
+import datetime
from report import report_sxw
-class third_party_ledger(report_sxw.rml_parse):
- def __init__(self, cr, uid, name, context):
- super(third_party_ledger, self).__init__(cr, uid, name, context)
- self.localcontext.update( {
- 'time': time,
- 'lines': self.lines,
- 'sum_debit_partner': self._sum_debit_partner,
- 'sum_credit_partner': self._sum_credit_partner,
- 'sum_debit': self._sum_debit,
- 'sum_credit': self._sum_credit,
- 'get_company': self._get_company,
- 'get_currency': self._get_currency,
- })
+class third_party_ledger(rml_parse.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ self.date_lst = []
+ self.date_lst_string = ''
+ super(third_party_ledger, self).__init__(cr, uid, name, context)
+ self.localcontext.update( {
+ 'time': time,
+ 'lines': self.lines,
+ 'sum_debit_partner': self._sum_debit_partner,
+ 'sum_credit_partner': self._sum_credit_partner,
+ 'sum_debit': self._sum_debit,
+ 'sum_credit': self._sum_credit,
+ 'get_company': self._get_company,
+ 'get_currency': self._get_currency,
+ 'comma_me' : self.comma_me,
+ })
+ def date_range(self,start,end):
+ start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
+ end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d")))
+ full_str_date = []
+ #
+ r = (end+datetime.timedelta(days=1)-start).days
+ #
+ date_array = [start+datetime.timedelta(days=i) for i in range(r)]
+ for date in date_array:
+ full_str_date.append(str(date))
+ return full_str_date
+
+ #
+ def transform_period_into_date_array(self,data):
+ ## Get All Period Date
+ if not data['form']['periods'][0][2] :
+ periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
+ else:
+ periods_id = data['form']['periods'][0][2]
+ date_array = []
+ for period_id in periods_id:
+ period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
+ date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
+ self.date_lst = date_array
+ self.date_lst.sort()
+
+ def transform_date_into_date_array(self,data):
+ return_array = self.date_range(data['form']['date1'],data['form']['date2'])
+ self.date_lst = return_array
+ self.date_lst.sort()
- def preprocess(self, objects, data, ids):
- account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
- line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='line',
- context={'fiscalyear': data['form']['fiscalyear'],'state':data['form']['state']})
- self.cr.execute(
- "SELECT DISTINCT line.partner_id " \
- "FROM account_move_line AS line, account_account AS account " \
- "WHERE line.partner_id IS NOT NULL " \
- "AND line.date >= %s " \
- "AND line.date <= %s " \
- "AND " + line_query + " " \
- "AND line.account_id = account.id " \
- "AND account.company_id = %d " \
- "AND account.active",
- (data['form']['date1'], data['form']['date2'],
- data['form']['company_id']))
- new_ids = [id for (id,) in self.cr.fetchall()]
- self.cr.execute(
- "SELECT a.id " \
- "FROM account_account a " \
- "LEFT JOIN account_account_type t " \
- "ON (a.type=t.code) " \
- "WHERE t.partner_account=TRUE " \
- "AND a.company_id = %d " \
- "AND a.active", (data['form']['company_id'],))
- self.account_ids = ','.join([str(a) for (a,) in self.cr.fetchall()])
- 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)
+ def comma_me(self,amount):
+ if type(amount) is float :
+ amount = str('%.2f'%amount)
+ else :
+ amount = str(amount)
+ if (amount == '0'):
+ return ' '
+ orig = amount
+ new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
+ if orig == new:
+ return new
+ else:
+ return self.comma_me(new)
+ def special_map(self):
+ string_map = ''
+ for date_string in self.date_lst:
+ string_map = date_string + ','
+ return string_map
+
+ def preprocess(self, objects, data, ids):
+ PARTNER_REQUEST = ''
+ if (data['model'] == 'res.partner'):
+ print"data['model']",data['model']
+ ## Si on imprime depuis les partenaires
+ if ids:
+ PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")"
+ # Transformation des date
+ #
+ #
+ if data['form'].has_key('fiscalyear'):
+ self.transform_period_into_date_array(data)
+ else:
+ self.transform_date_into_date_array(data)
+ ##
+ self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
+ #
+ #new_ids = [id for (id,) in self.cr.fetchall()]
+ if data['form']['result_selection'] == 'supplier':
+ ACCOUNT_TYPE = "AND a.type='payable' "
+ elif data['form']['result_selection'] == 'customer':
+ ACCOUNT_TYPE = "AND a.type='receivable' "
+ elif data['form']['result_selection'] == 'all':
+ ACCOUNT_TYPE = "AND (a.type='receivable' OR a.type='payable') "
- def lines(self, partner):
- account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
- line_query = account_move_line_obj._query_get(self.cr, self.uid, obj='l',
- context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
- self.cr.execute(
- "SELECT l.date, j.code, l.ref, l.name, l.debit, l.credit " \
- "FROM account_move_line l " \
- "LEFT JOIN account_journal j " \
- "ON (l.journal_id = j.id) " \
- "WHERE l.partner_id = %d " \
- "AND l.account_id IN (" + self.account_ids + ") " \
- "AND l.date >= %s " \
- "AND l.date <= %s "
- "AND " + line_query + " " \
- "ORDER BY l.id",
- (partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
- res = self.cr.dictfetchall()
- sum = 0.0
- for r in res:
- sum += r['debit'] - r['credit']
- r['progress'] = sum
- return res
+ self.cr.execute(
+ "SELECT a.id " \
+ "FROM account_account a " \
+ "LEFT JOIN account_account_type t " \
+ "ON (a.type=t.code) " \
+ "WHERE t.partner_account=TRUE " \
+ "AND a.company_id = %d " \
+ " " + 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 data['form']['soldeinit'] :
+ self.cr.execute(
+ "SELECT DISTINCT line.partner_id " \
+ "FROM account_move_line AS line, account_account AS account " \
+ "WHERE line.partner_id IS NOT NULL " \
+ "AND line.account_id = account.id " \
+ "AND line.date < %s " \
+ "AND line.reconcile_id IS NULL " \
+# "AND line.account_id IN (" + self.account_ids + ") " \
+ " " + PARTNER_REQUEST + " " \
+ "AND account.company_id = %d " \
+ "AND account.active " ,
+ (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 " \
+ "WHERE line.partner_id IS NOT NULL " \
+ "AND line.account_id = account.id " \
+ "AND line.date IN (" + self.date_lst_string + ") " \
+# "AND line.account_id IN (" + self.account_ids + ") " \
+ " " + PARTNER_REQUEST + " " \
+ "AND account.company_id = %d " \
+ "AND account.active " ,
+ (data['form']['company_id']))
+ res = self.cr.dictfetchall()
+ for res_line in res:
+ partner_to_use.append(res_line['partner_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)
- def _sum_debit_partner(self, partner):
- account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
- line_query = account_move_line_obj._query_get(self.cr, self.uid,
- obj='account_move_line',
- context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
- self.cr.execute(
- "SELECT sum(debit) " \
- "FROM account_move_line " \
- "WHERE partner_id = %d " \
- "AND account_id IN (" + self.account_ids + ") " \
- "AND date >= %s " \
- "AND date <= %s " \
- "AND " + line_query,
- (partner.id, self.datas['form']['date1'], self.datas['form']['date2']))
- return self.cr.fetchone()[0] or 0.0
-
- def _sum_credit_partner(self, partner):
- account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
- line_query = account_move_line_obj._query_get(self.cr, self.uid,
- obj='account_move_line',
- context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
- self.cr.execute(
- "SELECT sum(credit) " \
- "FROM account_move_line " \
- "WHERE partner_id=%d " \
- "AND account_id IN (" + self.account_ids + ") " \
- "AND date >= %s " \
- "AND date <= %s " \
- "AND " + line_query,
- (partner.id, self.datas["form"]["date1"], self.datas["form"]["date2"]))
- return self.cr.fetchone()[0] or 0.0
-
- def _sum_debit(self):
- if not self.ids:
- return 0.0
- account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
- line_query = account_move_line_obj._query_get(self.cr, self.uid,
- obj='account_move_line',
- context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
- self.cr.execute(
- "SELECT sum(debit) " \
- "FROM account_move_line " \
- "WHERE partner_id IN (" + self.partner_ids + ") " \
- "AND account_id IN (" + self.account_ids + ") " \
- "AND date >= %s " \
- "AND date <= %s " \
- "AND " + line_query,
- (self.datas['form']['date1'], self.datas['form']['date2']))
- return self.cr.fetchone()[0] or 0.0
-
- def _sum_credit(self):
- if not self.ids:
- return 0.0
- account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
- line_query = account_move_line_obj._query_get(self.cr, self.uid,
- obj='account_move_line',
- context={'fiscalyear': self.datas['form']['fiscalyear'],'state':self.datas['form']['state']})
- self.cr.execute(
- "SELECT sum(credit) " \
- "FROM account_move_line " \
- "WHERE partner_id IN (" + self.partner_ids + ") " \
- "AND account_id IN (" + self.account_ids + ") " \
- "AND date >= %s " \
- "AND date <= %s " \
- "AND " + line_query,
- (self.datas['form']['date1'], self.datas['form']['date2']))
- return self.cr.fetchone()[0] or 0.0
+ def lines(self, partner,data):
+ account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
+ full_account = []
+ if data['form']['reconcil'] :
+ 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 " \
+ "LEFT JOIN account_journal j " \
+ "ON (l.journal_id = j.id) " \
+ "WHERE l.partner_id = %d " \
+# "AND l.account_id IN (" + self.account_ids + ") " \
+ "AND l.date < %s " \
+ "AND l.reconcile_id IS NULL "
+ "ORDER BY l.id",
+ (partner.id, self.date_lst[0]))
+ res = self.cr.dictfetchall()
+ sum = 0.0
+ for r in res:
+ sum = r['debit'] - r['credit']
+ r['progress'] = sum
+ full_account.append(r)
+
+ self.cr.execute(
+ "SELECT l.id,l.date,j.code, l.ref, l.name, l.debit, l.credit " \
+ "FROM account_move_line l " \
+ "LEFT JOIN account_journal j " \
+ "ON (l.journal_id = j.id) " \
+ "WHERE l.partner_id = %d " \
+# "AND l.account_id IN (" + self.account_ids + ") " \
+ "AND l.date IN (" + self.date_lst_string + ") " \
+ " " + RECONCILE_TAG + " "\
+ "ORDER BY l.id",
+ (partner.id,))
+ res = self.cr.dictfetchall()
+ sum = 0.0
+ for r in res:
+ sum = r['debit'] - r['credit']
+ r['progress'] = sum
+ full_account.append(r)
+
+ return full_account
- def _get_company(self, form):
- return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
+ def _sum_debit_partner(self, partner,data):
+
+ account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
+ result_tmp = 0.0
+ if data['form']['reconcil'] :
+ RECONCILE_TAG = " "
+ else:
+ RECONCILE_TAG = "AND reconcile_id IS NULL"
+ if data['form']['soldeinit'] :
+ self.cr.execute(
+ "SELECT sum(debit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id = %d " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ "AND reconcile_id IS NULL " \
+ "AND date < %s " ,
+ (partner.id, self.date_lst[0],))
+ contemp = self.cr.fetchone()
+ if contemp != None:
+ result_tmp = contemp[0] or 0.0
+ else:
+ result_tmp = result_tmp + 0.0
+
- def _get_currency(self, form):
- return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
+ self.cr.execute(
+ "SELECT sum(debit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id = %d " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ " " + 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
+ else:
+ result_tmp = result_tmp + 0.0
+ return result_tmp
+
+ def _sum_credit_partner(self, partner,data):
+ account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
+ result_tmp = 0.0
+ if data['form']['reconcil'] :
+ RECONCILE_TAG = " "
+ else:
+ RECONCILE_TAG = "AND reconcile_id IS NULL"
+ if data['form']['soldeinit'] :
+ self.cr.execute(
+ "SELECT sum(credit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id=%d " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ "AND reconcile_id IS NULL " \
+ "AND date < %s " ,
+ (partner.id,self.date_lst[0],))
+ contemp = self.cr.fetchone()
+ if contemp != None:
+ result_tmp = contemp[0] or 0.0
+ else:
+ result_tmp = result_tmp + 0.0
+
+ self.cr.execute(
+ "SELECT sum(credit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id=%d " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ " " + 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
+ else:
+ result_tmp = result_tmp + 0.0
+ return result_tmp
+
+ def _sum_debit(self,data):
+ if not self.ids:
+ return 0.0
+ account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
+ result_tmp = 0.0
+ if data['form']['reconcil'] :
+ RECONCILE_TAG = " "
+ else:
+ RECONCILE_TAG = "AND reconcile_id IS NULL"
+ if data['form']['soldeinit'] :
+ self.cr.execute(
+ "SELECT sum(debit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id IN (" + self.partner_ids + ") " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ "AND reconcile_id IS NULL " \
+ "AND date < %s " ,
+ (self.date_lst[0],))
+ contemp = self.cr.fetchone()
+ if contemp != None:
+ result_tmp = contemp[0] or 0.0
+ else:
+ result_tmp = result_tmp + 0.0
+
+ self.cr.execute(
+ "SELECT sum(debit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id IN (" + self.partner_ids + ") " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ " " + RECONCILE_TAG + " " \
+ "AND date IN (" + self.date_lst_string + ") "
+ )
+
+ contemp = self.cr.fetchone()
+ if contemp != None:
+ result_tmp = contemp[0] or 0.0
+ else:
+ result_tmp = result_tmp + 0.0
+
+ return result_tmp
+
+
+ def _sum_credit(self,data):
+ if not self.ids:
+ return 0.0
+ account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
+ result_tmp = 0.0
+ if data['form']['reconcil'] :
+ RECONCILE_TAG = " "
+ else:
+ RECONCILE_TAG = "AND reconcile_id IS NULL"
+ if data['form']['soldeinit'] :
+ self.cr.execute(
+ "SELECT sum(credit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id IN (" + self.partner_ids + ") " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ "AND reconcile_id IS NULL " \
+ "AND date < %s " ,
+ (self.date_lst[0],))
+ contemp = self.cr.fetchone()
+ if contemp != None:
+ result_tmp = contemp[0] or 0.0
+ else:
+ result_tmp = result_tmp + 0.0
+ self.cr.execute(
+ "SELECT sum(credit) " \
+ "FROM account_move_line " \
+ "WHERE partner_id IN (" + self.partner_ids + ") " \
+# "AND account_id IN (" + self.account_ids + ") " \
+ " " + RECONCILE_TAG + " " \
+ "AND date IN (" + self.date_lst_string + ") "
+ )
+ contemp = self.cr.fetchone()
+ if contemp != None:
+ result_tmp = contemp[0] or 0.0
+ else:
+ result_tmp = result_tmp + 0.0
+
+ return result_tmp
+
+ def _get_company(self, form):
+ return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).name
+
+ def _get_currency(self, form):
+ return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name
+
report_sxw.report_sxw('report.account.third_party_ledger', 'res.partner',
- 'addons/account/report/third_party_ledger.rml',parser=third_party_ledger,
- header=False)
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ 'addons/account/report/third_party_ledger.rml',parser=third_party_ledger,
+ header=False)
diff --git a/addons/account/report/third_party_ledger.rml b/addons/account/report/third_party_ledger.rml
old mode 100644
new mode 100755
index a44bbb4f2ca..b8967de5d2c
--- a/addons/account/report/third_party_ledger.rml
+++ b/addons/account/report/third_party_ledger.rml
@@ -2,8 +2,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [[ company.name ]]
+ Third Party Ledger [[ data['form']['result_selection'] == 'customer' and '/ Débiteur' ]] [[ data['form']['result_selection'] == 'supplier' and '/ Créancier' ]] [[ data['form']['result_selection'] == 'all' and '/ Créancier et Débiteur' ]]
+
+
+
+
+
+ [[ time.strftime("%Y-%m-%d %H:%M", time.localtime()) ]]
+ Page
+
+
+
+
+ 1cm 27.7cm 20cm 27.7cm
+
+
+
+
+
@@ -13,227 +46,194 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+ [[ data['form']['page_split'] == True or removeParentNode('para') ]]
+ [[ repeatIn(objects, 'p') ]] [[ setLang(p.partner_id.lang) ]]
+
+
+
|
-
-
-
- |
-
- Third party ledger
- |
-
- From [[ formatLang(data['form']['date1'], date=True) ]]
- to [[ formatLang(data['form']['date2'], date=True) ]]
- |
-
-
- |
- [[ get_company(data['form']) ]]
- |
-
- Complete
- |
-
- Currency: [[ get_currency(data['form']) ]]
- |
-
+
+ Date
+
+
+ JNRL
+ |
+
+ Ref.
+ |
+
+ Entry label
+ |
+
+ Debit
+ |
+
+ Credit
+ |
+
+ Balance
+ |
+
+
+
+
+
+
+
+ |
+ Balance brought forward
+ |
+
+ [[ (sum_debit(data)) ]]
+ |
+
+ [[ (sum_credit(data)) ]]
+ |
+
+ [[ (sum_debit(data) - sum_credit(data)) ]]
+ |
+
+
+ |
+
+
+
+
+ [[ data['form']['page_split'] == False or removeParentNode('para') ]]
+ [[ repeatIn(objects, 'p') ]]
+
+
+
+ |
+ [[ p.ref ]] - [[ p.name ]]
+ |
+
+
+ |
+
+ [[ (sum_debit_partner(p,data)) ]]
+ |
+
+ [[ (sum_credit_partner(p,data)) ]]
+ |
+
+ [[ (sum_debit_partner(p,data) - sum_credit_partner(p,data)) ]]
+ |
+
+
+
+
+ |
+ [[ repeatIn(lines(p,data), 'line') ]][[ line['date'] ]]
+ |
+
+ [[ line['code'] ]]
+ |
+
+ [[ line['ref'] ]]
+ |
+
+ [[ line['name'] ]]
+ |
+
+ [[ (line['debit']) or '' ]]
+ |
+
+ [[ (line['credit']) or '' ]]
+ |
+
+ [[ (line['progress']) or '' ]]
+ |
+
+
+
+ |
+
-
-
-
- Printing date: [[ formatLang(time.strftime('%Y-%m-%d'), date=True) ]] at [[ time.strftime('%H:%M:%S') ]]
-
-
-
-
-
- |
- Date
- |
-
- J. code
- |
-
- Voucher Nb
- |
-
- Entry label
- |
-
- Debit
- |
-
- Credit
- |
-
- Progressive balance
- |
-
-
-
-
-
-
- [[ repeatIn(objects, 'p') ]]
- [[ p.ref ]] [[ p.name ]]
-
-
- |
- [[ repeatIn(lines(p), 'line') ]][[ formatLang(line['date'], date=True) ]]
- |
-
- [[ line['code'] ]]
- |
-
- [[ line['ref'] ]]
- |
-
- [[ line['name'] ]]
- |
-
- [[ formatLang(line['debit']) ]]
- |
-
- [[ formatLang(line['credit']) ]]
- |
-
- [[ formatLang(line['progress']) ]]
- |
-
-
-
-
- |
- Total for [[ p.ref ]]
-
-
-
- |
-
- [[ formatLang(sum_debit_partner(p)) ]]
- |
-
- [[ formatLang(sum_credit_partner(p)) ]]
- |
-
- [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]]
- |
-
-
-
-
-
-
-
-
-
-
-
- |
- Balance brought forward
- |
-
- [[ formatLang(sum_debit()) ]]
- |
-
- [[ formatLang(sum_credit()) ]]
- |
-
- [[ formatLang((sum_debit() - sum_credit())) ]]
- |
-
-
-
-
-
+
+
+
+
-
diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py
index 90eeaf44256..f038ce2bd68 100644
--- a/addons/account/wizard/wizard_account_balance_report.py
+++ b/addons/account/wizard/wizard_account_balance_report.py
@@ -1,9 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -30,37 +28,117 @@
import wizard
import pooler
+import time
+
+report_type = '''
+'''
+
dates_form = '''
'''
dates_fields = {
+ 'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
+ 'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
+ 'display_account':{'string':"Display accounts",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}
+}
+
+
+period_form = '''
+'''
+
+
+
+period_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
- 'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
+ 'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}
}
+account_form = '''
+'''
+
+account_fields = {
+ 'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
+}
+
+
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
+ periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
- data['form']['target_move'] = False
- data['form']['state']='all'
- if context.has_key('target_move'):
- data['form']['target_move'] = context['target_move']
+ data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
+ data['form']['display_account']='bal_all'
return data['form']
+ def _get_defaults_fordate(self, cr, uid, data, context):
+ data['form']['display_account']='bal_all'
+ return data['form']
+
+
+ def _check_path(self, cr, uid, data, context):
+ if data['model'] == 'account.account':
+ return 'checktype'
+ else:
+ return 'account_selection'
+
+
+ def _check_date(self, cr, uid, data, context):
+ sql = """
+ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
+ cr.execute(sql)
+ res = cr.dictfetchall()
+ if res:
+ if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
+ raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
+ else:
+ return 'report'
+
+ else:
+ raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
+
states = {
+
'init': {
- 'actions': [_get_defaults],
- 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
+ 'actions': [],
+ 'result': {'type':'choice','next_state':_check_path}
},
+ 'account_selection': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':account_form,'fields':account_fields, 'state':[('end','Cancel'),('checktype','Print')]}
+ },
+ 'checktype': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
+ },
+ 'with_period': {
+ 'actions': [_get_defaults],
+ 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]}
+ },
+ 'with_date': {
+ 'actions': [_get_defaults_fordate],
+ 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
+ },
+ 'checkdate': {
+ 'actions': [],
+ 'result': {'type':'choice','next_state':_check_date}
+ },
+
'report': {
'actions': [],
'result': {'type':'print', 'report':'account.account.balance', 'state':'end'}
@@ -69,6 +147,3 @@ class wizard_report(wizard.interface):
wizard_report('account.account.balance.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_aged_trial_balance.py b/addons/account/wizard/wizard_aged_trial_balance.py
old mode 100644
new mode 100755
index bf458e03069..ce95c2c8ab1
--- a/addons/account/wizard/wizard_aged_trial_balance.py
+++ b/addons/account/wizard/wizard_aged_trial_balance.py
@@ -1,9 +1,7 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -34,78 +32,79 @@ import datetime
import pooler
from mx.DateTime import *
-from tools.translate import _
_aged_trial_form = """
"""
_aged_trial_fields = {
- 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
- 'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
- 'help': 'Keep empty for all open fiscal year'},
- 'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
- 'sorting_on':{'string': 'Sorting On', 'type': 'selection', 'selection': [('partner','By Partner Name (asc)'), ('amount','By Amount (desc)')],'required': True, 'default': lambda *a:'partner'},
- 'computation':{'string': 'Computational Method', 'type': 'selection', 'selection': [("\'receivable\'",'On Receivables Only'), ("\'payable\'",'On Payables Only'), ("\'receivable\',\'payable\'",'On Receivables & Payables')], 'required': True, 'default': lambda *a:"\'receivable\'"},
- 'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
-}
+ 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
+ 'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30},
+ 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
+ 'result_selection':{'string':"Display partner",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]},
+ 'direction_selection':{'string':"Display aged balance of",'type':'selection','selection':[('past','Due amount'),('future','Not due amount')]},
+ }
def _calc_dates(self, cr, uid, data, context):
- res = {}
- period_length = data['form']['period_length']
- if period_length<=0:
- raise wizard.except_wizard(_('UserError'), _('You must enter a period length that cannot be 0 or below !'))
- start = now()
- for i in range(5)[::-1]:
- stop = start-RelativeDateTime(days=period_length)
- res[str(i)] = {
- 'name' : str((5-i)*period_length)+' days',
- 'stop': start.strftime('%Y-%m-%d'),
- 'start' : stop.strftime('%Y-%m-%d'),
- }
- start = stop - RelativeDateTime(days=1)
- return res
+ res = {}
+ period_length = data['form']['period_length']
+ if period_length<=0:
+ raise wizard.except_wizard('UserError', 'You must enter a period length that cannot be 0 or below !')
+ start = datetime.date.fromtimestamp(time.mktime(time.strptime(data['form']['date1'],"%Y-%m-%d")))
+ start = DateTime(int(start.year),int(start.month),int(start.day))
+ if data['form']['direction_selection'] == 'past':
+ for i in range(5)[::-1]:
+ stop = start - RelativeDateTime(days=period_length)
+ res[str(i)] = {
+ 'name' : str((5-(i+1))*period_length) + '-' + str((5-i)*period_length),
+
+ 'stop': start.strftime('%Y-%m-%d'),
+ 'start' : stop.strftime('%Y-%m-%d'),
+ }
+ start = stop - RelativeDateTime(days=1)
+ else:
+ for i in range(5):
+ stop = start + RelativeDateTime(days=period_length)
+ res[str(5-(i+1))] = {
+ 'name' : str((i)*period_length)+'-'+str((i+1)*period_length),
+ 'start': start.strftime('%Y-%m-%d'),
+ 'stop' : stop.strftime('%Y-%m-%d'),
+ }
+ start = stop + RelativeDateTime(days=1)
+ return res
class wizard_report(wizard.interface):
- def _get_defaults(self, cr, uid, data, context):
- fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
- data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
+ def _get_defaults(self, cr, uid, data, context):
+ fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
+ data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
- user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
- if user.company_id:
- company_id = user.company_id.id
- else:
- company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
- data['form']['company_id'] = company_id
- data['form']['state']='all'
- return data['form']
+ user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
+ if user.company_id:
+ company_id = user.company_id.id
+ else:
+ company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
+ data['form']['company_id'] = company_id
+
+ return data['form']
- states = {
- 'init': {
- 'actions': [_get_defaults],
- 'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Partner Balance')]},
- },
- 'print': {
- 'actions': [_calc_dates],
- 'result': {'type':'print', 'report':'account.aged.trial.balance', 'state':'end'},
- },
- }
-
+ states = {
+ 'init': {
+ 'actions': [_get_defaults],
+ 'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Trial Balance')]},
+ },
+ 'print': {
+ 'actions': [_calc_dates],
+ 'result': {'type':'print', 'report':'account.aged_trial_balance', 'state':'end'},
+ },
+ }
wizard_report('account.aged.trial.balance')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py
index 455ab049649..e26410e1dae 100644
--- a/addons/account/wizard/wizard_fiscalyear_close.py
+++ b/addons/account/wizard/wizard_fiscalyear_close.py
@@ -110,7 +110,7 @@ def _data_save(self, cr, uid, data, context):
offset = 0
limit = 100
while True:
- cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
+ cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
@@ -123,10 +123,13 @@ def _data_save(self, cr, uid, data, context):
if not result:
break
for move in result:
+ parent_id = move['id']
+ move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
+ 'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move, {
'journal_id': new_journal.id,
@@ -137,7 +140,7 @@ def _data_save(self, cr, uid, data, context):
offset = 0
limit = 100
while True:
- cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \
+ cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \
'amount_currency, currency_id, blocked, partner_id, ' \
'date_maturity, date_created ' \
'FROM account_move_line ' \
@@ -149,10 +152,13 @@ def _data_save(self, cr, uid, data, context):
if not result:
break
for move in result:
+ parent_id = move['id']
+ move.pop('id')
move.update({
'date': period.date_start,
'journal_id': new_journal.id,
'period_id': period.id,
+ 'parent_move_lines':[(6,0,[parent_id])]
})
pool.get('account.move.line').create(cr, uid, move)
offset += limit
diff --git a/addons/account/wizard/wizard_general_ledger_report.py b/addons/account/wizard/wizard_general_ledger_report.py
index 2e2407b5217..80a25dde35e 100644
--- a/addons/account/wizard/wizard_general_ledger_report.py
+++ b/addons/account/wizard/wizard_general_ledger_report.py
@@ -1,10 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
-#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
@@ -30,33 +26,144 @@
import wizard
import pooler
+import locale
+import time
+
+report_type = '''
+'''
dates_form = '''
-'''
dates_fields = {
+ 'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
+ 'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
+ 'sortbydate':{'string':"Sort by",'type':'selection','selection':[('sort_date','Date'),('sort_mvt','Mouvement')]},
+ 'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]},
+ 'landscape':{'string':"Print in Landscape Mode",'type':'boolean'},
+ 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
+ 'amount_currency':{'string':"with amount in currency",'type':'boolean'}
+
+}
+
+account_form = '''
+'''
+
+account_fields = {
+ 'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
+}
+
+
+
+
+period_form = '''
+'''
+
+period_fields = {
'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
'help': 'Keep empty for all open fiscal year'},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
- 'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
+ 'sortbydate':{'string':"Sort by:",'type':'selection','selection':[('sort_date','Date'),('sort_mvt','Mouvement')]},
+ 'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]},
+ 'landscape':{'string':"Print in Landscape Mode",'type':'boolean'},
+ 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
+ 'amount_currency':{'string':"with amount in currency",'type':'boolean'}
}
+def _check_path(self, cr, uid, data, context):
+ if data['model'] == 'account.account':
+ return 'checktype'
+ else:
+ return 'account_selection'
+
+def _check(self, cr, uid, data, context):
+ if data['form']['landscape']==True:
+ return 'report_landscape'
+ else:
+ return 'report'
+
+def _check_date(self, cr, uid, data, context):
+ sql = """
+ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
+ cr.execute(sql)
+ res = cr.dictfetchall()
+ if res:
+ if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
+ raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
+ else:
+ return 'checkreport'
+
+ else:
+ raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
+
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
- data['form']['state']='all'
+ data['form']['sortbydate'] = 'sort_date'
+ data['form']['display_account']='bal_all'
+ data['form']['landscape']=True
+ data['form']['amount_currency'] = True
return data['form']
+ def _get_defaults_fordate(self, cr, uid, data, context):
+ data['form']['sortbydate'] = 'sort_date'
+ data['form']['display_account']='bal_all'
+ data['form']['landscape']=True
+ data['form']['amount_currency'] = True
+ return data['form']
+
states = {
'init': {
+ 'actions': [],
+ 'result': {'type':'choice','next_state':_check_path}
+ },
+ 'account_selection': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':account_form,'fields':account_fields, 'state':[('end','Cancel'),('checktype','Print')]}
+ },
+ 'checktype': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
+ },
+ 'with_period': {
'actions': [_get_defaults],
- 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
+ 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('checkreport','Print')]}
+ },
+ 'with_date': {
+ 'actions': [_get_defaults_fordate],
+ 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
+ },
+ 'checkdate': {
+ 'actions': [],
+ 'result': {'type':'choice','next_state':_check_date}
+ },
+ 'checkreport': {
+ 'actions': [],
+ 'result': {'type':'choice','next_state':_check}
+ },
+ 'report_landscape': {
+ 'actions': [],
+ 'result': {'type':'print', 'report':'account.general.ledger_landscape', 'state':'end'}
},
'report': {
'actions': [],
@@ -64,7 +171,3 @@ class wizard_report(wizard.interface):
}
}
wizard_report('account.general.ledger.report')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_pay_invoice.py b/addons/account/wizard/wizard_pay_invoice.py
index 44e4fdd065c..fe60dc4689f 100644
--- a/addons/account/wizard/wizard_pay_invoice.py
+++ b/addons/account/wizard/wizard_pay_invoice.py
@@ -124,7 +124,7 @@ def _get_period(self, cr, uid, data, context={}):
raise wizard.except_wizard(_('Error !'), _('Can not pay draft invoice.'))
return {
'period_id': period_id,
- 'amount': invoice.amount_total,
+ 'amount': invoice.residual,
'date': time.strftime('%Y-%m-%d')
}
diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py
old mode 100644
new mode 100755
index 2c64c8f1df2..e9f2daf4b01
--- a/addons/account/wizard/wizard_third_party_ledger.py
+++ b/addons/account/wizard/wizard_third_party_ledger.py
@@ -1,9 +1,6 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -32,54 +29,133 @@ import time
import wizard
import pooler
+
+report_type = '''
+'''
+
+
dates_form = '''
'''
dates_fields = {
- 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
- 'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
- 'help': 'Keep empty for all open fiscal year'},
- 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
- 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
- 'state':{'string':'Target Moves','type':'selection','selection': [('all','All Entries'),('posted','All Posted Entries')]}
+ 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
+ 'date1': {'string':'Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
+ 'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
+ 'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]},
+ 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
+ 'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'},
+ 'page_split':{'string':"Un partenaire par page",'type':'boolean'},
}
+period_form = '''
+'''
+
+period_fields = {
+ 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
+ 'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
+ 'help': 'Keep empty for all open fiscal year'},
+ 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
+ 'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]},
+ 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'},
+ 'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'},
+ 'page_split':{'string':"Un partenaire par page",'type':'boolean'},
+}
+
+
class wizard_report(wizard.interface):
- def _get_defaults(self, cr, uid, data, context):
- fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
- data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
+
+ def _get_defaults(self, cr, uid, data, context):
- user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
- if user.company_id:
- company_id = user.company_id.id
- else:
- company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
- data['form']['company_id'] = company_id
- data['form']['state']='all'
- return data['form']
+ fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
+ data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
+ data['form']['display_account']='bal_all'
+
+ data['form']['result_selection'] = 'all'
+ user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
+ if user.company_id:
+ company_id = user.company_id.id
+ else:
+ company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
+ data['form']['company_id'] = company_id
+ data['form']['page_split'] = False
+ data['form']['reconcil'] = False
+ data['form']['soldeinit'] = True
+ return data['form']
+
+ def _get_defaults_fordate(self, cr, uid, data, context):
+ data['form']['result_selection'] = 'all'
+ user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
+ if user.company_id:
+ company_id = user.company_id.id
+ else:
+ company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
+ data['form']['company_id'] = company_id
+ data['form']['page_split'] = False
+ data['form']['reconcil'] = False
+ data['form']['soldeinit'] = True
+ return data['form']
- states = {
- 'init': {
- 'actions': [_get_defaults],
- 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print') ]}
- },
- 'report': {
- 'actions': [],
- 'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
- }
- }
+
+ def _check_date(self, cr, uid, data, context):
+ sql = """
+ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date1'])
+ cr.execute(sql)
+ res = cr.dictfetchall()
+ if res:
+ if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
+ raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
+ else:
+ return 'report'
+
+ else:
+ raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
+
+
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
+ },
+ 'with_period': {
+ 'actions': [_get_defaults],
+ 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]}
+ },
+ 'with_date': {
+ 'actions': [_get_defaults_fordate],
+ 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
+ },
+ 'checkdate': {
+ 'actions': [],
+ 'result': {'type':'choice','next_state':_check_date}
+ },
+ 'report': {
+ 'actions': [],
+ 'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'}
+ }
+ }
wizard_report('account.third_party_ledger.report')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account/wizard/wizard_vat.py b/addons/account/wizard/wizard_vat.py
old mode 100644
new mode 100755
index 2d72b0e445f..62a22e00af4
--- a/addons/account/wizard/wizard_vat.py
+++ b/addons/account/wizard/wizard_vat.py
@@ -1,9 +1,6 @@
-# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id$
+# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
@@ -34,68 +31,65 @@ import pooler
dates_form = '''
'''
dates_fields = {
- 'company_id': {'string': 'Company', 'type': 'many2one',
- 'relation': 'res.company', 'required': True},
- 'period_id': {'string':'Period', 'type':'many2one',
- 'relation': 'account.period', 'required':True},
- 'based_on':{'string':'Base on', 'type':'selection', 'selection':[
- ('invoices','Invoices'),
- ('payments','Payments'),
- ], 'required':True, 'default': lambda *a: 'invoices'},
+ 'company_id': {'string': 'Company', 'type': 'many2one',
+ 'relation': 'res.company', 'required': True},
+ 'based_on':{'string':'Base on', 'type':'selection', 'selection':[
+ ('invoices','Invoices'),
+ ('payments','Payments'),
+ ], 'required':True, 'default': lambda *a: 'invoices'},
+ 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
+
}
class wizard_report(wizard.interface):
- def _get_defaults(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- period_obj = pool.get('account.period')
- data['form']['period_id'] = period_obj.find(cr, uid)[0]
+ def _get_defaults(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ period_obj = pool.get('account.period')
- user = pool.get('res.users').browse(cr, uid, uid, context=context)
- if user.company_id:
- company_id = user.company_id.id
- else:
- company_id = pool.get('res.company').search(cr, uid,
- [('parent_id', '=', False)])[0]
- data['form']['company_id'] = company_id
+ user = pool.get('res.users').browse(cr, uid, uid, context=context)
+ if user.company_id:
+ company_id = user.company_id.id
+ else:
+ company_id = pool.get('res.company').search(cr, uid,
+ [('parent_id', '=', False)])[0]
+ data['form']['company_id'] = company_id
- return data['form']
+ return data['form']
- states = {
- 'init': {
- 'actions': [_get_defaults],
- 'result': {
- 'type': 'form',
- 'arch': dates_form,
- 'fields': dates_fields,
- 'state': [
- ('end', 'Cancel'),
- ('report', 'Print VAT Decl.')
- ]
- }
- },
- 'report': {
- 'actions': [],
- 'result': {
- 'type': 'print',
- 'report': 'account.vat.declaration',
- 'state':'end'
- }
- }
- }
+ states = {
+ 'init': {
+ 'actions': [_get_defaults],
+ 'result': {
+ 'type': 'form',
+ 'arch': dates_form,
+ 'fields': dates_fields,
+ 'state': [
+ ('end', 'Cancel'),
+ ('report', 'Print VAT Decl.')
+ ]
+ }
+ },
+ 'report': {
+ 'actions': [],
+ 'result': {
+ 'type': 'print',
+ 'report': 'account.vat.declaration',
+ 'state':'end'
+ }
+ }
+ }
wizard_report('account.vat.declaration')
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/account_budget/__terp__.py b/addons/account_budget/__terp__.py
index 9231b606400..b7957697226 100644
--- a/addons/account_budget/__terp__.py
+++ b/addons/account_budget/__terp__.py
@@ -1,13 +1,13 @@
# -*- encoding: utf-8 -*-
{
- "name" : "Crossovered Budget Management",
+ "name" : "Budget Management",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://tinyerp.com/module_crossovered_budget.html",
"category" : "Generic Modules/Accounting",
"description": """This module allow accountants to manage analytic and crossovered budgets.
- Once the Master Budgets and the Budgets defined (in Financial Management/Configuration/Budgets/), the Project Managers can set the planned amount on each Analytic Account.
+ Once the Master Budgets and the Budgets defined (in Financial Management/Budgets/), the Project Managers can set the planned amount on each Analytic Account.
The accountant has the possibility to see the total of amount planned for each Budget and Master Budget in order to ensure the total planned is not greater/lower than what he planned for this Budget/Master Budget. Each list of record can also be switched to a graphical view of it.
diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py
index 420926bbaf4..dfb018d82e8 100644
--- a/addons/account_budget/crossovered_budget.py
+++ b/addons/account_budget/crossovered_budget.py
@@ -138,7 +138,7 @@ crossovered_budget()
class crossovered_budget_lines(osv.osv):
- def _pra_amt(self, cr, uid, ids,name,args,context):
+ def _prac_amt(self, cr, uid, ids,context={}):
res = {}
for line in self.browse(cr, uid, ids):
acc_ids = ','.join([str(x.id) for x in line.general_budget_id.account_ids])
@@ -157,7 +157,14 @@ class crossovered_budget_lines(osv.osv):
res[line.id]=result
return res
- def _theo_amt(self, cr, uid, ids,name,args,context):
+ def _prac(self, cr, uid, ids,name,args,context):
+ res={}
+ for line in self.browse(cr, uid, ids):
+ res[line.id]=self._prac_amt(cr,uid,[line.id],context=context)[line.id]
+
+ return res
+
+ def _theo_amt(self, cr, uid, ids,context={}):
res = {}
for line in self.browse(cr, uid, ids):
today=datetime.datetime.today()
@@ -184,6 +191,13 @@ class crossovered_budget_lines(osv.osv):
res[line.id]=theo_amt
return res
+ def _theo(self, cr, uid, ids,name,args,context):
+ res={}
+ for line in self.browse(cr, uid, ids):
+ res[line.id]=self._theo_amt(cr,uid,[line.id],context=context)[line.id]
+
+ return res
+
def _perc(self, cr, uid, ids,name,args,context):
res = {}
for line in self.browse(cr, uid, ids):
@@ -201,58 +215,13 @@ class crossovered_budget_lines(osv.osv):
'date_from': fields.date('Start Date',required=True),
'date_to': fields.date('End Date',required=True),
'paid_date': fields.date('Paid Date'),
- 'planned_amount':fields.float('Planned Amount',required=True),
- 'practical_amount':fields.function(_pra_amt,method=True, string='Practical Amount',type='float'),
- 'theoritical_amount':fields.function(_theo_amt,method=True, string='Theoritical Amount',type='float'),
+ 'planned_amount':fields.float('Planned Amount',required=True,digits=(16,2)),
+ 'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float',digits=(16,2)),
+ 'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float',digits=(16,2)),
'percentage':fields.function(_perc,method=True, string='Percentage',type='float'),
}
crossovered_budget_lines()
-
-
-#class account_budget_post(osv.osv): #old code
-# _name = 'account.budget.post'
-# _inherit = 'account.budget.post'
-# _columns = {
-# 'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'general_budget_id', 'Budget Lines'),
-# }
-#account_budget_post()
-#
-#class account_budget_post_dotation(osv.osv):
-# _name = 'account.budget.post.dotation'
-# _inherit = 'account.budget.post.dotation'
-#
-# def _tot_planned(self, cr, uid, ids,name,args,context):
-# res={}
-# for line in self.browse(cr, uid, ids):
-# if line.period_id:
-# obj_period=self.pool.get('account.period').browse(cr, uid,line.period_id.id)
-#
-# total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start)
-# budget_id=line.post_id and line.post_id.id or False
-# query="select id from crossovered_budget_lines where general_budget_id= '"+ str(budget_id) + "' AND (date_from >='" +obj_period.date_start +"' and date_from <= '"+obj_period.date_stop + "') OR (date_to >='" +obj_period.date_start +"' and date_to <= '"+obj_period.date_stop + "') OR (date_from <'" +obj_period.date_start +"' and date_to > '"+obj_period.date_stop + "')"
-# cr.execute(query)
-# res1=cr.fetchall()
-#
-# tot_planned=0.00
-# for record in res1:
-# obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid,record[0])
-# count_days = min(strToDate(obj_period.date_stop),strToDate(obj_lines.date_to)) - max(strToDate(obj_period.date_start), strToDate(obj_lines.date_from))
-# days_in_period = count_days.days +1
-# count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from)
-# total_days_of_rec = count_days.days +1
-# tot_planned += obj_lines.planned_amount/total_days_of_rec* days_in_period
-# res[line.id]=tot_planned
-# else:
-# res[line.id]=0.00
-# return res
-#
-# _columns = {
-# 'tot_planned':fields.function(_tot_planned,method=True, string='Total Planned Amount',type='float',store=True),
-# }
-#
-#account_budget_post_dotation()
-
class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
_inherit = 'account.analytic.account'
@@ -266,7 +235,7 @@ account_analytic_account()
#--------------------------------------------------------------
# moved from account/project/project.py
# ---------------------------------------------------------
-# Budgets
+# Budgets.
# ---------------------------------------------------------
#class account_analytic_budget_post(osv.osv):
diff --git a/addons/account_budget/crossovered_budget_view.xml b/addons/account_budget/crossovered_budget_view.xml
index 178f8dd0696..ed7b1efb5bb 100644
--- a/addons/account_budget/crossovered_budget_view.xml
+++ b/addons/account_budget/crossovered_budget_view.xml
@@ -76,7 +76,7 @@
form
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -1
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+
+
+ 5
+
+
+
+
+
+
+ 1
+
+
+
diff --git a/addons/base_iban/base_iban.py b/addons/base_iban/base_iban.py
index dd06ea6e438..d7ccef61ad2 100644
--- a/addons/base_iban/base_iban.py
+++ b/addons/base_iban/base_iban.py
@@ -31,11 +31,52 @@
import netsvc
from osv import fields, osv
+def _format_iban(string):
+ '''
+ This function removes all characters from given 'string' that isn't a alpha numeric and converts it to lower case.
+ '''
+ res = ""
+ for char in string:
+ if char.isalnum():
+ res += char.lower()
+ return res
+
class res_partner_bank(osv.osv):
_inherit = "res.partner.bank"
- _columns = {
- 'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"),
- }
+
+ def create(self, cr, uid, vals, context={}):
+ #overwrite to format the iban number correctly
+ if vals.has_key('iban'):
+ vals['iban'] = _format_iban(vals['iban'])
+ return super(res_partner_bank, self).create(cr, uid, vals, context)
+
+ def write(self, cr, uid, ids, vals, context={}):
+ #overwrite to format the iban number correctly
+ if vals.has_key('iban'):
+ vals['iban'] = _format_iban(vals['iban'])
+ return super(res_partner_bank, self).write(cr, uid, ids, vals, context)
+
+ def check_iban(self, cr, uid, ids):
+ '''
+ Check the IBAN number
+ '''
+ for bank_acc in self.browse(cr, uid, ids):
+ if not bank_acc.iban:
+ continue
+ iban =_format_iban(bank_acc.iban)
+ #the four first digits have to be shifted to the end
+ iban = iban[4:] + iban[:4]
+ #letters have to be transformed into numbers (a = 10, b = 11, ...)
+ iban2 = ""
+ for char in iban:
+ if char.isalpha():
+ iban2 += str(ord(char)-87)
+ else:
+ iban2 += char
+ #iban is correct if modulo 97 == 1
+ if not int(iban2) % 97 == 1:
+ return False
+ return True
def name_get(self, cr, uid, ids, context=None):
res = []
@@ -48,6 +89,50 @@ class res_partner_bank(osv.osv):
res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context)
return res
+ def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
+ #overwrite the search method in order to search not only on bank type == basic account number but also on type == iban
+ res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, order, context=context, count=count)
+ if filter(lambda x:x[0]=='acc_number' ,args):
+ #get the value of the search
+ iban_value = filter(lambda x:x[0]=='acc_number' ,args)[0][2]
+ #get the other arguments of the search
+ args1 = filter(lambda x:x[0]!='acc_number' ,args)
+ #add the new criterion
+ args1 += [('iban','ilike',iban_value)]
+ #append the results to the older search
+ res += super(res_partner_bank,self).search(cr, uid, args1, offset, limit,
+ order, context=context, count=count)
+ return res
+
+ def get_bban_from_iban(self, cr, uid, ids, context=None):
+ '''
+ This function returns the bank account number computed from the iban account number, thanks to the mapping_list dictionary that contains the rules associated to its country.
+ '''
+ res = {}
+ mapping_list = {
+ #TODO add rules for others countries
+ 'be': lambda x: x[4:],
+ 'fr': lambda x: x[14:],
+ 'ch': lambda x: x[9:],
+ 'gb': lambda x: x[14:],
+ }
+ for record in self.browse(cr, uid, ids, context):
+ if not record.iban:
+ res[record.id] = False
+ continue
+ res[record.id] = False
+ for code, function in mapping_list.items():
+ if record.iban.lower().startswith(code):
+ res[record.id] = function(record.iban)
+ break
+ return res
+
+ _columns = {
+ 'iban': fields.char('IBAN', size=34, readonly=True, help="International Bank Account Number"),
+ }
+
+ _constraints = [(check_iban, "The IBAN number doesn't seem to be correct.", ["iban"])]
+
res_partner_bank()
diff --git a/addons/base_setup/wizard/wizard_base_setup.py b/addons/base_setup/wizard/wizard_base_setup.py
index 5e4b0356668..f8de1e6bfa8 100644
--- a/addons/base_setup/wizard/wizard_base_setup.py
+++ b/addons/base_setup/wizard/wizard_base_setup.py
@@ -264,7 +264,7 @@ class wizard_base_setup(wizard.interface):
return {
'view_type': 'form',
"view_mode": 'form',
- 'res_model': 'ir.module.module.configuration.wizard',
+ 'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'context':{'menu':True},
'target':'new',
diff --git a/addons/board_document/__terp__.py b/addons/board_document/__terp__.py
index b48ee6b2782..665d24c2f10 100644
--- a/addons/board_document/__terp__.py
+++ b/addons/board_document/__terp__.py
@@ -4,7 +4,7 @@
"version":"1.0",
"author":"Tiny",
"category":"Board/Document",
- "depends":["board","document2", "report_document"],
+ "depends":["board","document", "report_document"],
"demo_xml":["board_document_demo.xml"],
"update_xml":["board_document_view.xml"],
"description": """ This module implements a dashboard for Document """,
diff --git a/addons/crm_configuration/crm_config.py b/addons/crm_configuration/crm_config.py
index c89d49af7ba..fe57488dd6f 100644
--- a/addons/crm_configuration/crm_config.py
+++ b/addons/crm_configuration/crm_config.py
@@ -106,11 +106,11 @@ class crm_menu_config_wizard(osv.osv_memory):
tools.convert_xml_import(cr, 'crm_configuration', tools.file_open(os.path.join('crm_configuration',file_name )), {}, 'init', *args)
except Exception, e:
raise osv.except_osv('Error !', e)
-
+
return {
'view_type': 'form',
"view_mode": 'form',
- 'res_model': 'ir.module.module.configuration.wizard',
+ 'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
@@ -118,11 +118,11 @@ class crm_menu_config_wizard(osv.osv_memory):
return {
'view_type': 'form',
"view_mode": 'form',
- 'res_model': 'ir.module.module.configuration.wizard',
+ 'res_model': 'ir.actions.configuration.wizard',
'type': 'ir.actions.act_window',
'target':'new',
}
-
+
crm_menu_config_wizard()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/crm_configuration/crm_config_view.xml b/addons/crm_configuration/crm_config_view.xml
index 20dc8ed42c5..6185d763024 100644
--- a/addons/crm_configuration/crm_config_view.xml
+++ b/addons/crm_configuration/crm_config_view.xml
@@ -1,7 +1,7 @@
-
+
- |