|
|
@ -32,6 +32,7 @@ from openerp.tools.translate import _ |
|
|
|
import logging |
|
|
|
_logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
class account_journal_xls_parser(nov_journal_print): |
|
|
|
|
|
|
|
def __init__(self, cr, uid, name, context): |
|
|
@ -46,6 +47,7 @@ class account_journal_xls_parser(nov_journal_print): |
|
|
|
'template_changes': template_changes, |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
class account_journal_xls(report_xls): |
|
|
|
|
|
|
|
def __init__(self, name, table, rml=False, parser=False, header=True, store=False): |
|
|
@ -62,97 +64,97 @@ class account_journal_xls(report_xls): |
|
|
|
aml_cell_format = _xs['borders_all'] |
|
|
|
self.aml_cell_style = xlwt.easyxf(aml_cell_format) |
|
|
|
self.aml_cell_style_center = xlwt.easyxf(aml_cell_format + _xs['center']) |
|
|
|
self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str = report_xls.date_format) |
|
|
|
self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) |
|
|
|
self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str=report_xls.date_format) |
|
|
|
self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str=report_xls.decimal_format) |
|
|
|
# totals |
|
|
|
rt_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] |
|
|
|
self.rt_cell_style = xlwt.easyxf(rt_cell_format) |
|
|
|
self.rt_cell_style_right = xlwt.easyxf(rt_cell_format + _xs['right']) |
|
|
|
self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) |
|
|
|
self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str=report_xls.decimal_format) |
|
|
|
|
|
|
|
# XLS Template Journal Items |
|
|
|
self.col_specs_lines_template = { |
|
|
|
'move_name':{ |
|
|
|
'move_name': { |
|
|
|
'header': [1, 20, 'text', _render("_('Entry')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['move_name'] != '/' and l['move_name'] or ('*'+str(l['move_id']))")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'move_date':{ |
|
|
|
'move_date': { |
|
|
|
'header': [1, 13, 'text', _render("_('Date')")], |
|
|
|
'lines': [1, 0, 'date', _render("datetime.strptime(l['move_date'],'%Y-%m-%d')"), None, self.aml_cell_style_date], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'acc_code':{ |
|
|
|
'acc_code': { |
|
|
|
'header': [1, 12, 'text', _render("_('Account')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['acc_code']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'aml_name':{ |
|
|
|
'aml_name': { |
|
|
|
'header': [1, 42, 'text', _render("_('Description')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['aml_name']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'period':{ |
|
|
|
'period': { |
|
|
|
'header': [1, 12, 'text', _render("_('Period')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['period']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'partner_name':{ |
|
|
|
'partner_name': { |
|
|
|
'header': [1, 36, 'text', _render("_('Partner')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['partner_name']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'partner_ref':{ |
|
|
|
'partner_ref': { |
|
|
|
'header': [1, 36, 'text', _render("_('Partner Reference')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['partner_ref']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'date_maturity':{ |
|
|
|
'date_maturity': { |
|
|
|
'header': [1, 13, 'text', _render("_('Maturity Date')")], |
|
|
|
'lines': [1, 0, _render("l['date_maturity'] and 'date' or 'text'"), |
|
|
|
_render("l['date_maturity'] and datetime.strptime(l['date_maturity'],'%Y-%m-%d') or None"), |
|
|
|
None, self.aml_cell_style_date], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'debit':{ |
|
|
|
'debit': { |
|
|
|
'header': [1, 18, 'text', _render("_('Debit')"), None, self.rh_cell_style_right], |
|
|
|
'lines': [1, 0, 'number', _render("l['debit']"), None, self.aml_cell_style_decimal], |
|
|
|
'totals': [1, 0, 'number', None, _render("debit_formula"), self.rt_cell_style_decimal]}, |
|
|
|
'credit':{ |
|
|
|
'credit': { |
|
|
|
'header': [1, 18, 'text', _render("_('Credit')"), None, self.rh_cell_style_right], |
|
|
|
'lines': [1, 0, 'number', _render("l['credit']"), None, self.aml_cell_style_decimal], |
|
|
|
'totals': [1, 0, 'number', None, _render("credit_formula"), self.rt_cell_style_decimal]}, |
|
|
|
'balance':{ |
|
|
|
'balance': { |
|
|
|
'header': [1, 18, 'text', _render("_('Balance')"), None, self.rh_cell_style_right], |
|
|
|
'lines': [1, 0, 'number', None, _render("bal_formula"), self.aml_cell_style_decimal], |
|
|
|
'totals': [1, 0, 'number', None, _render("bal_formula"), self.rt_cell_style_decimal]}, |
|
|
|
'reconcile':{ |
|
|
|
'reconcile': { |
|
|
|
'header': [1, 12, 'text', _render("_('Rec.')"), None, self.rh_cell_style_center], |
|
|
|
'lines': [1, 0, 'text', _render("l['reconcile']"), None, self.aml_cell_style_center], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'reconcile_partial':{ |
|
|
|
'reconcile_partial': { |
|
|
|
'header': [1, 12, 'text', _render("_('Part. Rec.')"), None, self.rh_cell_style_center], |
|
|
|
'lines': [1, 0, 'text', _render("l['reconcile_partial']"), None, self.aml_cell_style_center], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'tax_code':{ |
|
|
|
'tax_code': { |
|
|
|
'header': [1, 6, 'text', _render("_('VAT')"), None, self.rh_cell_style_center], |
|
|
|
'lines': [1, 0, 'text', _render("l['tax_code']"), None, self.aml_cell_style_center], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'tax_amount':{ |
|
|
|
'tax_amount': { |
|
|
|
'header': [1, 18, 'text', _render("_('VAT Amount')"), None, self.rh_cell_style_right], |
|
|
|
'lines': [1, 0, 'number', _render("l['tax_amount']"), None, self.aml_cell_style_decimal], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'amount_currency':{ |
|
|
|
'amount_currency': { |
|
|
|
'header': [1, 18, 'text', _render("_('Am. Currency')"), None, self.rh_cell_style_right], |
|
|
|
'lines': [1, 0, _render("l['amount_currency'] and 'number' or 'text'"), |
|
|
|
_render("l['amount_currency'] or None"), |
|
|
|
None, self.aml_cell_style_decimal], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'currency_name':{ |
|
|
|
'currency_name': { |
|
|
|
'header': [1, 6, 'text', _render("_('Curr.')"), None, self.rh_cell_style_center], |
|
|
|
'lines': [1, 0, 'text', _render("l['currency_name']"), None, self.aml_cell_style_center], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'docname':{ |
|
|
|
'docname': { |
|
|
|
'header': [1, 35, 'text', _render("_('Document')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['docname']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'move_ref':{ |
|
|
|
'move_ref': { |
|
|
|
'header': [1, 25, 'text', _render("_('Entry Reference')")], |
|
|
|
'lines': [1, 0, 'text', _render("l['move_ref']")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
|
'move_id':{ |
|
|
|
'move_id': { |
|
|
|
'header': [1, 10, 'text', _render("_('Entry Id')")], |
|
|
|
'lines': [1, 0, 'text', _render("str(l['move_id'])")], |
|
|
|
'totals': [1, 0, 'text', None]}, |
|
|
@ -160,20 +162,20 @@ class account_journal_xls(report_xls): |
|
|
|
|
|
|
|
# XLS Template VAT Summary |
|
|
|
self.col_specs_vat_summary_template = { |
|
|
|
'tax_case_name':{ |
|
|
|
'tax_case_name': { |
|
|
|
'header': [1, 45, 'text', _render("_('Description')")], |
|
|
|
'tax_totals': [1, 0, 'text', _render("t.name")]}, |
|
|
|
'tax_code':{ |
|
|
|
'tax_code': { |
|
|
|
'header': [1, 6, 'text', _render("_('Case')")], |
|
|
|
'tax_totals': [1, 0, 'text', _render("t.code")]}, |
|
|
|
'tax_amount':{ |
|
|
|
'tax_amount': { |
|
|
|
'header': [1, 18, 'text', _render("_('Amount')"), None, self.rh_cell_style_right], |
|
|
|
'tax_totals': [1, 0, 'number', _render("sum_vat(o,t)"), None, self.aml_cell_style_decimal]}, |
|
|
|
} |
|
|
|
|
|
|
|
def _journal_title(self, o, ws, _p, row_pos, xlwt, _xs): |
|
|
|
cell_style = xlwt.easyxf(_xs['xls_title']) |
|
|
|
report_name = (10*' ').join([ |
|
|
|
report_name = (10 * ' ').join([ |
|
|
|
_p.company.name, |
|
|
|
_p.title(o)[0], |
|
|
|
_p.title(o)[1], |
|
|
@ -216,10 +218,10 @@ class account_journal_xls(report_xls): |
|
|
|
# Totals |
|
|
|
debit_start = rowcol_to_cell(aml_start_pos, debit_pos) |
|
|
|
debit_stop = rowcol_to_cell(row_pos - 1, debit_pos) |
|
|
|
debit_formula = 'SUM(%s:%s)' %(debit_start, debit_stop) |
|
|
|
debit_formula = 'SUM(%s:%s)' % (debit_start, debit_stop) |
|
|
|
credit_start = rowcol_to_cell(aml_start_pos, credit_pos) |
|
|
|
credit_stop = rowcol_to_cell(row_pos - 1, credit_pos) |
|
|
|
credit_formula = 'SUM(%s:%s)' %(credit_start, credit_stop) |
|
|
|
credit_formula = 'SUM(%s:%s)' % (credit_start, credit_stop) |
|
|
|
debit_cell = rowcol_to_cell(row_pos, debit_pos) |
|
|
|
credit_cell = rowcol_to_cell(row_pos, credit_pos) |
|
|
|
bal_formula = debit_cell + '-' + credit_cell |
|
|
@ -296,7 +298,7 @@ class account_journal_xls(report_xls): |
|
|
|
ws = wb.add_sheet(sheet_name) |
|
|
|
ws.panes_frozen = True |
|
|
|
ws.remove_splits = True |
|
|
|
ws.portrait = 0 # Landscape |
|
|
|
ws.portrait = 0 # Landscape |
|
|
|
ws.fit_width_to_pages = 1 |
|
|
|
row_pos = 0 |
|
|
|
|
|
|
|