@ -21,12 +21,11 @@
##############################################################################
##############################################################################
import xlwt
import xlwt
import time
from datetime import datetime
from datetime import datetime
from openerp.report import report_sxw
from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.report_xls import report_xls
from openerp.addons.report_xls.utils import rowcol_to_cell
from openerp.addons.report_xls.utils import rowcol_to_cell
from openerp.addons.account_financial_report_webkit.report.partners_ledger import PartnersLedgerWebkit
from openerp.addons.account_financial_report_webkit.report.partners_ledger \
import PartnersLedgerWebkit
from openerp.tools.translate import _
from openerp.tools.translate import _
#import logging
#import logging
#_logger = logging.getLogger(__name__)
#_logger = logging.getLogger(__name__)
@ -39,65 +38,75 @@ _column_sizes = [
( ' partner ' , 30 ) ,
( ' partner ' , 30 ) ,
( ' label ' , 58 ) ,
( ' label ' , 58 ) ,
( ' rec ' , 12 ) ,
( ' rec ' , 12 ) ,
( ' debit ' , 15 ) ,
( ' debit ' , 15 ) ,
( ' credit ' , 15 ) ,
( ' credit ' , 15 ) ,
( ' cumul_bal ' , 15 ) ,
( ' cumul_bal ' , 15 ) ,
( ' curr_bal ' , 15 ) ,
( ' curr_bal ' , 15 ) ,
( ' curr_code ' , 7 ) ,
( ' curr_code ' , 7 ) ,
]
]
class partner_ledger_xls ( report_xls ) :
class partner_ledger_xls ( report_xls ) :
column_sizes = [ x [ 1 ] for x in _column_sizes ]
column_sizes = [ x [ 1 ] for x in _column_sizes ]
def generate_xls_report ( self , _p , _xs , data , objects , wb ) :
def generate_xls_report ( self , _p , _xs , data , objects , wb ) :
ws = wb . add_sheet ( _p . report_name [ : 31 ] )
ws = wb . add_sheet ( _p . report_name [ : 31 ] )
ws . panes_frozen = True
ws . panes_frozen = True
ws . remove_splits = True
ws . remove_splits = True
ws . portrait = 0 # Landscape
ws . portrait = 0 # Landscape
ws . fit_width_to_pages = 1
ws . fit_width_to_pages = 1
row_pos = 0
row_pos = 0
# set print header/footer
# set print header/footer
ws . header_str = self . xls_headers [ ' standard ' ]
ws . header_str = self . xls_headers [ ' standard ' ]
ws . footer_str = self . xls_footers [ ' standard ' ]
ws . footer_str = self . xls_footers [ ' standard ' ]
# cf. account_report_partner_ledger.mako
initial_balance_text = { ' initial_balance ' : _ ( ' Computed ' ) , ' opening_balance ' : _ ( ' Opening Entries ' ) , False : _ ( ' No ' ) }
# cf. account_report_partner_ledger.mako
initial_balance_text = { ' initial_balance ' : _ ( ' Computed ' ) ,
' opening_balance ' : _ ( ' Opening Entries ' ) ,
False : _ ( ' No ' ) }
# Title
# Title
cell_style = xlwt . easyxf ( _xs [ ' xls_title ' ] )
cell_style = xlwt . easyxf ( _xs [ ' xls_title ' ] )
report_name = ' - ' . join ( [ _p . report_name . upper ( ) , _p . company . partner_id . name , _p . company . currency_id . name ] )
report_name = ' - ' . join ( [ _p . report_name . upper ( ) ,
_p . company . partner_id . name ,
_p . company . currency_id . name ] )
c_specs = [
c_specs = [
( ' report_name ' , 1 , 0 , ' text ' , report_name ) ,
( ' report_name ' , 1 , 0 , ' text ' , report_name ) ,
]
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , row_style = cell_style )
row_pos = self . xls_write_row (
ws , row_pos , row_data , row_style = cell_style )
# write empty row to define column sizes
# write empty row to define column sizes
c_sizes = self . column_sizes
c_sizes = self . column_sizes
c_specs = [ ( ' empty %s ' % i , 1 , c_sizes [ i ] , ' text ' , None ) for i in range ( 0 , len ( c_sizes ) ) ]
c_specs = [ ( ' empty %s ' % i , 1 , c_sizes [ i ] , ' text ' , None )
for i in range ( 0 , len ( c_sizes ) ) ]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , set_column_size = True )
row_pos = self . xls_write_row (
ws , row_pos , row_data , set_column_size = True )
# Header Table
# Header Table
nbr_columns = 10
nbr_columns = 10
if _p . amount_currency ( data ) :
if _p . amount_currency ( data ) :
nbr_columns = 12
nbr_columns = 12
cell_format = _xs [ ' bold ' ] + _xs [ ' fill_blue ' ] + _xs [ ' borders_all ' ]
cell_format = _xs [ ' bold ' ] + _xs [ ' fill_blue ' ] + _xs [ ' borders_all ' ]
cell_style = xlwt . easyxf ( cell_format )
cell_style = xlwt . easyxf ( cell_format )
cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_specs = [
c_specs = [
( ' coa ' , 2 , 0 , ' text ' , _ ( ' Chart of Account ' ) ) ,
( ' coa ' , 2 , 0 , ' text ' , _ ( ' Chart of Account ' ) ) ,
( ' fy ' , 1 , 0 , ' text ' , _ ( ' Fiscal Year ' ) ) ,
( ' fy ' , 1 , 0 , ' text ' , _ ( ' Fiscal Year ' ) ) ,
( ' df ' , 2 , 0 , ' text ' , _p . filter_form ( data ) == ' filter_date ' and _ ( ' Dates Filter ' ) or _ ( ' Periods Filter ' ) ) ,
( ' df ' , 2 , 0 , ' text ' , _p . filter_form ( data ) ==
' filter_date ' and _ ( ' Dates Filter ' ) or _ ( ' Periods Filter ' ) ) ,
( ' af ' , 1 , 0 , ' text ' , _ ( ' Accounts Filter ' ) ) ,
( ' af ' , 1 , 0 , ' text ' , _ ( ' Accounts Filter ' ) ) ,
( ' tm ' , 2 , 0 , ' text ' , _ ( ' Target Moves ' ) ) ,
( ' tm ' , 2 , 0 , ' text ' , _ ( ' Target Moves ' ) ) ,
( ' ib ' , nbr_columns - 8 , 0 , ' text ' , _ ( ' Initial Balance ' ) ) ,
( ' ib ' , nbr_columns - 8 , 0 , ' text ' , _ ( ' Initial Balance ' ) ) ,
]
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , row_style = cell_style_center )
row_pos = self . xls_write_row (
ws , row_pos , row_data , row_style = cell_style_center )
cell_format = _xs [ ' borders_all ' ]
cell_format = _xs [ ' borders_all ' ]
cell_style = xlwt . easyxf ( cell_format )
cell_style = xlwt . easyxf ( cell_format )
@ -108,7 +117,7 @@ class partner_ledger_xls(report_xls):
]
]
df = _ ( ' From ' ) + ' : '
df = _ ( ' From ' ) + ' : '
if _p . filter_form ( data ) == ' filter_date ' :
if _p . filter_form ( data ) == ' filter_date ' :
df + = _p . start_date if _p . start_date else u ' '
df + = _p . start_date if _p . start_date else u ' '
else :
else :
df + = _p . start_period . name if _p . start_period else u ' '
df + = _p . start_period . name if _p . start_period else u ' '
df + = ' ' + _ ( ' To ' ) + ' : '
df + = ' ' + _ ( ' To ' ) + ' : '
@ -118,20 +127,26 @@ class partner_ledger_xls(report_xls):
df + = _p . stop_period . name if _p . stop_period else u ' '
df + = _p . stop_period . name if _p . stop_period else u ' '
c_specs + = [
c_specs + = [
( ' df ' , 2 , 0 , ' text ' , df ) ,
( ' df ' , 2 , 0 , ' text ' , df ) ,
( ' af ' , 1 , 0 , ' text ' , _ ( ' Custom Filter ' ) if _p . partner_ids else _p . display_partner_account ( data ) ) ,
( ' af ' , 1 , 0 , ' text ' , _ ( ' Custom Filter ' )
if _p . partner_ids else _p . display_partner_account ( data ) ) ,
( ' tm ' , 2 , 0 , ' text ' , _p . display_target_move ( data ) ) ,
( ' tm ' , 2 , 0 , ' text ' , _p . display_target_move ( data ) ) ,
( ' ib ' , nbr_columns - 8 , 0 , ' text ' , initial_balance_text [ _p . initial_balance_mode ] ) ,
]
( ' ib ' , nbr_columns - 8 , 0 , ' text ' ,
initial_balance_text [ _p . initial_balance_mode ] ) ,
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , row_style = cell_style_center )
ws . set_horz_split_pos ( row_pos )
row_pos = self . xls_write_row (
ws , row_pos , row_data , row_style = cell_style_center )
ws . set_horz_split_pos ( row_pos )
row_pos + = 1
row_pos + = 1
# Account Title Row
# Account Title Row
cell_format = _xs [ ' xls_title ' ] + _xs [ ' bold ' ] + _xs [ ' fill ' ] + _xs [ ' borders_all ' ]
cell_format = _xs [ ' xls_title ' ] + _xs [ ' bold ' ] + \
_xs [ ' fill ' ] + _xs [ ' borders_all ' ]
account_cell_style = xlwt . easyxf ( cell_format )
account_cell_style = xlwt . easyxf ( cell_format )
account_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
account_cell_style_decimal = xlwt . easyxf ( cell_format + _xs [ ' right ' ] , num_format_str = report_xls . decimal_format )
account_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
account_cell_style_decimal = xlwt . easyxf (
cell_format + _xs [ ' right ' ] ,
num_format_str = report_xls . decimal_format )
# Column Title Row
# Column Title Row
cell_format = _xs [ ' bold ' ]
cell_format = _xs [ ' bold ' ]
@ -142,26 +157,32 @@ class partner_ledger_xls(report_xls):
c_hdr_cell_style = xlwt . easyxf ( cell_format )
c_hdr_cell_style = xlwt . easyxf ( cell_format )
c_hdr_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
c_hdr_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
c_hdr_cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_hdr_cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_hdr_cell_style_decimal = xlwt . easyxf ( cell_format + _xs [ ' right ' ] , num_format_str = report_xls . decimal_format )
c_hdr_cell_style_decimal = xlwt . easyxf (
cell_format + _xs [ ' right ' ] ,
num_format_str = report_xls . decimal_format )
# Column Initial Balance Row
# Column Initial Balance Row
cell_format = _xs [ ' italic ' ] + _xs [ ' borders_all ' ]
cell_format = _xs [ ' italic ' ] + _xs [ ' borders_all ' ]
c_init_cell_style = xlwt . easyxf ( cell_format )
c_init_cell_style = xlwt . easyxf ( cell_format )
c_init_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
c_init_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
c_init_cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_init_cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_init_cell_style_decimal = xlwt . easyxf ( cell_format + _xs [ ' right ' ] , num_format_str = report_xls . decimal_format )
c_init_cell_style_decimal = xlwt . easyxf (
cell_format + _xs [ ' right ' ] ,
num_format_str = report_xls . decimal_format )
# Column Cumulated balance Row
# Column Cumulated balance Row
cell_format = _xs [ ' bold ' ] + _xs [ ' fill ' ] + _xs [ ' borders_all ' ]
cell_format = _xs [ ' bold ' ] + _xs [ ' fill ' ] + _xs [ ' borders_all ' ]
c_cumul_cell_style = xlwt . easyxf ( cell_format )
c_cumul_cell_style = xlwt . easyxf ( cell_format )
c_cumul_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
c_cumul_cell_style_right = xlwt . easyxf ( cell_format + _xs [ ' right ' ] )
c_cumul_cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_cumul_cell_style_center = xlwt . easyxf ( cell_format + _xs [ ' center ' ] )
c_cumul_cell_style_decimal = xlwt . easyxf ( cell_format + _xs [ ' right ' ] , num_format_str = report_xls . decimal_format )
# Column Partner Row
c_cumul_cell_style_decimal = xlwt . easyxf (
cell_format + _xs [ ' right ' ] ,
num_format_str = report_xls . decimal_format )
# Column Partner Row
cell_format = _xs [ ' bold ' ]
cell_format = _xs [ ' bold ' ]
c_part_cell_style = xlwt . easyxf ( cell_format )
c_part_cell_style = xlwt . easyxf ( cell_format )
c_specs = [
c_specs = [
( ' date ' , 1 , 0 , ' text ' , _ ( ' Date ' ) , None , c_hdr_cell_style ) ,
( ' date ' , 1 , 0 , ' text ' , _ ( ' Date ' ) , None , c_hdr_cell_style ) ,
( ' period ' , 1 , 0 , ' text ' , _ ( ' Period ' ) , None , c_hdr_cell_style ) ,
( ' period ' , 1 , 0 , ' text ' , _ ( ' Period ' ) , None , c_hdr_cell_style ) ,
@ -171,13 +192,17 @@ class partner_ledger_xls(report_xls):
( ' label ' , 1 , 0 , ' text ' , _ ( ' Label ' ) , None , c_hdr_cell_style ) ,
( ' label ' , 1 , 0 , ' text ' , _ ( ' Label ' ) , None , c_hdr_cell_style ) ,
( ' rec ' , 1 , 0 , ' text ' , _ ( ' Rec. ' ) , None , c_hdr_cell_style ) ,
( ' rec ' , 1 , 0 , ' text ' , _ ( ' Rec. ' ) , None , c_hdr_cell_style ) ,
( ' debit ' , 1 , 0 , ' text ' , _ ( ' Debit ' ) , None , c_hdr_cell_style_right ) ,
( ' debit ' , 1 , 0 , ' text ' , _ ( ' Debit ' ) , None , c_hdr_cell_style_right ) ,
( ' credit ' , 1 , 0 , ' text ' , _ ( ' Credit ' ) , None , c_hdr_cell_style_right ) ,
( ' cumul_bal ' , 1 , 0 , ' text ' , _ ( ' Cumul. Bal. ' ) , None , c_hdr_cell_style_right ) ,
( ' credit ' , 1 , 0 , ' text ' , _ ( ' Credit ' ) ,
None , c_hdr_cell_style_right ) ,
( ' cumul_bal ' , 1 , 0 , ' text ' , _ ( ' Cumul. Bal. ' ) ,
None , c_hdr_cell_style_right ) ,
]
]
if _p . amount_currency ( data ) :
if _p . amount_currency ( data ) :
c_specs + = [
c_specs + = [
( ' curr_bal ' , 1 , 0 , ' text ' , _ ( ' Curr. Bal. ' ) , None , c_hdr_cell_style_right ) ,
( ' curr_code ' , 1 , 0 , ' text ' , _ ( ' Curr. ' ) , None , c_hdr_cell_style_center ) ,
( ' curr_bal ' , 1 , 0 , ' text ' , _ ( ' Curr. Bal. ' ) ,
None , c_hdr_cell_style_right ) ,
( ' curr_code ' , 1 , 0 , ' text ' , _ ( ' Curr. ' ) ,
None , c_hdr_cell_style_center ) ,
]
]
c_hdr_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
c_hdr_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
@ -186,12 +211,16 @@ class partner_ledger_xls(report_xls):
ll_cell_style = xlwt . easyxf ( ll_cell_format )
ll_cell_style = xlwt . easyxf ( ll_cell_format )
ll_cell_style_right = xlwt . easyxf ( ll_cell_format + _xs [ ' right ' ] )
ll_cell_style_right = xlwt . easyxf ( ll_cell_format + _xs [ ' right ' ] )
ll_cell_style_center = xlwt . easyxf ( ll_cell_format + _xs [ ' center ' ] )
ll_cell_style_center = xlwt . easyxf ( ll_cell_format + _xs [ ' center ' ] )
ll_cell_style_date = xlwt . easyxf ( ll_cell_format + _xs [ ' left ' ] , num_format_str = report_xls . date_format )
ll_cell_style_decimal = xlwt . easyxf ( ll_cell_format + _xs [ ' right ' ] , num_format_str = report_xls . decimal_format )
ll_cell_style_date = xlwt . easyxf (
ll_cell_format + _xs [ ' left ' ] ,
num_format_str = report_xls . date_format )
ll_cell_style_decimal = xlwt . easyxf (
ll_cell_format + _xs [ ' right ' ] ,
num_format_str = report_xls . decimal_format )
cnt = 0
cnt = 0
for account in objects :
for account in objects :
if account . ledger_lines or account . init_balance :
if account . ledger_lines or account . init_balance :
if not account . partners_order :
if not account . partners_order :
continue
continue
cnt + = 1
cnt + = 1
@ -200,15 +229,20 @@ class partner_ledger_xls(report_xls):
account_balance_cumul = 0.0
account_balance_cumul = 0.0
account_balance_cumul_curr = 0.0
account_balance_cumul_curr = 0.0
c_specs = [
c_specs = [
( ' acc_title ' , nbr_columns , 0 , ' text ' , ' - ' . join ( [ account . code , account . name ] ) , None , account_cell_style ) ,
( ' acc_title ' , nbr_columns , 0 , ' text ' ,
' - ' . join ( [ account . code , account . name ] ) , None ,
account_cell_style ) ,
]
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , c_title_cell_style )
row_data = self . xls_row_template (
c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row (
ws , row_pos , row_data , c_title_cell_style )
row_pos + = 1
row_pos + = 1
row_start_account = row_pos
row_start_account = row_pos
for partner_name , p_id , p_ref , p_name in account . partners_order :
for partner_name , p_id , p_ref , p_name in \
account . partners_order :
total_debit = 0.0
total_debit = 0.0
total_credit = 0.0
total_credit = 0.0
cumul_balance = 0.0
cumul_balance = 0.0
@ -216,48 +250,67 @@ class partner_ledger_xls(report_xls):
part_cumul_balance = 0.0
part_cumul_balance = 0.0
part_cumul_balance_curr = 0.0
part_cumul_balance_curr = 0.0
c_specs = [
c_specs = [
( ' partner_title ' , nbr_columns , 0 , ' text ' , partner_name or _ ( ' No Partner ' ) , None , c_part_cell_style ) ,
( ' partner_title ' , nbr_columns , 0 , ' text ' ,
partner_name or _ ( ' No Partner ' ) , None ,
c_part_cell_style ) ,
]
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , c_title_cell_style )
row_pos = self . xls_write_row ( ws , row_pos , c_hdr_data )
row_data = self . xls_row_template (
c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row (
ws , row_pos , row_data , c_title_cell_style )
row_pos = self . xls_write_row ( ws , row_pos , c_hdr_data )
row_start_partner = row_pos
row_start_partner = row_pos
total_debit = account . init_balance . get ( p_id , { } ) . get ( ' debit ' ) or 0.0
total_credit = account . init_balance . get ( p_id , { } ) . get ( ' credit ' ) or 0.0
total_debit = account . init_balance . get (
p_id , { } ) . get ( ' debit ' ) or 0.0
total_credit = account . init_balance . get (
p_id , { } ) . get ( ' credit ' ) or 0.0
init_line = False
init_line = False
if _p . initial_balance_mode and ( total_debit or total_credit ) :
if _p . initial_balance_mode and \
( total_debit or total_credit ) :
init_line = True
init_line = True
part_cumul_balance = account . init_balance . get ( p_id , { } ) . get ( ' init_balance ' ) or 0.0
part_cumul_balance_curr = account . init_balance . get ( p_id , { } ) . get ( ' init_balance_currency ' ) or 0.0
balance_forward_currency = account . init_balance . get ( p_id , { } ) . get ( ' currency_name ' ) or ' '
part_cumul_balance = account . init_balance . get (
p_id , { } ) . get ( ' init_balance ' ) or 0.0
part_cumul_balance_curr = account . init_balance . get (
p_id , { } ) . get ( ' init_balance_currency ' ) or 0.0
balance_forward_currency = account . init_balance . get (
p_id , { } ) . get ( ' currency_name ' ) or ' '
cumul_balance + = part_cumul_balance
cumul_balance + = part_cumul_balance
cumul_balance_curr + = part_cumul_balance_curr
cumul_balance_curr + = part_cumul_balance_curr
debit_cell = rowcol_to_cell ( row_pos , 7 )
debit_cell = rowcol_to_cell ( row_pos , 7 )
credit_cell = rowcol_to_cell ( row_pos , 8 )
credit_cell = rowcol_to_cell ( row_pos , 8 )
init_bal_formula = debit_cell + ' - ' + credit_cell
################## Print row 'Initial Balance' by partner #################
c_specs = [ ( ' empty %s ' % x , 1 , 0 , ' text ' , None ) for x in range ( 5 ) ]
init_bal_formula = debit_cell + ' - ' + credit_cell
# Print row 'Initial Balance' by partn
c_specs = [ ( ' empty %s ' % x , 1 , 0 , ' text ' , None )
for x in range ( 5 ) ]
c_specs + = [
c_specs + = [
( ' init_bal ' , 1 , 0 , ' text ' , _ ( ' Initial Balance ' ) ) ,
( ' init_bal ' , 1 , 0 , ' text ' , _ ( ' Initial Balance ' ) ) ,
( ' rec ' , 1 , 0 , ' text ' , None ) ,
( ' rec ' , 1 , 0 , ' text ' , None ) ,
( ' debit ' , 1 , 0 , ' number ' , total_debit , None , c_init_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , total_credit , None , c_init_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , None , init_bal_formula , c_init_cell_style_decimal ) ,
]
( ' debit ' , 1 , 0 , ' number ' , total_debit ,
None , c_init_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , total_credit ,
None , c_init_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , None ,
init_bal_formula , c_init_cell_style_decimal ) ,
]
if _p . amount_currency ( data ) :
if _p . amount_currency ( data ) :
c_specs + = [
c_specs + = [
( ' curr_bal ' , 1 , 0 , ' number ' , part_cumul_balance_curr , None , c_init_cell_style_decimal ) ,
( ' curr_code ' , 1 , 0 , ' text ' , balance_forward_currency ) ,
( ' curr_bal ' , 1 , 0 , ' number ' ,
part_cumul_balance_curr ,
None , c_init_cell_style_decimal ) ,
( ' curr_code ' , 1 , 0 , ' text ' ,
balance_forward_currency ) ,
]
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , c_init_cell_style )
row_data = self . xls_row_template (
c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row (
ws , row_pos , row_data , c_init_cell_style )
for line in account . ledger_lines . get ( p_id , [ ] ) :
for line in account . ledger_lines . get ( p_id , [ ] ) :
total_debit + = line . get ( ' debit ' ) or 0.0
total_debit + = line . get ( ' debit ' ) or 0.0
@ -265,101 +318,148 @@ class partner_ledger_xls(report_xls):
label_elements = [ line . get ( ' lname ' ) or ' ' ]
label_elements = [ line . get ( ' lname ' ) or ' ' ]
if line . get ( ' invoice_number ' ) :
if line . get ( ' invoice_number ' ) :
label_elements . append ( " ( %s ) " % ( line [ ' invoice_number ' ] , ) )
label_elements . append (
" ( %s ) " % ( line [ ' invoice_number ' ] , ) )
label = ' ' . join ( label_elements )
label = ' ' . join ( label_elements )
cumul_balance + = line . get ( ' balance ' ) or 0.0
cumul_balance + = line . get ( ' balance ' ) or 0.0
if init_line or row_pos > row_start_partner :
if init_line or row_pos > row_start_partner :
cumbal_formula = rowcol_to_cell ( row_pos - 1 , 9 ) + ' + '
cumbal_formula = rowcol_to_cell (
row_pos - 1 , 9 ) + ' + '
else :
else :
cumbal_formula = ' '
cumbal_formula = ' '
debit_cell = rowcol_to_cell ( row_pos , 7 )
debit_cell = rowcol_to_cell ( row_pos , 7 )
credit_cell = rowcol_to_cell ( row_pos , 8 )
credit_cell = rowcol_to_cell ( row_pos , 8 )
cumbal_formula + = debit_cell + ' - ' + credit_cell
################## Print row ledger line data #################
cumbal_formula + = debit_cell + ' - ' + credit_cell
################## Print row ledger line data #########
if line . get ( ' ldate ' ) :
if line . get ( ' ldate ' ) :
c_specs = [
c_specs = [
( ' ldate ' , 1 , 0 , ' date ' , datetime . strptime ( line [ ' ldate ' ] , ' % Y- % m- %d ' ) , None , ll_cell_style_date ) ,
( ' ldate ' , 1 , 0 , ' date ' , datetime . strptime (
line [ ' ldate ' ] , ' % Y- % m- %d ' ) , None ,
ll_cell_style_date ) ,
]
]
else :
else :
c_specs = [
c_specs = [
( ' ldate ' , 1 , 0 , ' text ' , None ) ,
( ' ldate ' , 1 , 0 , ' text ' , None ) ,
]
]
c_specs + = [
c_specs + = [
( ' period ' , 1 , 0 , ' text ' , line . get ( ' period_code ' ) or ' ' ) ,
( ' move ' , 1 , 0 , ' text ' , line . get ( ' move_name ' ) or ' ' ) ,
( ' period ' , 1 , 0 , ' text ' ,
line . get ( ' period_code ' ) or ' ' ) ,
( ' move ' , 1 , 0 , ' text ' ,
line . get ( ' move_name ' ) or ' ' ) ,
( ' journal ' , 1 , 0 , ' text ' , line . get ( ' jcode ' ) or ' ' ) ,
( ' journal ' , 1 , 0 , ' text ' , line . get ( ' jcode ' ) or ' ' ) ,
( ' partner ' , 1 , 0 , ' text ' , line . get ( ' partner_name ' ) or ' ' ) ,
( ' partner ' , 1 , 0 , ' text ' ,
line . get ( ' partner_name ' ) or ' ' ) ,
( ' label ' , 1 , 0 , ' text ' , label ) ,
( ' label ' , 1 , 0 , ' text ' , label ) ,
( ' rec_name ' , 1 , 0 , ' text ' , line . get ( ' rec_name ' ) or ' ' ) ,
( ' debit ' , 1 , 0 , ' number ' , line . get ( ' debit ' ) , None , ll_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , line . get ( ' credit ' ) , None , ll_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , None , cumbal_formula , ll_cell_style_decimal ) ,
]
( ' rec_name ' , 1 , 0 , ' text ' ,
line . get ( ' rec_name ' ) or ' ' ) ,
( ' debit ' , 1 , 0 , ' number ' , line . get ( ' debit ' ) ,
None , ll_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , line . get ( ' credit ' ) ,
None , ll_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , None ,
cumbal_formula , ll_cell_style_decimal ) ,
]
if _p . amount_currency ( data ) :
if _p . amount_currency ( data ) :
c_specs + = [
c_specs + = [
( ' curr_bal ' , 1 , 0 , ' number ' , line . get ( ' amount_currency ' ) or 0.0 , None , ll_cell_style_decimal ) ,
( ' curr_code ' , 1 , 0 , ' text ' , line . get ( ' currency_code ' ) or ' ' , None , ll_cell_style_center ) ,
( ' curr_bal ' , 1 , 0 , ' number ' , line . get (
' amount_currency ' ) or 0.0 , None ,
ll_cell_style_decimal ) ,
( ' curr_code ' , 1 , 0 , ' text ' , line . get (
' currency_code ' ) or ' ' , None ,
ll_cell_style_center ) ,
]
]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , ll_cell_style )
#end for line
################## Print row Cumulated Balance by partner #################
debit_partner_start = rowcol_to_cell ( row_start_partner , 7 )
debit_partner_end = rowcol_to_cell ( row_pos - 1 , 7 )
debit_partner_total = ' SUM( ' + debit_partner_start + ' : ' + debit_partner_end + ' ) '
credit_partner_start = rowcol_to_cell ( row_start_partner , 8 )
credit_partner_end = rowcol_to_cell ( row_pos - 1 , 8 )
credit_partner_total = ' SUM( ' + credit_partner_start + ' : ' + credit_partner_end + ' ) '
bal_partner_debit = rowcol_to_cell ( row_pos , 7 )
row_data = self . xls_row_template (
c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row (
ws , row_pos , row_data , ll_cell_style )
# end for line
################## Print row Cumulated Balance by partner #
debit_partner_start = rowcol_to_cell ( row_start_partner , 7 )
debit_partner_end = rowcol_to_cell ( row_pos - 1 , 7 )
debit_partner_total = ' SUM( ' + debit_partner_start + \
' : ' + debit_partner_end + ' ) '
credit_partner_start = rowcol_to_cell ( row_start_partner , 8 )
credit_partner_end = rowcol_to_cell ( row_pos - 1 , 8 )
credit_partner_total = ' SUM( ' + credit_partner_start + \
' : ' + credit_partner_end + ' ) '
bal_partner_debit = rowcol_to_cell ( row_pos , 7 )
bal_partner_credit = rowcol_to_cell ( row_pos , 8 )
bal_partner_credit = rowcol_to_cell ( row_pos , 8 )
bal_partner_total = bal_partner_debit + ' - ' + bal_partner_credit
c_specs = [ ( ' empty %s ' % x , 1 , 0 , ' text ' , None ) for x in range ( 5 ) ]
bal_partner_total = bal_partner_debit + \
' - ' + bal_partner_credit
c_specs = [ ( ' empty %s ' % x , 1 , 0 , ' text ' , None )
for x in range ( 5 ) ]
c_specs + = [
c_specs + = [
( ' init_bal ' , 1 , 0 , ' text ' , _ ( ' Cumulated balance on Partner ' ) ) ,
( ' rec ' , 1 , 0 , ' text ' , None ) ,
( ' debit ' , 1 , 0 , ' number ' , None , debit_partner_total , c_cumul_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , None , credit_partner_total , c_cumul_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , None , bal_partner_total , c_cumul_cell_style_decimal ) ,
]
( ' init_bal ' , 1 , 0 , ' text ' ,
_ ( ' Cumulated balance on Partner ' ) ) ,
( ' rec ' , 1 , 0 , ' text ' , None ) ,
( ' debit ' , 1 , 0 , ' number ' , None ,
debit_partner_total , c_cumul_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , None ,
credit_partner_total , c_cumul_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , None ,
bal_partner_total , c_cumul_cell_style_decimal ) ,
]
if _p . amount_currency ( data ) :
if _p . amount_currency ( data ) :
if account . currency_id :
if account . currency_id :
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' number ' , cumul_balance_curr or 0.0 , None , c_cumul_cell_style_decimal ) ]
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' number ' ,
cumul_balance_curr or 0.0 , None ,
c_cumul_cell_style_decimal ) ]
else :
else :
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' text ' , ' - ' , None , c_cumul_cell_style_right ) ]
c_specs + = [ ( ' curr_code ' , 1 , 0 , ' text ' , account . currency_id . name if account . currency_id else u ' ' , None , c_cumul_cell_style_center ) ]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , c_cumul_cell_style )
row_pos + = 1
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' text ' ,
' - ' , None , c_cumul_cell_style_right ) ]
c_specs + = [ ( ' curr_code ' , 1 , 0 , ' text ' ,
account . currency_id . name if
account . currency_id else u ' ' , None ,
c_cumul_cell_style_center ) ]
row_data = self . xls_row_template (
c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row (
ws , row_pos , row_data , c_cumul_cell_style )
row_pos + = 1
account_total_debit + = total_debit
account_total_debit + = total_debit
account_total_credit + = total_credit
account_total_credit + = total_credit
account_balance_cumul + = cumul_balance
account_balance_cumul + = cumul_balance
account_balance_cumul_curr + = cumul_balance_curr
################## Print row Cumulated Balance by account #################
c_specs = [ ( ' acc_title ' , 5 , 0 , ' text ' , ' - ' . join ( [ account . code , account . name ] ) ) , ]
account_balance_cumul_curr + = cumul_balance_curr
################## Print row Cumulated Balance by account #####
c_specs = [
( ' acc_title ' , 5 , 0 , ' text ' , ' - ' .
join ( [ account . code , account . name ] ) ) , ]
c_specs + = [
c_specs + = [
( ' label ' , 1 , 0 , ' text ' , _ ( ' Cumulated balance on Account ' ) ) ,
( ' label ' , 1 , 0 , ' text ' , _ ( ' Cumulated balance on Account ' ) ) ,
( ' rec ' , 1 , 0 , ' text ' , None ) ,
( ' rec ' , 1 , 0 , ' text ' , None ) ,
( ' debit ' , 1 , 0 , ' number ' , account_total_debit , None , account_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , account_total_credit , None , account_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , account_balance_cumul , None , account_cell_style_decimal ) ,
]
( ' debit ' , 1 , 0 , ' number ' , account_total_debit ,
None , account_cell_style_decimal ) ,
( ' credit ' , 1 , 0 , ' number ' , account_total_credit ,
None , account_cell_style_decimal ) ,
( ' cumul_bal ' , 1 , 0 , ' number ' , account_balance_cumul ,
None , account_cell_style_decimal ) ,
]
if _p . amount_currency ( data ) :
if _p . amount_currency ( data ) :
if account . currency_id :
if account . currency_id :
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' number ' , account_balance_cumul_curr or 0.0 , None , account_cell_style_decimal ) ]
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' number ' ,
account_balance_cumul_curr or 0.0 , None ,
account_cell_style_decimal ) ]
else :
else :
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' text ' , ' - ' , None , account_cell_style_right ) ]
c_specs + = [ ( ' curr_code ' , 1 , 0 , ' text ' , account . currency_id . name if account . currency_id else u ' ' , None , account_cell_style ) ]
row_data = self . xls_row_template ( c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row ( ws , row_pos , row_data , account_cell_style )
c_specs + = [ ( ' curr_bal ' , 1 , 0 , ' text ' ,
' - ' , None , account_cell_style_right ) ]
c_specs + = [ ( ' curr_code ' , 1 , 0 , ' text ' ,
account . currency_id . name if
account . currency_id else u ' ' , None ,
account_cell_style ) ]
row_data = self . xls_row_template (
c_specs , [ x [ 0 ] for x in c_specs ] )
row_pos = self . xls_write_row (
ws , row_pos , row_data , account_cell_style )
row_pos + = 2
row_pos + = 2
partner_ledger_xls ( ' report.account.account_report_partner_ledger_xls ' , ' account.account ' ,
parser = PartnersLedgerWebkit )
partner_ledger_xls ( ' report.account.account_report_partner_ledger_xls ' ,
' account.account ' ,
parser = PartnersLedgerWebkit )
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: