[MERGE]: Merge with lp:openobject-addons-trunk

bzr revid: ksa@tinyerp.co.in-20100920054141-ljt5n2onqdftjuk2
This commit is contained in:
ksa (Open ERP)
2010-09-20 11:11:41 +05:30
223 changed files with 9076 additions and 1346 deletions
+1
View File
@@ -134,6 +134,7 @@ module named account_voucher.
'test/account_use_model.yml',
'test/account_validate_account_move.yml',
'test/account_fiscalyear_close.yml',
'test/account_report.yml',
],
'installable': True,
'active': False,
+25
View File
@@ -686,6 +686,27 @@ class account_journal(osv.osv):
vals.update({'sequence_id' : self.create_sequence(cr, uid, vals, context)})
return super(account_journal, self).create(cr, uid, vals, context)
def name_get(self, cr, user, ids, context={}):
"""
Returns a list of tupples containing id, name.
result format : {[(id, name), (id, name), ...]}
@param cr: A database cursor
@param user: ID of the user currently logged in
@param ids: list of ids for which name should be read
@param context: context arguments, like lang, time zone
@return: Returns a list of tupples containing id, name
"""
result = self.browse(cr, user, ids, context)
res = []
for rs in result:
name = rs.name
if rs.currency:
name = "%s (%s)" % (rs.name, rs.currency.name)
res += [(rs.id, name)]
return res
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
if not args:
args = []
@@ -2659,6 +2680,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
vals_journal['type'] = 'sale'
vals_journal['code'] = _('SAJ')
vals_journal['sequence_id'] = seq_id_sale
vals_journal['company_id'] = company_id
if obj_multi.chart_template_id.property_account_receivable:
vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id]
@@ -2672,6 +2694,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
vals_journal['code'] = _('EXJ')
vals_journal['sequence_id'] = seq_id_purchase
vals_journal['view_id'] = view_id
vals_journal['company_id'] = company_id
if obj_multi.chart_template_id.property_account_payable:
vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id]
@@ -2723,6 +2746,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
vals_journal['code']= _('BNK') + str(current_num)
vals_journal['sequence_id'] = seq_id
vals_journal['type'] = 'cash'
vals_journal['company_id'] = company_id
if line.currency_id:
vals_journal['view_id'] = view_id_cur
vals_journal['currency'] = line.currency_id.id
-1
View File
@@ -51,7 +51,6 @@ class account_analytic_line(osv.osv):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
context = {}
if context.get('from_date',False):
args.append(['date', '>=',context['from_date']])
+112 -362
View File
@@ -214,22 +214,121 @@ class account_bank_statement(osv.osv):
self.write(cr, uid, ids, {}, context)
return True
def button_confirm_bank(self, cr, uid, ids, context=None):
done = []
def create_move_from_st_line(self, cr, uid, st_line, company_currency_id, next_number, context=None):
res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users')
account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line')
account_analytic_line_obj = self.pool.get('account.analytic.line')
account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
st = st_line.statement_id
context.update({'date': st_line.date})
move_id = account_move_obj.create(cr, uid, {
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'date': st_line.date,
}, context=context)
account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
'move_ids': [(4, move_id, False)]
})
torec = []
if st_line.amount >= 0:
account_id = st.journal_id.default_credit_account_id.id
else:
account_id = st.journal_id.default_debit_account_id.id
acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, st_line.amount, context=context,
account=acc_cur)
val = {
'name': st_line.name,
'date': st_line.date,
'ref': st_line.ref,
'move_id': move_id,
'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
'account_id': (st_line.account_id) and st_line.account_id.id,
'credit': ((amount>0) and amount) or 0.0,
'debit': ((amount<0) and -amount) or 0.0,
'statement_id': st.id,
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'currency_id': st.currency.id,
'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False
}
amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, st_line.amount, context=context,
account=acc_cur)
if st.currency.id <> company_currency_id:
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
st.currency.id, amount, context=context,
account=acc_cur)
val['amount_currency'] = -amount_cur
if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
val['currency_id'] = st_line.account_id.currency_id.id
if company_currency_id==st_line.account_id.currency_id.id:
amount_cur = st_line.amount
else:
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
st_line.account_id.currency_id.id, amount, context=context,
account=acc_cur)
val['amount_currency'] = amount_cur
move_line_id = account_move_line_obj.create(cr, uid, val , context=context)
torec.append(move_line_id)
# Fill the secondary amount/currency
# if currency is not the same than the company
amount_currency = False
currency_id = False
if st.currency.id <> company_currency_id:
amount_currency = st_line.amount
currency_id = st.currency.id
account_move_line_obj.create(cr, uid, {
'name': st_line.name,
'date': st_line.date,
'ref': st_line.ref,
'move_id': move_id,
'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
'account_id': account_id,
'credit': ((amount < 0) and -amount) or 0.0,
'debit': ((amount > 0) and amount) or 0.0,
'statement_id': st.id,
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'amount_currency': amount_currency,
'currency_id': currency_id,
}, context=context)
for line in account_move_line_obj.browse(cr, uid, [x.id for x in
account_move_obj.browse(cr, uid, move_id,
context=context).line_id],
context=context):
if line.state <> 'valid':
raise osv.except_osv(_('Error !'),
_('Journal Item "%s" is not valid') % line.name)
move_name = next_number + ' - ' + str(st_line.sequence)
account_move_obj.write(cr, uid, [move_id], {'name': move_name})
# Bank statements will not consider boolean on journal entry_posted
account_move_obj.post(cr, uid, [move_id], context=context)
return move_id
def button_confirm_bank(self, cr, uid, ids, context=None):
done = []
obj_seq = self.pool.get('ir.sequence')
if context is None:
context = {}
company_currency_id = res_users_obj.browse(cr, uid, uid,
context=context).company_id.currency_id.id
for st in self.browse(cr, uid, ids, context):
company_currency_id = st.journal_id.company_id.currency_id.id
if not st.state=='draft':
continue
@@ -245,181 +344,24 @@ class account_bank_statement(osv.osv):
if not st.name == '/':
next_number = st.name
else:
next_number = obj_seq.get(cr, uid, 'account.bank.statement')
if st.journal_id.sequence_id:
c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
next_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
else:
next_number = obj_seq.get(cr, uid, 'account.bank.statement')
for line in st.move_line_ids:
if line.state <> 'valid':
raise osv.except_osv(_('Error !'),
_('The account entries lines are not in valid state.'))
# for bank.statement.lines
# In line we get reconcile_id on bank.ste.rec.
# in bank stat.rec we get line_new_ids on bank.stat.rec.line
for move in st.line_ids:
if move.analytic_account_id:
for st_line in st.line_ids:
if st_line.analytic_account_id:
if not st.journal_id.analytic_journal_id:
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,))
context.update({'date': move.date})
move_id = account_move_obj.create(cr, uid, {
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'date': move.date,
}, context=context)
account_bank_statement_line_obj.write(cr, uid, [move.id], {
'move_ids': [(4, move_id, False)]
})
if not move.amount:
if not st_line.amount:
continue
torec = []
if move.amount >= 0:
account_id = st.journal_id.default_credit_account_id.id
else:
account_id = st.journal_id.default_debit_account_id.id
acc_cur = ((move.amount<=0) and st.journal_id.default_debit_account_id) or move.account_id
amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, move.amount, context=context,
account=acc_cur)
if move.reconcile_id and move.reconcile_id.line_new_ids:
for newline in move.reconcile_id.line_new_ids:
amount += newline.amount
val = {
'name': move.name,
'date': move.date,
'ref': move.ref,
'move_id': move_id,
'partner_id': ((move.partner_id) and move.partner_id.id) or False,
'account_id': (move.account_id) and move.account_id.id,
'credit': ((amount>0) and amount) or 0.0,
'debit': ((amount<0) and -amount) or 0.0,
'statement_id': st.id,
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'currency_id': st.currency.id,
'analytic_account_id': move.analytic_account_id and move.analytic_account_id.id or False
}
amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, move.amount, context=context,
account=acc_cur)
if st.currency.id <> company_currency_id:
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
st.currency.id, amount, context=context,
account=acc_cur)
val['amount_currency'] = -amount_cur
if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id <> company_currency_id:
val['currency_id'] = move.account_id.currency_id.id
if company_currency_id==move.account_id.currency_id.id:
amount_cur = move.amount
else:
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
move.account_id.currency_id.id, amount, context=context,
account=acc_cur)
val['amount_currency'] = amount_cur
move_line_id = account_move_line_obj.create(cr, uid, val , context=context)
torec.append(move_line_id)
if move.analytic_account_id:
anal_val = {}
amt = (val['credit'] or 0.0) - (val['debit'] or 0.0)
anal_val = {
'name': val['name'],
'ref': val['ref'],
'date': val['date'],
'amount': amt,
'account_id': val['analytic_account_id'],
'currency_id': val['currency_id'],
'general_account_id': val['account_id'],
'journal_id': st.journal_id.analytic_journal_id.id,
'period_id': val['period_id'],
'user_id': uid,
'move_id': move_line_id
}
if val.get('amount_currency', False):
anal_val['amount_currency'] = val['amount_currency']
account_analytic_line_obj.create(cr, uid, anal_val, context=context)
if move.reconcile_id and move.reconcile_id.line_new_ids:
for newline in move.reconcile_id.line_new_ids:
account_move_line_obj.create(cr, uid, {
'name': newline.name or move.name,
'date': move.date,
'ref': move.ref,
'move_id': move_id,
'partner_id': ((move.partner_id) and move.partner_id.id) or False,
'account_id': (newline.account_id) and newline.account_id.id,
'debit': newline.amount>0 and newline.amount or 0.0,
'credit': newline.amount<0 and -newline.amount or 0.0,
'statement_id': st.id,
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'analytic_account_id':newline.analytic_id and newline.analytic_id.id or False,
}, context=context)
# Fill the secondary amount/currency
# if currency is not the same than the company
amount_currency = False
currency_id = False
if st.currency.id <> company_currency_id:
amount_currency = move.amount
currency_id = st.currency.id
account_move_line_obj.create(cr, uid, {
'name': move.name,
'date': move.date,
'ref': move.ref,
'move_id': move_id,
'partner_id': ((move.partner_id) and move.partner_id.id) or False,
'account_id': account_id,
'credit': ((amount < 0) and -amount) or 0.0,
'debit': ((amount > 0) and amount) or 0.0,
'statement_id': st.id,
'journal_id': st.journal_id.id,
'period_id': st.period_id.id,
'amount_currency': amount_currency,
'currency_id': currency_id,
}, context=context)
for line in account_move_line_obj.browse(cr, uid, [x.id for x in
account_move_obj.browse(cr, uid, move_id,
context=context).line_id],
context=context):
if line.state <> 'valid':
raise osv.except_osv(_('Error !'),
_('Journal Item "%s" is not valid') % line.name)
if move.reconcile_id and move.reconcile_id.line_ids:
## Search if move has already a partial reconciliation
previous_partial = False
for line_reconcile_move in move.reconcile_id.line_ids:
if line_reconcile_move.reconcile_partial_id:
previous_partial = True
break
##
torec += map(lambda x: x.id, move.reconcile_id.line_ids)
#try:
if abs(move.reconcile_amount-move.amount)<0.0001:
writeoff_acc_id = False
#There should only be one write-off account!
for entry in move.reconcile_id.line_new_ids:
writeoff_acc_id = entry.account_id.id
break
## If we have already a partial reconciliation
## We need to make a partial reconciliation
## To add this amount to previous paid amount
if previous_partial:
account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context)
## If it's the first reconciliation, we do a full reconciliation as regular
else:
account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
else:
account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context)
move_name = next_number + ' - ' + str(move.sequence)
account_move_obj.write(cr, uid, [move_id], {'name': move_name, 'state': 'posted'}) # Bank statements will not consider boolean on journal entry_posted
self.create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context)
self.log(cr, uid, st.id, 'Statement %s is confirmed and entries are created.' % st.name)
done.append(st.id)
@@ -474,175 +416,6 @@ class account_bank_statement(osv.osv):
account_bank_statement()
class account_bank_statement_reconcile(osv.osv):
_name = "account.bank.statement.reconcile"
_description = "Statement Reconcile"
def _total_entry(self, cursor, user, ids, name, attr, context=None):
result = {}
for o in self.browse(cursor, user, ids, context=context):
result[o.id] = 0.0
for line in o.line_ids:
result[o.id] += line.debit - line.credit
return result
def _total_new(self, cursor, user, ids, name, attr, context=None):
result = {}
for o in self.browse(cursor, user, ids, context=context):
result[o.id] = 0.0
for line in o.line_new_ids:
result[o.id] += line.amount
return result
def _total_balance(self, cursor, user, ids, name, attr, context=None):
result = {}
for o in self.browse(cursor, user, ids, context=context):
result[o.id] = o.total_new - o.total_entry + o.total_amount
return result
def _total_amount(self, cursor, user, ids, name, attr, context=None):
res = {}
res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users')
company_currency_id = res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
currency_id = context.get('currency_id', company_currency_id)
acc_cur = None
if context.get('journal_id', False) and context.get('account_id',False):
st =self.pool.get('account.journal').browse(cursor, user, context['journal_id'])
acc = self.pool.get('account.account').browse(cursor, user, context['account_id'])
acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc
for reconcile_id in ids:
res[reconcile_id] = res_currency_obj.compute(cursor, user,
currency_id, company_currency_id,
context.get('amount', 0.0), context=context, account=acc_cur)
return res
def _default_amount(self, cursor, user, context=None):
if context is None:
context = {}
res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users')
company_currency_id = res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
currency_id = context.get('currency_id', company_currency_id)
acc_cur = None
if context.get('journal_id', False) and context.get('account_id',False):
st =self.pool.get('account.journal').browse(cursor, user, context['journal_id'])
acc = self.pool.get('account.account').browse(cursor, user, context['account_id'])
acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc
return res_currency_obj.compute(cursor, user,
currency_id, company_currency_id,
context.get('amount', 0.0), context=context, account=acc_cur)
def _total_currency(self, cursor, user, ids, name, attrs, context=None):
res = {}
res_users_obj = self.pool.get('res.users')
company_currency_id = res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
for reconcile_id in ids:
res[reconcile_id] = company_currency_id
return res
def _default_currency(self, cursor, user, context=None):
res_users_obj = self.pool.get('res.users')
return res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
def _total_second_amount(self, cursor, user, ids, name, attr,
context=None):
res = {}
for reconcile_id in ids:
res[reconcile_id] = context.get('amount', 0.0)
return res
def _total_second_currency(self, cursor, user, ids, name, attr, context=None):
res = {}
for reconcile_id in ids:
res[reconcile_id] = context.get('currency_id', False)
return res
def name_get(self, cursor, user, ids, context=None):
res= []
for o in self.browse(cursor, user, ids, context=context):
result = 0.0
res_currency = ''
for line in o.line_ids:
if line.amount_currency and line.currency_id:
result += line.amount_currency
res_currency = line.currency_id.code
else:
result += line.debit - line.credit
if res_currency:
res_currency = ' ' + res_currency
res.append((o.id, '[%.2f'% (result - o.total_new,) + res_currency + ']' ))
return res
_columns = {
'name': fields.char('Date', size=64, required=True),
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
'line_new_ids': fields.one2many('account.bank.statement.reconcile.line',
'line_id', 'Write-Off'),
'total_entry': fields.function(_total_entry, method=True,
string='Total entries'),
'total_new': fields.function(_total_new, method=True,
string='Total write-off'),
'total_second_amount': fields.function(_total_second_amount,
method=True, string='Payment amount',
help='The amount in the currency of the journal'),
'total_second_currency': fields.function(_total_second_currency, method=True,
string='Currency', type='many2one', relation='res.currency',
help='The currency of the journal'),
'total_amount': fields.function(_total_amount, method=True,
string='Payment amount'),
'total_currency': fields.function(_total_currency, method=True,
string='Currency', type='many2one', relation='res.currency'),
'total_balance': fields.function(_total_balance, method=True,
string='Balance'),
#line_ids define in account.py
'statement_line': fields.one2many('account.bank.statement.line',
'reconcile_id', 'Bank Statement Line'),
}
_defaults = {
'name': lambda *a: time.strftime('%Y-%m-%d'),
'partner_id': lambda obj, cursor, user, context=None: \
context.get('partner', False),
'total_amount': _default_amount,
'total_currency': _default_currency,
'total_second_amount': lambda obj, cursor, user, context=None: \
context.get('amount', 0.0),
'total_second_currency': lambda obj, cursor, user, context=None: \
context.get('currency_id', False),
'total_balance': _default_amount,
}
account_bank_statement_reconcile()
class account_bank_statement_reconcile_line(osv.osv):
_name = "account.bank.statement.reconcile.line"
_description = "Statement reconcile line"
_columns = {
'name': fields.char('Description', size=64, required=True),
'account_id': fields.many2one('account.account', 'Account', required=True),
'line_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile'),
'amount': fields.float('Amount', required=True),
'analytic_id': fields.many2one('account.analytic.account',"Analytic Account", domain=[('parent_id', '!=', False)])
}
_defaults = {
'name': 'Write-Off',
}
account_bank_statement_reconcile_line()
class account_bank_statement_line(osv.osv):
def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id, context=None):
@@ -683,25 +456,6 @@ class account_bank_statement_line(osv.osv):
res['value']['amount'] = balance
return res
def _reconcile_amount(self, cursor, user, ids, name, args, context=None):
if not ids:
return {}
res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users')
res = {}
company_currency_id = res_users_obj.browse(cursor, user, user,
context=context).company_id.currency_id.id
for line in self.browse(cursor, user, ids, context=context):
if line.reconcile_id:
res[line.id] = res_currency_obj.compute(cursor, user,
company_currency_id, line.statement_id.currency.id,
line.reconcile_id.total_entry, context=context)
else:
res[line.id] = 0.0
return res
_order = "statement_id desc, sequence"
_name = "account.bank.statement.line"
_description = "Bank Statement Line"
@@ -719,16 +473,12 @@ class account_bank_statement_line(osv.osv):
required=True),
'statement_id': fields.many2one('account.bank.statement', 'Statement',
select=True, required=True, ondelete='cascade'),
'reconcile_id': fields.many2one('account.bank.statement.reconcile',
'Reconcile'),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'move_ids': fields.many2many('account.move',
'account_bank_statement_line_move_rel', 'move_id','statement_id',
'Moves'),
'ref': fields.char('Reference', size=32),
'note': fields.text('Notes'),
'reconcile_amount': fields.function(_reconcile_amount,
string='Amount reconciled', method=True, type='float'),
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of bank statement lines."),
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
}
+21 -21
View File
@@ -270,7 +270,7 @@ class account_cash_statement(osv.osv):
super(account_cash_statement, self).write(cr, uid, [rs], res.get(rs))
return True
def onchange_journal_id(self, cr, uid, statement_id, journal_id, context={}):
def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
""" Changes balance start and starting details if journal_id changes"
@param statement_id: Changed statement_id
@param journal_id: Changed journal_id
@@ -288,7 +288,7 @@ class account_cash_statement(osv.osv):
'balance_start': balance_start
})
return res
res = super(account_cash_statement, self).onchange_journal_id(cr, uid, statement_id, journal_id, context)
res = super(account_cash_statement, self).onchange_journal_id(cr, uid, statement_id, journal_id, context=context)
return res
def _equal_balance(self, cr, uid, ids, statement, context={}):
@@ -454,25 +454,25 @@ class account_cash_statement(osv.osv):
move_line_id = account_move_line_obj.create(cr, uid, val , context=context)
torec.append(move_line_id)
if move.analytic_account_id:
anal_val = {}
amt = (val['credit'] or 0.0) - (val['debit'] or 0.0)
anal_val = {
'name': val['name'],
'ref': val['ref'],
'date': val['date'],
'amount': amt,
'account_id': val['analytic_account_id'],
'currency_id': val['currency_id'],
'general_account_id': val['account_id'],
'journal_id': st.journal_id.analytic_journal_id.id,
'period_id': val['period_id'],
'user_id': uid,
'move_id': move_line_id
}
if val.get('amount_currency', False):
anal_val['amount_currency'] = val['amount_currency']
account_analytic_line_obj.create(cr, uid, anal_val, context=context)
# if move.analytic_account_id:
# anal_val = {}
# amt = (val['credit'] or 0.0) - (val['debit'] or 0.0)
# anal_val = {
# 'name': val['name'],
# 'ref': val['ref'],
# 'date': val['date'],
# 'amount': amt,
# 'account_id': val['analytic_account_id'],
# 'currency_id': val['currency_id'],
# 'general_account_id': val['account_id'],
# 'journal_id': st.journal_id.analytic_journal_id.id,
# 'period_id': val['period_id'],
# 'user_id': uid,
# 'move_id': move_line_id
# }
# if val.get('amount_currency', False):
# anal_val['amount_currency'] = val['amount_currency']
# account_analytic_line_obj.create(cr, uid, anal_val, context=context)
if move.reconcile_id and move.reconcile_id.line_new_ids:
for newline in move.reconcile_id.line_new_ids:
+2 -2
View File
@@ -14,7 +14,7 @@
<attribute name="string">Configure Your Accounting Chart</attribute>
</separator>
<xpath expr="//label[@string='description']" position="attributes">
<attribute name="string">Configure your accounting system. By default, Chart of Account is matching to your country. If there are not chart of account certified for your county, you can install the generic chart of account.</attribute>
<attribute name="string">The default Chart of Accounts is matching your country selection. If no certified Chart of Accounts exists for your specified country, a generic one can be installed and will be selected by default.</attribute>
</xpath>
<xpath expr="//button[@string='Install Modules']" position="attributes">
<attribute name="string">Configure</attribute>
@@ -73,7 +73,7 @@
</separator>
<xpath expr="//label[@string='description']" position="attributes">
<attribute name="string">From this screen, you can install Other Addons in your accounting Application. Select the Addons to directly install them. If you do not think you need any of these right now, you can easily install them later.</attribute>
<attribute name="string">Add extra Accounting Addons to the ones already installed. Remember you can always install them at a later stage.</attribute>
</xpath>
<xpath expr="//button[@string='Install Modules']" position="attributes">
<attribute name="string">Configure</attribute>
+7 -8
View File
@@ -150,7 +150,7 @@
<field name="arch" type="xml">
<form string="Supplier invoice">
<group col="8" colspan="4">
<field domain="[('type', '=', 'purchase')]" name="journal_id"/>
<field domain="[('type', '=', 'purchase')]" name="journal_id" on_change="onchange_journal_id(journal_id)" widget="selection"/>
<field name="number" readonly="1"/>
<field name="type" invisible="1"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
@@ -161,14 +161,14 @@
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" groups="account.group_account_user"/>
<field name="period_id" domain="[('state', '=', 'draft')]" groups="account.group_account_user" widget="selection"/>
<group colspan="2" col="1" groups="account.group_account_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
<notebook colspan="4">
<page string="Invoice">
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', company_id),('journal_id','=',journal_id)]" name="account_id" groups="account.group_account_user"/>
<field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]" name="account_id" groups="account.group_account_user"/>
<field name="reference_type" nolabel="1" size="0"/>
<field name="reference" nolabel="1"/>
<field name="date_due"/>
@@ -221,7 +221,6 @@
</page>
<page string="Other Info">
<field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
<field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
<newline/>
<field name="payment_term" widget="selection"/>
@@ -260,7 +259,7 @@
<field name="arch" type="xml">
<form string="Invoice">
<group colspan="4" col="8">
<field name="journal_id" groups="base.group_user"/>
<field name="journal_id" groups="base.group_user" on_change="onchange_journal_id(journal_id)" widget="selection"/>
<field name="number"/>
<field name="type" invisible="1"/>
<field name="currency_id" on_change="onchange_currency_id(currency_id, company_id)" width="50"/>
@@ -271,14 +270,14 @@
<field name="fiscal_position" groups="base.group_extended" widget="selection"/>
<newline/>
<field name="date_invoice"/>
<field name="period_id" groups="account.group_account_user"/>
<field name="period_id" domain="[('state', '=', 'draft')]" groups="account.group_account_user" widget="selection"/>
<group colspan="2" col="1" groups="account.group_account_user">
<label align="0.0" string="(keep empty to use the current period)"/>
</group>
</group>
<notebook colspan="4">
<page string="Invoice">
<field domain="[('type','&lt;&gt;','view'), ('company_id', '=', company_id),('journal_id','=',journal_id)]" name="account_id" groups="account.group_account_user"/>
<field domain="[('company_id', '=', company_id),('type','=', 'receivable')]" name="account_id" groups="account.group_account_user"/>
<field name="name"/>
<field name="payment_term" widget="selection"/>
<field colspan="4" name="invoice_line" nolabel="1" widget="one2many_list"/>
@@ -316,7 +315,7 @@
</group>
</page>
<page string="Other Info">
<field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
<field name="company_id" on_change="onchange_company_id(company_id,partner_id,type,invoice_line,currency_id)" widget="selection" groups="base.group_multi_company"/>
<newline/>
<field name="date_due"/>
<field name="user_id"/>
+3 -9
View File
@@ -131,7 +131,8 @@ class account_move_line(osv.osv):
'general_account_id': obj_line.account_id.id,
'journal_id': obj_line.journal_id.analytic_journal_id.id,
'ref': obj_line.ref,
'move_id':obj_line.id
'move_id':obj_line.id,
'user_id': uid
}
new_id = self.pool.get('account.analytic.line').create(cr,uid,vals_lines)
return True
@@ -1181,6 +1182,7 @@ class account_move_line(osv.osv):
'general_account_id': vals.get('account_id', False),
'journal_id': journal.analytic_journal_id.id,
'ref': vals.get('ref', False),
'user_id': uid
})]
result = super(osv.osv, self).create(cr, uid, vals, context)
@@ -1257,13 +1259,5 @@ class account_move_line(osv.osv):
return result
account_move_line()
class account_bank_statement_reconcile(osv.osv):
_inherit = "account.bank.statement.reconcile"
_columns = {
'line_ids': fields.many2many('account.move.line', 'account_bank_statement_line_rel', 'statement_id', 'line_id', 'Entries'),
}
account_bank_statement_reconcile()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -37
View File
@@ -521,7 +521,7 @@
attrs="{'invisible':[('state','=','confirm')]}"/>
</group>
<notebook colspan="4">
<page string="Transaction">
<page string="Transaction" name="statement_line_ids">
<field colspan="4" name="line_ids" nolabel="1">
<tree editable="bottom" string="Statement lines">
<field name="sequence" readonly="1"/>
@@ -533,8 +533,6 @@
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
<field name="analytic_account_id" groups="base.group_extended"/>
<field name="amount"/>
<field context="{'partner_id': partner_id, 'amount': amount, 'account_id': account_id, 'currency_id': parent.currency, 'journal_id': parent.journal_id, 'date':date}" name="reconcile_id"/>
<field invisible="1" name="reconcile_amount"/>
</tree>
<form string="Statement lines">
<field name="date"/>
@@ -544,7 +542,6 @@
<field domain="[('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id"/>
<field name="analytic_account_id" groups="base.group_extended" />
<field name="amount"/>
<field context="{'partner_id':partner_id,'amount':amount,'account_id':account_id,'currency_id': parent.currency,'journal_id':parent.journal_id, 'date':date}" name="reconcile_id"/>
<field name="ref"/>
<field name="sequence" readonly="0"/>
<separator colspan="4" string="Notes"/>
@@ -552,7 +549,7 @@
</form>
</field>
</page>
<page string="Journal Entries">
<page string="Journal Entries" name="move_live_ids">
<field colspan="4" name="move_line_ids" nolabel="1"/>
</page>
</notebook>
@@ -657,38 +654,6 @@
<field name="filter" eval="True"/>
</record>
<record id="view_bank_statement_reconcile" model="ir.ui.view">
<field name="name">account.bank.statement.reconcile.form</field>
<field name="model">account.bank.statement.reconcile</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Reconcile">
<field name="name" select="1"/>
<newline/>
<field name="total_second_amount"/>
<field name="total_second_currency"/>
<newline/>
<field name="total_amount"/>
<field name="total_currency"/>
<newline/>
<separator colspan="4" string="Entries"/>
<field colspan="4" domain="[('partner_id','=',context.get('partner_id', False)),('state','=','valid'),('account_id','=',context.get('account_id', False)),('reconcile_id', '=', False)]" name="line_ids" nolabel="1" view_mode="tree"/>
<field colspan="4" name="line_new_ids" nolabel="1">
<tree editable="bottom" string="Write-Off">
<field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="amount"/>
<field name="name"/>
</tree>
</field>
<group col="7" colspan="4">
<field name="total_entry"/>
<field name="total_new"/>
<field name="total_balance"/>
<button name="dummy" string="Compute" icon="terp-stock_format-scientific"/>
</group>
</form>
</field>
</record>
<!--
Account Types
-->
@@ -187,8 +187,8 @@
<field name="code">1104</field>
<field name="name">Bank Current Account</field>
<field ref="conf_cas" name="parent_id"/>
<field name="type">view</field>
<field name="user_type" ref="account_type_asset_view1"/>
<field name="type">liquidity</field>
<field name="user_type" ref="conf_account_type_asset"/>
</record>
<record id="conf_cli" model="account.account.template">
+33 -4
View File
@@ -73,6 +73,21 @@ class account_installer(osv.osv_memory):
return user.company_id.id
return False
def _get_default_charts(self, cr, uid, context={}):
module_name = False
company_id = self._default_company(cr, uid, context=context)
company = self.pool.get('res.company').browse(cr, uid, company_id)
address_id = self.pool.get('res.partner').address_get(cr, uid, [company.partner_id.id])
if address_id['default']:
address = self.pool.get('res.partner.address').browse(cr, uid, address_id['default'])
code = address.country_id.code
module_name = (code and 'l10n_' + code.lower()) or False
if module_name:
module_id = self.pool.get('ir.module.module').search(cr, uid, [('name', '=', module_name)])
if module_id:
return module_name
return 'configurable'
_defaults = {
'date_start': lambda *a: time.strftime('%Y-01-01'),
'date_stop': lambda *a: time.strftime('%Y-12-31'),
@@ -80,7 +95,8 @@ class account_installer(osv.osv_memory):
'sale_tax':lambda *a:0.0,
'purchase_tax':lambda *a:0.0,
'company_id': _default_company,
'bank_accounts_id':_get_default_accounts
'bank_accounts_id':_get_default_accounts,
'charts': _get_default_charts
}
def on_change_tax(self, cr, uid, id, tax):
@@ -195,7 +211,7 @@ class account_installer(osv.osv_memory):
vals={
'name': (obj_acc_root.id == account_template.id) and company_id.name or account_template.name,
#'sign': account_template.sign,
'currency_id': account_template.currency_id and account_template.currency_id.id or False,
#'currency_id': account_template.currency_id and account_template.currency_id.id or False,
'code': code_acc,
'type': account_template.type,
'user_type': account_template.user_type and account_template.user_type.id or False,
@@ -209,6 +225,19 @@ class account_installer(osv.osv_memory):
new_account = obj_acc.create(cr, uid, vals)
acc_template_ref[account_template.id] = new_account
if account_template.name == 'Bank Current Account':
b_vals={
'name': 'Bank Accounts',
'code': '110500',
'type': 'view',
'user_type': account_template.parent_id.user_type and account_template.user_type.id or False,
'shortcut': account_template.shortcut,
'note': account_template.note,
'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False,
'tax_ids': [(6,0,tax_ids)],
'company_id': company_id.id,
}
bank_account = obj_acc.create(cr, uid, b_vals)
view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Bank/Cash Journal View')])[0] #why fixed name here?
view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Bank/Cash Journal (Multi-Currency) View')])[0] #Why Fixed name here?
ref_acc_bank = obj_multi.bank_account_view_id
@@ -265,10 +294,10 @@ class account_installer(osv.osv_memory):
vals_bnk = {'name': val.acc_name or '',
'currency_id': val.currency_id.id or False,
'code': str(110400 + code_cnt),
'code': str(110500 + code_cnt),
'type': 'liquidity',
'user_type': type,
'parent_id':new_account,
'parent_id':bank_account,
'company_id': company_id.id }
child_bnk_acc = obj_acc.create(cr, uid, vals_bnk)
vals_seq_child = {
+38 -20
View File
@@ -138,16 +138,17 @@ class account_invoice(osv.osv):
return res
# Give Journal Items related to the payment reconciled to this invoice
# Return ids of partial and total payments related to the selected invoices
def _get_lines(self, cr, uid, ids, name, arg, context=None):
res = {}
for id in ids:
move_lines = self.move_line_id_payment_get(cr, uid, [id])
if not move_lines:
res[id] = []
continue
for invoice in self.browse(cr, uid, ids, context=context):
id = invoice.id
res[id] = []
data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines)
partial_ids = []# Keeps the track of ids where partial payments are done with payment terms
if not invoice.move_id:
continue
data_lines = invoice.move_id.line_id
partial_ids = []
for line in data_lines:
ids_line = []
if line.reconcile_id:
@@ -174,17 +175,17 @@ class account_invoice(osv.osv):
def _compute_lines(self, cr, uid, ids, name, args, context=None):
result = {}
for invoice in self.browse(cr, uid, ids, context):
moves = self.move_line_id_payment_get(cr, uid, [invoice.id])
src = []
lines = []
for m in self.pool.get('account.move.line').browse(cr, uid, moves, context):
temp_lines = []#Added temp list to avoid duplicate records
if m.reconcile_id:
temp_lines = map(lambda x: x.id, m.reconcile_id.line_id)
elif m.reconcile_partial_id:
temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids)
lines += [x for x in temp_lines if x not in lines]
src.append(m.id)
if invoice.move_id:
for m in invoice.move_id.line_id:
temp_lines = []
if m.reconcile_id:
temp_lines = map(lambda x: x.id, m.reconcile_id.line_id)
elif m.reconcile_partial_id:
temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids)
lines += [x for x in temp_lines if x not in lines]
src.append(m.id)
lines = filter(lambda x: x not in src, lines)
result[invoice.id] = lines
@@ -452,6 +453,17 @@ class account_invoice(osv.osv):
_('Can not select currency that is not related to current company.\nPlease select accordingly !.'))
return {}
def onchange_journal_id(self, cr, uid, ids, journal_id=False):
result = {}
if journal_id:
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
currency_id = journal.currency and journal.currency.id or journal.company_id.currency_id.id
result = {'value': {
'currency_id': currency_id,
}
}
return result
def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
if not payment_term_id:
return {}
@@ -550,7 +562,6 @@ class account_invoice(osv.osv):
val['currency_id'] = False
else:
val['currency_id'] = currency.id
if company_id:
company = self.pool.get('res.company').browse(cr, uid, company_id)
if company.currency_id.company_id and company.currency_id.company_id.id != company_id:
@@ -584,15 +595,22 @@ class account_invoice(osv.osv):
# return the ids of the move lines which has the same account than the invoice
# whose id is in ids
def move_line_id_payment_get(self, cr, uid, ids, *args):
res = []
if not ids: return []
result = self.move_line_id_payment_gets(cr, uid, ids, *args)
return result.get(ids[0], [])
def move_line_id_payment_gets(self, cr, uid, ids, *args):
res = {}
if not ids: return res
cr.execute('SELECT l.id '\
cr.execute('SELECT i.id, l.id '\
'FROM account_move_line l '\
'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\
'WHERE i.id IN %s '\
'AND l.account_id=i.account_id',
(tuple(ids),))
res = map(itemgetter(0), cr.fetchall())
for r in cr.fetchall():
res.setdefault(r[0], [])
res[r[0]].append( r[1] )
return res
def copy(self, cr, uid, id, default={}, context=None):
@@ -78,7 +78,7 @@ class report_balancesheet_horizontal(rml_parse.rml_parse, common_report_header):
db_pool = pooler.get_pool(self.cr.dbname)
#Getting Profit or Loss Balance from profit and Loss report
result_pl=self.obj_pl.get_data(data)
result_pl = self.obj_pl.get_data(data)
self.res_bl = self.obj_pl.final_result()
type_pool = db_pool.get('account.account.type')
@@ -86,7 +86,7 @@ class journal_print(report_sxw.rml_parse, common_report_header):
'FROM account_move_line l '
'LEFT JOIN account_journal j ON (l.journal_id=j.id) '
'LEFT JOIN res_currency c on (l.currency_id=c.id)'
'WHERE period_id=%s AND journal_id IN %s ' + self.query_get_clause + ''
'WHERE period_id=%s AND journal_id IN %s ' + self.query_get_clause + ' '
'GROUP BY j.id, j.code, j.name, l.amount_currency,c.code, l.currency_id ',
(period_id, tuple(self.journal_ids)))
return self.cr.dictfetchall()
+76 -32
View File
@@ -43,6 +43,7 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
self.init_query = data['form']['initial_bal_query']
self.init_balance = data['form']['initial_balance']
self.display_account = data['form']['display_account']
self.target_move = data['form'].get('target_move', 'all')
if (data['model'] == 'ir.ui.menu'):
new_ids = [data['form']['chart_account_id']]
objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
@@ -78,14 +79,14 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
self.context = context
def _sum_currency_amount_account(self, account):
self.cr.execute("SELECT sum(l.amount_currency) AS tot_currency "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s" %(account.id, self.query))
self.cr.execute('SELECT sum(l.amount_currency) AS tot_currency \
FROM account_move_line l \
WHERE l.account_id = %s AND %s' %(account.id, self.query))
sum_currency = self.cr.fetchone()[0] or 0.0
if self.init_balance:
self.cr.execute("SELECT sum(l.amount_currency) AS tot_currency "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
self.cr.execute('SELECT sum(l.amount_currency) AS tot_currency \
FROM account_move_line l \
WHERE l.account_id = %s AND %s '%(account.id, self.init_query))
sum_currency += self.cr.fetchone()[0] or 0.0
return str(sum_currency)
@@ -117,13 +118,23 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
def lines(self, account):
""" Return all the account_move_line of account with their account code counterparts """
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted', '']
# First compute all counterpart strings for every move_id where this account appear.
# Currently, the counterpart info is used only in landscape mode
sql = """
SELECT m1.move_id,
array_to_string(ARRAY(SELECT DISTINCT a.code FROM account_move_line m2 LEFT JOIN account_account a ON (m2.account_id=a.id) WHERE m2.move_id = m1.move_id AND m2.account_id<>%%s), ', ') AS counterpart
FROM (SELECT move_id FROM account_move_line l WHERE %s AND l.account_id = %%s GROUP BY move_id) m1
""" % self.query
array_to_string(ARRAY(SELECT DISTINCT a.code
FROM account_move_line m2
LEFT JOIN account_account a ON (m2.account_id=a.id)
WHERE m2.move_id = m1.move_id
AND m2.account_id<>%%s), ', ') AS counterpart
FROM (SELECT move_id
FROM account_move_line l
LEFT JOIN account_move am ON (am.id = l.move_id)
WHERE am.state IN %s and %s AND l.account_id = %%s GROUP BY move_id) m1
"""% (tuple(move_state), self.query)
self.cr.execute(sql, (account.id, account.id))
counterpart_res = self.cr.dictfetchall()
counterpart_accounts = {}
@@ -143,13 +154,13 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number,
p.name AS partner_name
FROM account_move_line l
LEFT JOIN account_move m on (l.move_id=m.id)
JOIN account_move m on (l.move_id=m.id)
LEFT JOIN res_currency c on (l.currency_id=c.id)
LEFT JOIN res_partner p on (l.partner_id=p.id)
LEFT JOIN account_invoice i on (m.id =i.move_id)
JOIN account_journal j on (l.journal_id=j.id)
WHERE %s AND l.account_id = %%s ORDER by %s
""" % (self.query, sql_sort)
WHERE %s AND m.state IN %s AND l.account_id = %%s ORDER by %s
""" %(self.query, tuple(move_state), sql_sort)
self.cr.execute(sql, (account.id,))
res_lines = self.cr.dictfetchall()
res_init = []
@@ -167,8 +178,8 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
LEFT JOIN res_partner p on (l.partner_id=p.id)
LEFT JOIN account_invoice i on (m.id =i.move_id)
JOIN account_journal j on (l.journal_id=j.id)
WHERE %s AND l.account_id = %%s
""" %(self.init_query)
WHERE %s AND m.state IN %s AND l.account_id = %%s
""" %(self.init_query, tuple(move_state))
self.cr.execute(sql, (account.id,))
res_init = self.cr.dictfetchall()
@@ -192,40 +203,73 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
return res
def _sum_debit_account(self, account):
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted','']
self.cr.execute('SELECT sum(debit) \
FROM account_move_line l \
JOIN account_move am ON (am.id = l.move_id) \
WHERE (l.account_id = %s) \
AND (am.state IN %s) \
AND '+ self.query +' '
,(account.id, tuple(move_state)))
sum_debit = self.cr.fetchone()[0] or 0.0
if self.init_balance:
self.cr.execute("SELECT sum(debit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
self.cr.execute('SELECT sum(debit) \
FROM account_move_line l \
JOIN account_move am ON (am.id = l.move_id) \
WHERE (l.account_id = %s) \
AND (am.state IN %s) \
AND '+ self.init_query +' '
,(account.id, tuple(move_state)))
# Add initial balance to the result
sum_debit += self.cr.fetchone()[0] or 0.0
return sum_debit
def _sum_credit_account(self, account):
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted','']
self.cr.execute('SELECT sum(credit) \
FROM account_move_line l \
JOIN account_move am ON (am.id = l.move_id) \
WHERE (l.account_id = %s) \
AND (am.state IN %s) \
AND '+ self.query +' '
,(account.id, tuple(move_state)))
sum_credit = self.cr.fetchone()[0] or 0.0
if self.init_balance:
self.cr.execute("SELECT sum(credit) "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
self.cr.execute('SELECT sum(credit) \
FROM account_move_line l \
JOIN account_move am ON (am.id = l.move_id) \
WHERE (l.account_id = %s) \
AND (am.state IN %s) \
AND '+ self.init_query +' '
,(account.id, tuple(move_state)))
# Add initial balance to the result
sum_credit += self.cr.fetchone()[0] or 0.0
return sum_credit
def _sum_balance_account(self, account):
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_balance "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s"%(account.id, self.query))
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted','']
self.cr.execute('SELECT (sum(debit) - sum(credit)) as tot_balance \
FROM account_move_line l \
JOIN account_move am ON (am.id = l.move_id) \
WHERE (l.account_id = %s) \
AND (am.state IN %s) \
AND '+ self.query +' '
,(account.id, tuple(move_state)))
sum_balance = self.cr.fetchone()[0] or 0.0
if self.init_balance:
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_balance "\
"FROM account_move_line l "\
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
self.cr.execute('SELECT (sum(debit) - sum(credit)) as tot_balance \
FROM account_move_line l \
JOIN account_move am ON (am.id = l.move_id) \
WHERE (l.account_id = %s) \
AND (am.state IN %s) \
AND '+ self.init_query +' '
,(account.id, tuple(move_state)))
# Add initial balance to the result
sum_balance += self.cr.fetchone()[0] or 0.0
return sum_balance
+85 -94
View File
@@ -1,32 +1,8 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(595.0,842.0)" title="Tax Code" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Accounting Entries" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="481" height="700"/>
<header>
<pageGraphics>
<setFont name="Helvetica-Bold" size="9"/>
<!--COL 1-->
<drawString x="1.0cm" y="28.1cm">[[ company.name ]]</drawString>
<drawRightString x="20cm" y="28.1cm">Accounting Entries-[[ company.currency_id.name ]]</drawRightString>
<!-- Header -->
<setFont name="Helvetica" size="9"/>
<drawString x="1.0cm" y="1cm"> [[ formatLang(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),date_time = True) ]]</drawString>
<drawString x="19.0cm" y="1cm">Page <pageNumber/></drawString>
<!--<drawRightString x="19.8cm" y="28cm">[[ company.rml_header1 ]]</drawRightString>-->
<lineMode width="0.7"/>
<lines>1cm 27.7cm 20cm 27.7cm</lines>
<setFont name="Helvetica" size="8"/>
</pageGraphics>
</header>
<frame id="first" x1="28.0" y1="42.0" width="539" height="758"/>
</pageTemplate>
</template>
<stylesheet>
@@ -34,28 +10,20 @@
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table_Title_Table">
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table_Line_Title">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,0" stop="4,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,0" stop="5,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,0" stop="6,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="4,1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="5,1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="6,1" stop="6,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="6,-1" stop="6,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Line_Content_Detail">
<blockAlignment value="LEFT"/>
@@ -71,19 +39,19 @@
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="P1" fontName="Helvetica-Bold" fontSize="11.0" leading="14" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
<paraStyle name="Heading" fontName="Helvetica" fontSize="15.0" leading="19" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Footer" fontName="Times-Roman"/>
<paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
<paraStyle name="Footer" fontName="Helvetica"/>
<paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
<paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="P8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
@@ -95,59 +63,82 @@
<paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<images/>
</stylesheet>
<images/>
<story>
<para style="P8">[[ repeatIn(objects, 'o') ]]</para>
<para style="terp_tblheader_Details">
<font color="white"></font>
</para>
<blockTable colWidths="162.0,222.0,154.0" repeatRows="1" style="Table_Title_Table">
<para style="terp_default_8">[[ repeatIn(objects, 'o') ]]</para>
<blockTable colWidths="539.0" repeatRows="1" style="Table2">
<tr>
<td><para style="terp_header">[[ o.company_id.name ]]</para></td>
<td><para style="terp_header"><font face="Times-Roman" size="11.0"/></para></td>
<td><para style="terp_header">Accounting Entries-[[ o.company_id.currency_id.name ]]</para></td>
<td>
<para style="terp_header_Centre">Accounting Entries-[[ company.currency_id.name ]]</para>
</td>
</tr>
</blockTable>
<para style="terp_tblheader_Details">
<font color="white"></font>
</para>
<para style="terp_tblheader_Details">[[ o.name ]]</para>
<para style="terp_tblheader_Details">
<font color="white"></font>
</para>
<section>
<blockTable colWidths="55.0,43.0,57.0,125.0,127.0,65.0,67.0" repeatRows="1" style="Table_Line_Title">
<tr>
<td><para style="terp_tblheader_Details_Centre">Date</para></td>
<td><para style="terp_tblheader_Details">Voucher Nb</para></td>
<td><para style="terp_tblheader_Details">Account Number</para></td>
<td><para style="terp_tblheader_Details">Third party (Country)</para></td>
<td><para style="terp_tblheader_Details">Entry label</para></td>
<td><para style="terp_tblheader_Details_Right">Debit</para></td>
<td><para style="terp_tblheader_Details_Right">Credit</para></td>
</tr>
<tr>
<td><para style="terp_default_9">[[ repeatIn(get_line(o),'line') ]]<font>[[ not line and removeParentNode('tr') ]]</font>[[ formatLang(line['date'],date=True) ]]</para></td>
<td><para style="terp_default_9">[[ line['ref'] ]]</para></td>
<td><para style="terp_default_9">[[ line['acode'] ]]</para></td>
<td><para style="terp_default_9">[[ line['pname'] ]]<font>([[ line['country'] ]] )</font></para></td>
<td><para style="terp_default_9">[[ line['name'] ]]</para></td>
<td><para style="terp_default_Right_9">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="terp_default_Right_9">[[ formatLang(line['credit']) ]]</para></td>
</tr>
</blockTable>
</section>
<para style="terp_default_8">
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="52.0,68.0,55.0,110.0,130.0,64.0,60.0" repeatRows="1" style="Table_Line_Title">
<tr>
<td>
<para style="terp_tblheader_Details">Date</para>
</td>
<td>
<para style="terp_tblheader_Details">Voucher No</para>
</td>
<td>
<para style="terp_tblheader_Details">A/c Code</para>
</td>
<td>
<para style="terp_tblheader_Details">Third Party (Country)</para>
</td>
<td>
<para style="terp_tblheader_Details">Entry Label</para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Debit<font face="Helvetica" size="8.0">([[ company.currency_id.name ]])</font></para>
</td>
<td>
<para style="terp_tblheader_Details_Right">Credit<font face="Helvetica" size="8.0">([[ company.currency_id.name ]])</font></para>
</td>
</tr>
</blockTable>
<section>
<para style="terp_default_8">[[ repeatIn(get_line(o),'line') ]]</para>
<blockTable colWidths="52.0,68.0,54.0,110.0,131.0,63.0,60.0" style="Table_Line_Content_Detail">
<tr>
<td>
<para style="terp_default_9">[[ not line and removeParentNode('blockTable') ]] [[ formatLang(line['date'],date=True) ]]</para>
</td>
<td>
<para style="terp_default_9">[[ line['ref'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ line['acode'] ]]</para>
</td>
<td>
<para style="terp_default_9">[[ line['pname'] ]] ([[ line['country'] ]] )</para>
</td>
<td>
<para style="terp_default_9">[[ line['name'] ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line['debit']) ]] [[ company.currency_id.symbol]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang(line['credit']) ]] [[ company.currency_id.symbol]]</para>
</td>
</tr>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>
</section>
</story>
</document>
</document>
+1 -1
View File
@@ -187,7 +187,7 @@
<para style="terp_default_Right_9">[[ (line['account_id']['type'] == 'receivable' and formatLang(line['credit']) or 0) or (line['account_id']['type'] == 'payable' and formatLang(line['debit'] * -1) or 0) ]] [[ company.currency_id.symbol ]]</para>
</td>
<td>
<para style="terp_default_Right_9">[[ formatLang((line['date_maturity'] &lt; time.strftime('%Y-%m-%d'))) and (line['debit'] - line['credit']) ]] [[ company.currency_id.symbol ]]</para>
<para style="terp_default_Right_9">[[ formatLang((line['date_maturity'] &lt; time.strftime('%Y-%m-%d'))) and formatLang(line['debit'] - line['credit']) ]] [[ company.currency_id.symbol ]]</para>
</td>
<td>
<para style="terp_default_Centre_9">[[ line['blocked'] and 'X' or '' ]]</para>
-2
View File
@@ -212,10 +212,8 @@ class tax_report(rml_parse.rml_parse):
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="internal")
+1 -1
View File
@@ -325,7 +325,7 @@
</tr>
<tr>
<td>
<para style="P9">[[ voucher.line_id and voucher.line_id.name and voucher.line_id.name[1] or removeParentNode('para') ]]</para>
<para style="P9">[[ voucher.line_id and voucher.line_id[0].name or removeParentNode('para') ]]</para>
</td>
<td>
<para style="P2">
@@ -29,8 +29,6 @@
"access_account_chart_template","account.chart.template","model_account_chart_template","account.group_account_manager",1,1,1,1
"access_account_tax_template","account.tax.template","model_account_tax_template","account.group_account_manager",1,0,0,0
"access_account_bank_statement","account.bank.statement","model_account_bank_statement","account.group_account_user",1,0,0,0
"access_account_bank_statement_reconcile","account.bank.statement.reconcile","model_account_bank_statement_reconcile","account.group_account_user",1,1,1,1
"access_account_bank_statement_reconcile_line","account.bank.statement.reconcile.line","model_account_bank_statement_reconcile_line","account.group_account_user",1,1,1,1
"access_account_bank_statement_line","account.bank.statement.line","model_account_bank_statement_line","account.group_account_user",1,0,0,0
"access_account_analytic_line","account.analytic.line","model_account_analytic_line","account.group_account_user",1,1,1,1
"access_account_analytic_line_manager","account.analytic.line manager","model_account_analytic_line","account.group_account_manager",1,0,0,0
@@ -182,7 +180,6 @@
"access_account_tax_code_accounting_accountant","account.tax.code","model_account_tax_code","account.group_accounting_accountant",1,0,0,0
"access_account_bank_statement_accounting_accountant","account.bank.statement","model_account_bank_statement","account.group_accounting_accountant",1,1,1,1
"access_account_cashbox_line_accounting_accountant","account.cashbox.line","model_account_cashbox_line","account.group_accounting_accountant",1,1,1,1
"access_account_bank_statement_reconcile_line","account.bank.statement.reconcile.line","model_account_bank_statement_reconcile_line","account.group_accounting_accountant",1,1,1,1
"access_account_bank_statement_line_accounting_accountant","account.bank.statement.line","model_account_bank_statement_line","account.group_accounting_accountant",1,1,1,1
"access_account_invoice_report_accounting_accountant","account.invoice.report","model_account_invoice_report","account.group_accounting_accountant",1,0,0,0
"access_report_account_receivable_accounting_accountant","report.account.receivable","model_report_account_receivable","account.group_accounting_accountant",1,0,0,0
@@ -197,7 +194,6 @@
"access_account_analytic_account_accounting_accountant","account.analytic.account","analytic.model_account_analytic_account","account.group_accounting_accountant",1,0,0,0
"access_account_analytic_line_accounting_accountant","account.analytic.line","analytic.model_account_analytic_line","account.group_accounting_accountant",1,0,0,0
"access_account_analytic_journal_accounting_accountant","account.analytic.journal","model_account_analytic_journal","account.group_accounting_accountant",1,0,0,0
"access_account_bank_statement_reconcile_accounting_accountant","account.bank.statement.reconcile","model_account_bank_statement_reconcile","account.group_accounting_accountant",1,1,1,1
"access_account_analytic_journal_analytic_accounting","account.analytic.journal","model_account_analytic_journal","analytic.group_analytic_accounting",1,1,1,1
"access_account_account_analytic_accounting","account.account","model_account_account","analytic.group_analytic_accounting",1,0,0,0
"access_product_product_analytic_accounting","product.product","product.model_product_product","analytic.group_analytic_accounting",1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
29 access_account_chart_template account.chart.template model_account_chart_template account.group_account_manager 1 1 1 1
30 access_account_tax_template account.tax.template model_account_tax_template account.group_account_manager 1 0 0 0
31 access_account_bank_statement account.bank.statement model_account_bank_statement account.group_account_user 1 0 0 0
access_account_bank_statement_reconcile account.bank.statement.reconcile model_account_bank_statement_reconcile account.group_account_user 1 1 1 1
access_account_bank_statement_reconcile_line account.bank.statement.reconcile.line model_account_bank_statement_reconcile_line account.group_account_user 1 1 1 1
32 access_account_bank_statement_line account.bank.statement.line model_account_bank_statement_line account.group_account_user 1 0 0 0
33 access_account_analytic_line account.analytic.line model_account_analytic_line account.group_account_user 1 1 1 1
34 access_account_analytic_line_manager account.analytic.line manager model_account_analytic_line account.group_account_manager 1 0 0 0
180 access_account_tax_code_accounting_accountant account.tax.code model_account_tax_code account.group_accounting_accountant 1 0 0 0
181 access_account_bank_statement_accounting_accountant account.bank.statement model_account_bank_statement account.group_accounting_accountant 1 1 1 1
182 access_account_cashbox_line_accounting_accountant account.cashbox.line model_account_cashbox_line account.group_accounting_accountant 1 1 1 1
access_account_bank_statement_reconcile_line account.bank.statement.reconcile.line model_account_bank_statement_reconcile_line account.group_accounting_accountant 1 1 1 1
183 access_account_bank_statement_line_accounting_accountant account.bank.statement.line model_account_bank_statement_line account.group_accounting_accountant 1 1 1 1
184 access_account_invoice_report_accounting_accountant account.invoice.report model_account_invoice_report account.group_accounting_accountant 1 0 0 0
185 access_report_account_receivable_accounting_accountant report.account.receivable model_report_account_receivable account.group_accounting_accountant 1 0 0 0
194 access_account_analytic_account_accounting_accountant account.analytic.account analytic.model_account_analytic_account account.group_accounting_accountant 1 0 0 0
195 access_account_analytic_line_accounting_accountant account.analytic.line analytic.model_account_analytic_line account.group_accounting_accountant 1 0 0 0
196 access_account_analytic_journal_accounting_accountant account.analytic.journal model_account_analytic_journal account.group_accounting_accountant 1 0 0 0
access_account_bank_statement_reconcile_accounting_accountant account.bank.statement.reconcile model_account_bank_statement_reconcile account.group_accounting_accountant 1 1 1 1
197 access_account_analytic_journal_analytic_accounting account.analytic.journal model_account_analytic_journal analytic.group_analytic_accounting 1 1 1 1
198 access_account_account_analytic_accounting account.account model_account_account analytic.group_analytic_accounting 1 0 0 0
199 access_product_product_analytic_accounting product.product product.model_product_product analytic.group_analytic_accounting 1 0 0 0
@@ -21,16 +21,23 @@
-
I made modification in journal so it can move entries
-
!record {model: account.journal, id: account.sales_journal}:
!record {model: account.journal, id: account.close_journal}:
name: End of Year
code: NEW
type: situation
sequence_id: sequence_journal
default_debit_account_id: cash
default_credit_account_id: cash
company_id: base.main_company
view_id: account_journal_bank_view
centralisation: 1
-
I called the Generate Fiscalyear Opening Entries wizard
-
!record {model: account.fiscalyear.close, id: account_fiscalyear_close_0}:
fy2_id: account_fiscalyear_fiscalyear0
fy_id: account.data_fiscalyear
journal_id: account.sales_journal
journal_id: account.close_journal
period_id: account_period_jan11
report_name: End of Fiscal Year Entry
-
+386
View File
@@ -0,0 +1,386 @@
-
In order to test the PDF reports defined on an invoice, we will print an invoice
-
!python {model: account.invoice}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.account.invoice').create(cr, uid, [ref('account.test_invoice_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-invoice.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a partner, we will print the Overdue Report
-
!python {model: res.partner}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.account.overdue').create(cr, uid, [ref('base.res_partner_asus'),ref('base.res_partner_agrolait'),ref('base.res_partner_c2c')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-report_overdue.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on Account Move, we will print the Voucher Report
-
!python {model: account.move}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.account.move.voucher').create(cr, uid, [ref('account.account_move_0')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-voucher-report.'+format), 'wb+').write(data)
-
Demo data for Account tax code
-
!record {model: account.tax.code, id: account_tax_code_0}:
name : Tax Code Test
-
Print Tax Code entries report
-
!python {model: account.tax.code}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.account.tax.code.entries').create(cr, uid, [ref('account_tax_code_0')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-tax-code-entries.'+format), 'wb+').write(data)
-
Print Vat Declaration Report
-
!python {model: account.tax.code}: |
import netsvc, tools, os
data_dict = {'model': 'ir.ui.menu', 'form': {'based_on': 'invoices','company_id':ref('base.main_company'),'periods':[]}}
(data, format) = netsvc.LocalService('report.account.vat.declaration').create(cr, uid, [ref("account_tax_code_0")], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-vat-declaration.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on an invoice, we will print an invoice
-
!python {model: account.invoice}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.account.invoice').create(cr, uid, [ref('account.test_invoice_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-invoice.'+format), 'wb+').write(data)
-
Print the Aged Partner Balance Report
-
!python {model: res.partner}: |
import netsvc, tools, os, time
import datetime
from mx.DateTime import *
start = datetime.date.fromtimestamp(time.mktime(time.strptime(time.strftime('%Y-%m-%d'), "%Y-%m-%d")))
start = DateTime(int(start.year), int(start.month), int(start.day))
res = {}
for i in range(5)[::-1]:
stop = start - RelativeDateTime(days=30)
res[str(i)] = {
'name': (i!=0 and (str((5-(i+1)) * 30) + '-' + str((5-i) * 30)) or ('+'+str(4 * 30))),
'stop': start.strftime('%Y-%m-%d'),
'start': (i!=0 and stop.strftime('%Y-%m-%d') or False),
}
start = stop - RelativeDateTime(days=1)
obj_move = self.pool.get('account.move.line')
ctx = {}
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'ir.ui.menu', 'form': {'chart_account_id':ref('account.chart0'),'initial_balance': 1, 'periods': period_list,'journal_ids':journal_ids, 'page_split': 0, 'date_from': time.strftime('%Y-%m-%d'), 'period_length': 30, 'amount_currency': 0,'query_line' : query_line, 'result_selection': 'customer','direction_selection': 'past','fiscalyear_id':fy_id}}
data_dict['form'].update(res)
(data, format) = netsvc.LocalService('report.account.aged_trial_balance').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-aged_partner_balance.'+format), 'wb+').write(data)
-
Print the Compare Account Balance Report in Normal mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.account', 'form': {'id':ref('account.bal'),'chart_account_id':ref('account.chart0'),'select_account': False,'format_perc':0,'show_columns' :0, 'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear': [ref('account.data_fiscalyear')] ,'target_move': 'all','periods': [],'context':{'state':'all'}}}
(data, format) = netsvc.LocalService('report.account.balance.account.balance').create(cr, uid, [ref('account.bal'),ref('account.gpf')], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-compare-account_balance.'+format), 'wb+').write(data)
-
Print the Compare Account Balance Report in Landscape mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.account', 'form': {'id':ref('account.bal'),'chart_account_id':ref('account.chart0'),'select_account': False,'format_perc':0,'show_columns' :0, 'compare_pattern': 'none','account_choice': 'moves','landscape':1,'period_manner': 'actual','fiscalyear': [ref('account.data_fiscalyear')] ,'target_move': 'all','periods': [],'context':{'state':'all'}}}
(data, format) = netsvc.LocalService('report.account.account.balance.landscape').create(cr, uid, [ref('account.bal'),ref('account.gpf')], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-compare-account_balance-landscape.'+format), 'wb+').write(data)
-
Print the Account Balance Sheet in Horizontal mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'ir.ui.menu', 'form': {'reserve_account_id':ref('account.rsa') ,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 1,'journal_ids':[],'fiscalyear': ref('account.data_fiscalyear') ,'target_move': 'all'}}
(data, format) = netsvc.LocalService('report.account.balancesheet.horizontal').create(cr, uid, [], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-account_balance_sheet_horizontal.'+format), 'wb+').write(data)
-
Print the Account Balance Sheet in Normal mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'ir.ui.menu', 'form': {'reserve_account_id':ref('account.rsa') ,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':[],'fiscalyear': ref('account.data_fiscalyear') ,'target_move': 'all'}}
(data, format) = netsvc.LocalService('report.account.balancesheet').create(cr, uid, [], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-account_balance_sheet.'+format), 'wb+').write(data)
-
Print the Account Balance Report in Normal mode - From Account Chart
-
!python {model: account.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.account', 'form': {'chart_account_id':ref('account.chart0'),'select_account': False,'display_account':'bal_all','format_perc':0,'filter': 'filter_no','show_columns' :0, 'account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': ref('account.data_fiscalyear') ,'target_move': 'all','periods': [],'id':ref('account.bal'),'context':{'state':'all'}}}
(data, format) = netsvc.LocalService('report.account.account.balance').create(cr, uid, [ref('account.bal'),ref('account.gpf')], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-account_balance-normal.'+format), 'wb+').write(data)
print "Account Balance Report in Normal mode - From Menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids':[ref('account.bal'),ref('account.gpf')]})
(data, format) = netsvc.LocalService('report.account.account.balance').create(cr, uid, [], data_dict, {'periods': []})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-account_balance-normal-menu.'+format), 'wb+').write(data)
-
Print the Central Journal Report - From Account
-
!python {model: account.journal.period}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'account.journal.period', 'id':journal_period_ids[0], 'form': {'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
(data, format) = netsvc.LocalService('report.account.central.journal').create(cr, uid, journal_period_ids, data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-central_journal.'+format), 'wb+').write(data)
print "Central Journal Report - From Menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids':journal_period_ids})
(data, format) = netsvc.LocalService('report.account.central.journal').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-central_journal-menu.'+format), 'wb+').write(data)
-
Print the General Journal Report - From Journal
-
!python {model: account.journal.period}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'ir.ui.menu','id':journal_period_ids[0], 'form': {'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids, 'active_ids':journal_period_ids}}
(data, format) = netsvc.LocalService('report.account.general.journal').create(cr, uid, journal_period_ids, data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_journal.'+format), 'wb+').write(data)
-
Print the General Ledger Report in Normal Mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
acc_ids = [ref('account.bal'),ref('account.gpf')]
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'account.account', 'form': {'initial_balance': 1,'initial_bal_query': query_line,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','sortby': 'sort_date','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
(data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, acc_ids, data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger.'+format), 'wb+').write(data)
print "GL report from menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids': acc_ids})
(data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-menu.'+format), 'wb+').write(data)
-
Print the General Ledger Report in Landscape Mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
acc_ids = [ref('account.bal'),ref('account.gpf')]
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'account.account', 'form': {'initial_balance': 1,'initial_bal_query':query_line,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','sortby': 'sort_date','amount_currency': 0,'landscape':1,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
(data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, acc_ids, data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-landscape.'+format), 'wb+').write(data)
print "GL report landscape mode from menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids': acc_ids})
(data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-general_ledger-landscape-menu.'+format), 'wb+').write(data)
-
Print Journal Report - From Model
-
!python {model: account.journal.period}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context)
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'account.journal.period', 'id':journal_period_ids[0], 'form': {'sort_selection': 'date','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }}
(data, format) = netsvc.LocalService('report.account.journal.period.print').create(cr, uid, journal_period_ids, data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-print_journal.'+format), 'wb+').write(data)
print "Journal Report - From Menu"
data_dict.update({'model': 'ir.ui.menu'})
data_dict['form'].update({'active_ids':journal_period_ids})
(data, format) = netsvc.LocalService('report.account.journal.period.print').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-print_journal-menu.'+format), 'wb+').write(data)
-
Print the Partner Balance Report
-
!python {model: res.partner}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'ir.ui.menu', 'form': {'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}}
(data, format) = netsvc.LocalService('report.account.partner.balance').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-partner_balance.'+format), 'wb+').write(data)
-
Print the Partner Ledger Report
-
!python {model: res.partner}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'ir.ui.menu', 'form': {'initial_bal_query':query_line,'amount_currency': 0,'reconcil': True,'initial_balance':1,'page_split': True,'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}}
(data, format) = netsvc.LocalService('report.account.third_party_ledger').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-partner_ledger.'+format), 'wb+').write(data)
-
Print the Partner Ledger-Other Report
-
!python {model: res.partner}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')]
obj_move = self.pool.get('account.move.line')
ctx = {}
ctx['fiscalyear'] = fy_id
ctx['journal_ids'] = journal_ids
ctx['chart_account_id'] = ref('account.chart0')
query_line = obj_move._query_get(cr, uid, obj='l', context=ctx)
data_dict = {'model': 'ir.ui.menu', 'form': {'initial_bal_query':query_line,'amount_currency': 0,'reconcil': True,'initial_balance':1,'page_split': False,'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}}
(data, format) = netsvc.LocalService('report.account.third_party_ledger_other').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-partner_ledger-other.'+format), 'wb+').write(data)
-
Print the Profit-Loss Report in Normal Mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = []
acc_ids = [ref('account.bal'),ref('account.gpf')]
data_dict = {'model': 'ir.ui.menu', 'form': {'display_type': False,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':'True ','target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal'),'active_ids':acc_ids }}
(data, format) = netsvc.LocalService('report.pl.account').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-profit-loss.'+format), 'wb+').write(data)
-
Print the Profit-Loss Report in Horizontal Mode
-
!python {model: account.account}: |
import netsvc, tools, os, time
fy_id = ref('account.data_fiscalyear')
period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context)
journal_ids = []
acc_ids = [ref('account.bal'),ref('account.gpf')]
data_dict = {'model': 'ir.ui.menu', 'form': {'display_type': True,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':'True ','target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal'),'active_ids':acc_ids }}
(data, format) = netsvc.LocalService('report.pl.account.horizontal').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account-profit-loss-horizontal.'+format), 'wb+').write(data)
+5 -5
View File
@@ -54,14 +54,14 @@ class account_chart(osv.osv_memory):
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear_id=False, context=None):
res = {}
res['value'] = {'period_from': False, 'period_to': False}
res['value'] = {}
if fiscalyear_id:
start_period = end_period = False
cr.execute('''
SELECT * FROM (SELECT p.id
FROM account_period p
LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
SELECT * FROM (SELECT p.id
FROM account_period p
LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
WHERE f.id = %s
ORDER BY p.date_start ASC
LIMIT 1) AS period_start
UNION
+3 -3
View File
@@ -9,11 +9,11 @@
<form string="Account charts">
<group colspan="4">
<field name="fiscalyear" on_change="onchange_fiscalyear(fiscalyear)"/>
<field name="target_move"/>
<label align="0.7" colspan="4" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
<separator string="Periods" colspan="4"/>
<field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear)]"/>
<field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear)]"/>
<field name="target_move"/>
<field name="period_from"/>
<field name="period_to"/>
</group>
<separator string="" colspan="4"/>
<group colspan="4" col="6">
@@ -37,14 +37,11 @@ class account_aged_trial_balance(osv.osv_memory):
'direction_selection': fields.selection([('past','Past'),
('future','Future')],
'Analysis Direction', required=True),
'target_move': fields.selection([('all', 'All Entries'),
('posted', 'All Posted Entries')], 'Target Moves', required=True),
}
_defaults = {
'period_length': 30,
'date_from' : time.strftime('%Y-%m-%d'),
'direction_selection': 'past',
'target_move': 'all',
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
@@ -64,7 +61,7 @@ class account_aged_trial_balance(osv.osv_memory):
context = {}
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['period_length', 'direction_selection', 'target_move'])[0])
data['form'].update(self.read(cr, uid, ids, ['period_length', 'direction_selection'])[0])
period_length = data['form']['period_length']
if period_length<=0:
@@ -81,7 +78,7 @@ class account_aged_trial_balance(osv.osv_memory):
'name': (i!=0 and (str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length)) or ('+'+str(4 * period_length))),
'stop': start.strftime('%Y-%m-%d'),
'start': (i!=0 and stop.strftime('%Y-%m-%d') or False),
}
}
start = stop - RelativeDateTime(days=1)
else:
for i in range(5):
@@ -90,7 +87,7 @@ class account_aged_trial_balance(osv.osv_memory):
'name' : (i!=4 and str((i) * period_length)+'-' + str((i+1) * period_length) or ('+'+str(4 * period_length))),
'start': start.strftime('%Y-%m-%d'),
'stop': (i!=4 and stop.strftime('%Y-%m-%d') or False),
}
}
start = stop + RelativeDateTime(days=1)
data['form'].update(res)
@@ -98,7 +95,7 @@ class account_aged_trial_balance(osv.osv_memory):
'type': 'ir.actions.report.xml',
'report_name': 'account.aged_trial_balance',
'datas': data
}
}
account_aged_trial_balance()
@@ -12,6 +12,7 @@
<field name="display_account"/>
<field name="target_move"/>
<field name="display_type"/>
<field name="reserve_account_id"/>
<newline/>
</field>
</field>
@@ -30,15 +30,19 @@ class account_common_partner_report(osv.osv_memory):
('supplier','Payable Accounts'),
('customer_supplier' ,'Receivable and Payable Accounts')],
"Partner's", required=True),
'target_move': fields.selection([('all', 'All Entries'),
('posted', 'All Posted Entries')], 'Target Moves', required=True),
}
_defaults = {
'result_selection': 'customer',
'target_move': 'all'
}
def pre_print_report(self, cr, uid, ids, data, query_line, context=None):
if context is None:
context = {}
data['form'].update(self.read(cr, uid, ids, ['result_selection'])[0])
data['form'].update(self.read(cr, uid, ids, ['result_selection', 'target_move'])[0])
return data
account_common_partner_report()
@@ -32,12 +32,15 @@ class account_report_general_ledger(osv.osv_memory):
help='It adds initial balance row on report which display previous sum amount of debit/credit/balance'),
'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"),
'sortby': fields.selection([('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], 'Sort By', required=True),
'target_move': fields.selection([('all', 'All Entries'),
('posted', 'All Posted Entries')], 'Target Moves', required=True),
}
_defaults = {
'landscape': True,
'amount_currency': True,
'sortby': 'sort_date',
'initial_balance': False,
'target_move': 'all',
}
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, context=None):
@@ -50,7 +53,7 @@ class account_report_general_ledger(osv.osv_memory):
if context is None:
context = {}
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby'])[0])
data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby', 'target_move'])[0])
if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record
data['form'].update({'initial_balance': False})
if data['form']['landscape']:
@@ -10,6 +10,7 @@
<field name="arch" type="xml">
<field name="fiscalyear_id" position="after">
<field name="display_account"/>
<field name="target_move"/>
<field name="sortby"/>
<field name="landscape"/>
<field name="initial_balance" attrs="{'readonly':[('fiscalyear_id','=', False)]}"/>
@@ -33,25 +33,23 @@ class account_partner_balance(osv.osv_memory):
# ,help='It adds initial balance row on report which display previous sum amount of debit/credit/balance'),
'display_partner': fields.selection([('non-zero_balance', 'With balance is not equal to 0'), ('all', 'All Partners')]
,'Display Partners'),
'target_move': fields.selection([('all', 'All Entries'),
('posted', 'All Posted Entries')], 'Target Moves', required=True),
}
}
_defaults = {
# 'initial_balance': True,
'display_partner': 'non-zero_balance',
'target_move': 'all'
}
}
def _print_report(self, cr, uid, ids, data, query_line, context=None):
if context is None:
context = {}
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['display_partner', 'target_move'])[0])
data['form'].update(self.read(cr, uid, ids, ['display_partner'])[0])
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.partner.balance',
'datas': data,
}
}
account_partner_balance()
@@ -35,28 +35,25 @@ class account_partner_ledger(osv.osv_memory):
'reconcil': fields.boolean('Include Reconciled Entries', help='Consider reconciled entries'),
'page_split': fields.boolean('One Partner Per Page', help='Display Ledger Report with One partner per page'),
'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"),
'target_move': fields.selection([('all', 'All Entries'),
('posted', 'All Posted Entries')], 'Target Moves', required=True),
}
_defaults = {
'reconcil': True,
'initial_balance': True,
'page_split': False,
'target_move': 'all'
}
def _print_report(self, cr, uid, ids, data, query_line, context=None):
if context is None:
context = {}
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'reconcil', 'page_split', 'amount_currency', 'target_move'])[0])
data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'reconcil', 'page_split', 'amount_currency'])[0])
if data['form']['page_split']:
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.third_party_ledger',
'datas': data,
}
}
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.third_party_ledger_other',
@@ -66,6 +66,7 @@ of distribution models.
'wizard/account_crossovered_analytic_view.xml'
],
'demo_xml' : [],
'test' : ['test/acount_analytic_plans_report.yml'],
'installable': True,
'active' : False,
'certificate': '0036417675373',
@@ -96,17 +96,19 @@ class crossovered_analytic(report_sxw.rml_parse):
self.final_list = children_list
selected_ids = line_pool.search(self.cr,self.uid,[('account_id','in',self.final_list)])
if selected_ids:
query="SELECT sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \
WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"
self.cr.execute(query)
info=self.cr.dictfetchall()
query="SELECT sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \
WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"
self.cr.execute(query)
info=self.cr.dictfetchall()
res['ref_qty']=info[0]['qty']
res['ref_amt']=info[0]['amt']
self.base_amount= info[0]['amt']
res['ref_qty']=info[0]['qty']
res['ref_amt']=info[0]['amt']
self.base_amount= info[0]['amt']
res['ref_qty']=0.0
res['ref_amt']=0.0
self.base_amount= 0.0
result.append(res)
return result
@@ -0,0 +1,9 @@
-
Print the Cross Overed Report in Normal mode
-
!python {model: account.analytic.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.analytic.account', 'form': {'date1':time.strftime("%Y-01-01"),'date2':time.strftime('%Y-%m-%d'),'journal_ids':[6,0,(ref('account.cose_journal_sale'))],'ref':ref('account.analytic_root'),'empty_line':True,'id':ref('account.analytic_root'),'context':{}}}
(data, format) = netsvc.LocalService('report.account.analytic.account.crossovered.analytic').create(cr, uid, [ref('account.analytic_root')], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_analytic_plans-crossovered_analyitic.'+format), 'wb+').write(data)
+1
View File
@@ -63,6 +63,7 @@ Three reports are available:
'demo_xml': ['crossovered_budget_demo.xml'],
'test':[
'test/account_budget.yml',
'test/account_budget_report.yml',
],
'installable': True,
'active': False,
@@ -0,0 +1,27 @@
-
Print the Analytic Budget Report in Normal mode
-
!python {model: account.analytic.account}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.analytic.account', 'form': {'date1':time.strftime("%Y-01-01"),'date2':time.strftime('%Y-%m-%d'),'id':ref('account.analytic_root'),'context':{}}}
(data, format) = netsvc.LocalService('report.account.analytic.account.budget').create(cr, uid, [ref('account.analytic_root')], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_budget-analytic_budget_report.'+format), 'wb+').write(data)
-
Print the Budget Report in Normal mode
-
!python {model: account.budget.post}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.budget.post', 'form': {'date1':time.strftime("%Y-01-01"),'date2':time.strftime('%Y-%m-%d'),'id':ref('account_budget.account_budget_post_sales0'),'context':{}}}
(data, format) = netsvc.LocalService('report.account.analytic.account.budget').create(cr, uid, [ref('account_budget.account_budget_post_sales0')], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_budget-budget_report.'+format), 'wb+').write(data)
-
Print the Cross Overed Budget Report in Normal mode
-
!python {model: crossovered.budget}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.budget.post', 'form': {'date_from':time.strftime("%Y-01-01"),'date_to':time.strftime('%Y-%m-%d'),'report':'analytic-full','id':ref('account_budget.crossovered_budget_budgetoptimistic0'),'context':{}}}
(data, format) = netsvc.LocalService('report.crossovered.budget.report').create(cr, uid, [ref('account_budget.crossovered_budget_budgetoptimistic0')], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_budget-crossovered_budget_report.'+format), 'wb+').write(data)
@@ -42,7 +42,7 @@ class account_budget_crossvered_report(osv.osv_memory):
data = self.read(cr, uid, ids)[0]
datas = {
'ids': context.get('active_ids',[]),
'model': 'crossovered.budge',
'model': 'crossovered.budget',
'form': data
}
datas['form']['report']='analytic-full'
+2 -1
View File
@@ -45,7 +45,8 @@
'account_invoice_layout_report.xml',
'wizard/account_invoice_special_message.xml',
],
'demo_xml': [],
'demo_xml': ['account_invoice_layout_demo.xml'],
'test':['test/account_invoice_layout_report.yml'],
'installable': True,
'active': False,
'certificate': '0057235078173',
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="demo_message1" model="notify.message">
<field name="name">OpenERP SA</field>
<field name="msg">ERP & CRM Solutions....</field>
</record>
<record id="demo_message1" model="notify.message">
<field name="name">Tiny sprl</field>
<field name="msg">Be Expert with the Experts...</field>
</record>
</data>
</openerp>
@@ -297,7 +297,7 @@
</para>
</td>
<td>
<para style="terp_default_Note">Note: [[ (a['note'] and format(a['note'])) or removeParentNode('tr') ]]</para>
<para style="terp_default_Note">Note: [[ (a['note'] and format(a['note'] or '')) or removeParentNode('tr') ]]</para>
<para style="terp_default_Note">
<font color="white"> </font>
</para>
@@ -337,7 +337,7 @@
</para>
</td>
<td>
<para style="terp_default_9">[[ a['type']=='text' and format(a['name']) or removeParentNode('blockTable') ]]</para>
<para style="terp_default_9">[[ a['type']=='text' and format(a['name'] or '') or removeParentNode('blockTable') ]]</para>
</td>
<td>
<para style="terp_default_9">[[ a['type']=='text' and '' ]]</para>
@@ -467,7 +467,7 @@
<blockTable colWidths="539.0" style="Table_Coment_Payment_Term">
<tr>
<td>
<para style="terp_default_9">[[ format(o.comment or removeParentNode('blockTable')) ]]</para>
<para style="terp_default_9">[[ format(o.comment or '') or removeParentNode('blockTable') ]]</para>
</td>
</tr>
</blockTable>
@@ -477,7 +477,7 @@
<blockTable colWidths="539.0" style="Table_Payment_Terms">
<tr>
<td>
<para style="terp_default_9">[[ format((o.payment_term and o.payment_term.note) or removeParentNode('blockTable')) ]]</para>
<para style="terp_default_9">[[ format((o.payment_term and o.payment_term.note or '') or removeParentNode('blockTable')) ]]</para>
</td>
</tr>
</blockTable>
@@ -0,0 +1,17 @@
-
Print the Invoice layout report in Normal Mode
-
!python {model: account.invoice}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.account.invoice.layout').create(cr, uid, [ref('account.test_invoice_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_invoice_layout.'+format), 'wb+').write(data)
-
Print the Invoice Layout Report with Message in Normal mode
-
!python {model: account.invoice}: |
import netsvc, tools, os, time
data_dict = {'model': 'account.invoice', 'form': {'message':ref('account_invoice_layout.demo_message1'),'id':ref('account.test_invoice_1'),'context':{}}}
(data, format) = netsvc.LocalService('report.notify_account.invoice').create(cr, uid, [ref('account.test_invoice_1')], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_invoice_layout_message_report.'+format), 'wb+').write(data)
+5 -2
View File
@@ -47,8 +47,11 @@
'account_invoice_view.xml',
'account_payment_report.xml',
],
'demo_xml': [],
'test': ['test/account_payment.yml'],
'demo_xml': ['account_payment_demo.xml'],
'test': [
'test/account_payment.yml'
'test/account_payment_report.yml'
],
'installable': True,
'active': False,
'certificate': '0061703998541',
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="partner_bank_1" model="res.partner.bank">
<field name="name">Reserve Bank</field>
<field name="acc_number">00987654321</field>
<field name="partner_id" ref="base.res_partner_agrolait"></field>
<field name="state" eval="bank"/>
</record>
<record id="payment_mode_1" model="payment.mode">
<field name="name">Direct Payment</field>
<field name="journal" ref="account.sales_journal"/>
<field name="bank_id" ref="account_payment.partner_bank_1"/>
<field name="company_id" ref="base.main_company"/>
</record>
<record id="payment_order_1" model="payment.order">
<field name="reference">ORDER1</field>
<field name="mode" ref="account_payment.payment_mode_1"/>
<field name="user_id" ref="base.user_root"/>
<field name="date_prefered">now</field>
<field name="state">draft</field>
</record>
</data>
</openerp>
@@ -0,0 +1,8 @@
-
In order to test the PDF reports defined on Account Payment, Print a Payment Order
-
!python {model: payment.order}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.payment.order').create(cr, uid, [ref('account_payment.payment_order_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_payment-payment_order_report.'+format), 'wb+').write(data)
+2 -1
View File
@@ -42,7 +42,8 @@
'wizard/account_report_print_indicators_with_pdf_view.xml',
'board_account_report_view.xml',
],
'demo_xml': [],
'demo_xml': ['account_report_demo.xml'],
'test': ['test/account_report.yml'],
'installable': True,
'active': False,
'certificate': '0050976406925',
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="account_report_1" model="account.report.report">
<field name="name">Account Demo Report</field>
<field name="code">ADR</field>
<field name="type">fiscal</field>
<field name="expression">debit&gt;0.0</field>
</record>
</data>
</openerp>
@@ -119,7 +119,7 @@
</blockTable>
<blockTable colWidths="528.0" repeatRows="1" style="Table7">
<tr>
<td><para style="P5"> <font color="white">[['..........'*(o['level']) ]]</font> <font>[[ format(o['note']) or removeParentNode('blockTable') ]]</font></para></td>
<td><para style="P5"> <font color="white">[['..........'*(o['level']) ]]</font> <font>[[ format(o['note'] or '') or removeParentNode('blockTable') ]]</font></para></td>
</tr>
</blockTable>
</section>
@@ -0,0 +1,17 @@
-
In order to test the PDF reports defined on Account, Print a Financial Statement Report
-
!python {model: account.report.report}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.accounting.report').create(cr, uid, [ref('account_report.account_report_1')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_report-financial_statement_report.'+format), 'wb+').write(data)
-
Print the Indicators Report in Normal mode
-
!python {model: account.report.history }: |
import netsvc, tools, os, time
data_dict = {'model': 'ir.ui.menu', 'form': {'select_base':'year','base_selection':[ref('account.data_fiscalyear')],'context':{}}}
(data, format) = netsvc.LocalService('report.print.indicators').create(cr, uid, [], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_report-indicators_report.'+format), 'wb+').write(data)
+2 -1
View File
@@ -36,7 +36,8 @@
'account_data.xml',
'wizard/account_reporting_balance_report_view.xml',
],
'demo_xml': [],
'demo_xml': ['account_reporting_demo.xml'],
'test': ['test/account_reporting_report.yml'],
'installable': True,
'active': False,
'certificate': '0072305016797',
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="account_balance_sheet_1" model="account.report.bs">
<field name="name">My Balance Sheet</field>
<field name="code">MBS</field>
</record>
</data>
</openerp>
@@ -10,14 +10,52 @@
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table1">
<blockTableStyle id="Table_Company_Name">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="Table2a">
<blockValign value="TOP"/>
<blockAlignment value="RIGHT"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Table3">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="0,0" stop="0,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="0,0" stop="0,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="1,0" stop="1,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="1,0" stop="1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="2,0" stop="2,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="2,0" stop="2,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBEFORE" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEAFTER" colorName="#e6e6e6" start="3,0" stop="3,-1"/>
<lineStyle kind="LINEABOVE" colorName="#e6e6e6" start="3,0" stop="3,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Table7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
@@ -25,7 +63,7 @@
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,2" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,1"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
@@ -41,26 +79,32 @@
</initialize>
<paraStyle name="P1" fontName="Helvetica" fontSize="15.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3a" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P8" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10"/>
<paraStyle name="P10" fontName="Helvetica" fontSize="9.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P10" fontName="Helvetica-Bold" fontSize="8.0" leading="14" spaceBefore="0.0" spaceAfter="6.0" alignment="RIGHT"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12a" fontName="Helvetica" fontSize="12.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12a" fontName="Helvetica-Bold" fontSize="9.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P12b" fontName="Helvetica-Bold" fontSize="9.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P13" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" rightIndent="17.0" leftIndent="-0.0" fontName="Helvetica-Bold" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="P15" fontName="Helvetica" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Helvetica" fontSize="9.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Helvetica" fontSize="9.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
<paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
@@ -69,63 +113,49 @@
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<story>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table1">
<tr>
<td>
<para style="Table Contents"><font color='blue'>[[ company.name ]]</font></para>
</td>
<td>
<para style="P3">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P4"><font color='blue'>Currency: [[ company.currency_id.name ]]</font></para>
</td>
</tr>
</blockTable>
<para style="P8"><font color='blue'>Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]]</font></para>
<para style="P7">[[repeatIn(objects,'o') ]]</para>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table2">
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="539.0" style="Table_Company_Name">
<tr>
<td>
<para style="Table Contents">
<font color="white"> </font>
</para>
</td>
<td>
<para style="P1"><font>[[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]] [[o.name]]</font></para>
</td>
<td>
<para style="P2">
<font color="white"> </font>
</para>
<para style="terp_header_Centre">Account Balance</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="131.0,280.0,131.0" style="Table7">
<para style="terp_default_8">
<font color="white"> </font>
</para>
<blockTable colWidths="132.0,134.0,135.0,135.0" style="Table2">
<tr>
<td>
<para style="P12a" ><font color='blue'>Code</font></para>
<para style="terp_tblheader_General_Centre">Company Name</para>
</td>
<td>
<para style="P12a"><font color='blue'>Account Name</font></para>
<para style="terp_tblheader_General_Centre">Printing date</para>
</td>
<td>
<para style="P13"><font color='blue'>Balance</font></para>
<para style="terp_tblheader_General_Centre">Currency</para>
</td>
<td>
<para style="terp_tblheader_General_Centre">Name</para>
</td>
</tr>
</blockTable>
<blockTable colWidths="131.0,280.0,131.0" style="Table4">
</blockTable>
<blockTable colWidths="132.0,134.0,135.0,135.0" style="Table3">
<tr>
<td>
<para style="P10"><font>[[ repeatIn(lines(data['form'],object=o), 'a') ]]</font><font>[[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]] [[ a['code'] ]]</font></para>
<para style="terp_default_Centre_8">[[ company.name ]]</para>
</td>
<td>
<para style="P17"><font color="white">[[ '..'*(a['level']-1) ]]</font><font>[[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]] [[ a['name'] ]]</font></para>
<para style="terp_default_Centre_8">[[ formatLang(time.strftime('%Y-%m-%d %H:%M:%S'), date_time = True) ]]</para>
</td>
<td>
<para style="P18"><font>[[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]][[ '%.2f'% a['balance'] ]]</font></para>
<para style="terp_default_Centre_8">[[ company.currency_id.name ]]</para>
</td>
<td>
<para style="terp_default_Centre_8"><font>[[ setTag('font','font',{'face':o.font_style,'color':o.color_font.name,'backColor':o.color_back.name}) ]] [[o.name]]</font></para>
</td>
</tr>
</blockTable>
@@ -135,6 +165,27 @@
<para style="Standard">
<font color="white"> </font>
</para>
<blockTable colWidths="80.0,382.0,80.0" style="Table2a" repeatRows="1">
<tr noRowsplits="1">
<td>
<para style="P12a">Code</para>
</td>
<td>
<para style="P12a">Account Name</para>
</td>
<td>
<para style="P12b">Balance([[company.currency_id.code]])</para>
</td>
</tr>
<tr>
<td>
<para style="P14">[[ repeatIn(lines(data['form']), 'a') ]]<font>[[ (a['level']&gt;4 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]]</font><i>[[ a['code'] or removeParentNode('tr')]]</i></para>
</td>
<td><para style="P14"><font>[[ (a['level']&gt;4 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]]</font><font color="white">[[ '..'*(a['level']-1) ]]</font><font>[[ a['name'] ]]</font> </para></td>
<td>
<para style="P3"><font>[[ (a['level']&gt;4 and setTag('para','para',{'fontName':"Helvetica"})) or removeParentNode('font') ]]</font><font >[[ formatLang(a['balance']) ]] [[company.currency_id.symbol]]</font></para>
</td>
</tr>
</blockTable>
</story>
</document>
@@ -0,0 +1,9 @@
-
Print the Balance Sheet Report in Normal mode
-
!python {model: account.report.bs }: |
import netsvc, tools, os, time
data_dict = {'model': 'account.report.bs', 'form': {'fiscalyear':ref('account.data_fiscalyear'),'periods':[ref('account.period_1'),ref('account.period_2'),ref('account.period_3')],'context':{}}}
(data, format) = netsvc.LocalService('report.account.report.bs').create(cr, uid, [ref('account_reporting.account_balance_sheet_1')], data_dict, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_reporting-balance_sheet_report.'+format), 'wb+').write(data)
+1
View File
@@ -52,6 +52,7 @@
# "test/account_voucher.yml",
# "test/sales_receipt.yml",
# "test/sales_payment.yml",
"test/account_voucher_report.yml"
],
'certificate': '0037580727101',
"active": False,
@@ -0,0 +1,34 @@
-
Demo for Account Voucher
-
!record {model: account.voucher, id: account_voucher_voucheraxelor0}:
account_id: account.cash
company_id: base.main_company
currency_id: base.EUR
journal_id: account.bank_journal
name: Voucher Axelor
narration: Basic PC
amount: 1000.0
line_ids:
- account_id: account.cash
amount: 1000.0
name: Voucher Axelor
period_id: account.period_6
-
In order to test the PDF reports defined on a account_voucher, we will print account voucher amount Report
-
!python {model: account.voucher}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.voucher.cash_amount').create(cr, uid, [ref("account_voucher_voucheraxelor0")], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_voucher-amount.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a account_voucher, we will print account voucher Report
-
!python {model: account.voucher}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.voucher.cash_receipt.drcr').create(cr, uid, [ref("account_voucher_voucheraxelor0")], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'account_voucher-report.'+format), 'wb+').write(data)
+44 -3
View File
@@ -45,7 +45,7 @@ account_move_line()
class account_voucher(osv.osv):
def _get_type(self, cr, uid, ids, context={}):
return context.get('type')
return context.get('type', False)
def _get_period(self, cr, uid, context={}):
if context.get('period_id', False):
@@ -101,7 +101,8 @@ class account_voucher(osv.osv):
def _get_narration(self, cr, uid, context={}):
return context.get('narration', False)
_name = 'account.voucher'
_description = 'Accounting Voucher'
_order = "date desc, id desc"
@@ -308,7 +309,7 @@ class account_voucher(osv.osv):
tr_type = 'receipt'
default['value']['account_id'] = account_id
default['value']['type'] = tr_type
default['value']['type'] = ttype or tr_type
vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context)
default['value'].update(vals.get('value'))
@@ -810,3 +811,43 @@ class account_voucher_line(osv.osv):
})
return values
account_voucher_line()
class account_bank_statement(osv.osv):
_inherit = 'account.bank.statement'
def create_move_from_st_line(self, cr, uid, st_line, company_currency_id, next_number, context=None):
if st_line.voucher_id:
return self.pool.get('account.voucher').proforma_voucher(cr, uid, [st_line.voucher_id.id])
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context=context)
account_bank_statement()
class account_bank_statement_line(osv.osv):
_inherit = 'account.bank.statement.line'
def _amount_reconciled(self, cursor, user, ids, name, args, context=None):
if not ids:
return {}
res_currency_obj = self.pool.get('res.currency')
res = {}
company_currency_id = False
for line in self.browse(cursor, user, ids, context=context):
if not company_currency_id:
company_currency_id = line.company_id.id
if line.voucher_id:
res[line.id] = res_currency_obj.compute(cursor, user,
company_currency_id, line.statement_id.currency.id,
line.voucher_id.amount, context=context)
else:
res[line.id] = 0.0
return res
_columns = {
'amount_reconciled': fields.function(_amount_reconciled,
string='Amount reconciled', method=True, type='float'),
'voucher_id': fields.many2one('account.voucher', 'Payment'),
}
account_bank_statement_line()
@@ -80,6 +80,72 @@
</search>
</field>
</record>
<record model="ir.ui.view" id="view_low_priority_payment_form">
<field name="name">account.voucher.payment.low.priority.form</field>
<field name="model">account.voucher</field>
<field name="type">form</field>
<field name="priority">1</field>
<field name="arch" type="xml">
<form string="Bill Payment">
<group col="6" colspan="4">
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)" context="{'invoice_currency':currency_id}" string="Vendor"/>
<field name="journal_id"
domain="[('type','in',['bank', 'cash'])]"
widget="selection" select="1"
on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"
string="Payment Method"/>
<field name="amount" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"/>
<field name="reference" select="1" string="Payment Ref"/>
<field name="name" colspan="4"/>
<field name="account_id"
widget="selection"
invisible="True"/>
<field name="pre_line" invisible="1"/>
<field name="type" invisible="True"/>
</group>
<notebook colspan="4">
<page string="Payment Information">
<field name="line_dr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140">
<tree string="Vendor Invoices and Outstanding transactions" editable="bottom">
<field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
on_change="onchange_move_line_id(move_line_id)"
domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
/>
<field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
<field name="date_original" readonly="1"/>
<field name="date_due" readonly="1"/>
<field name="amount_original" readonly="1"/>
<field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
<field name="amount" sum="Payment"/>
</tree>
<form string="Payment Information">
<label string="Form view not available for Payment Lines"/>
</form>
</field>
<field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
<tree string="Credits" editable="bottom">
<field name="move_line_id"/>
<field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
<field name="date_original"/>
<field name="amount_original"/>
<field name="amount" sum="Payment"/>
</tree>
</field>
<group col="2" colspan="3">
<separator string="Internal Notes" colspan="2"/>
<field name="narration" colspan="2" nolabel="1"/>
</group>
<group col="2" colspan="1">
<separator string="Other Information" colspan="2"/>
<field name="date" select="1" on_change="onchange_date(date)"/>
<field name="currency_id" invisible="True"/>
<field name="number"/>
</group>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_vendor_payment_form">
<field name="name">account.voucher.payment.form</field>
@@ -102,6 +102,7 @@
<field name="name" colspan="4"/>
<field name="date" on_change="onchange_date(date)"/>
<field name="type" invisible="True"/>
<field name="currency_id" invisible="True" nolabel="1"/>
</group>
<notebook colspan="4">
<page string="Sales Information">
@@ -133,7 +134,7 @@
<group col="4" colspan="1">
<separator string="Total" colspan="4"/>
<field name="tax_id" on_change="onchange_price(line_cr_ids, tax_id, partner_id)" widget="selection" domain="[('type_tax_use','in',('sale','all'))]"/><field name="tax_amount" nolabel="1"/><button type="object" icon="terp-stock_format-scientific" name="compute_tax" groups="base.group_extended" string="Compute Tax" attrs="{'invisible': [('state','!=','draft')]}"/>
<label string="" colspan="1"/><field name="currency_id" invisible="True" nolabel="1"/><field name="amount" string="Total"/>
<label string="" colspan="1"/><field name="amount" string="Total"/>
</group>
</group>
</page>
@@ -211,6 +212,7 @@
<field name="reference" select="1"/>
<field name="account_id" domain="[('type','=','other')]" invisible="True"/>
<field name="type" invisible="True"/>
<field name="currency_id" invisible="True" nolabel="1"/>
</group>
<notebook colspan="4">
<page string="Bill Information">
@@ -235,7 +237,7 @@
<group col="4" colspan="1">
<separator string="Total" colspan="4"/>
<field name="tax_id" on_change="onchange_price(line_dr_ids, tax_id, partner_id)" widget="selection" domain="[('type_tax_use','in',('purchase','all'))]"/><field name="tax_amount" nolabel="1"/><button type="object" icon="terp-stock_format-scientific" name="compute_tax" string="Compute Tax" groups="base.group_extended" attrs="{'invisible': [('state','!=','draft')]}"/>
<label string="" colspan="1"/><field name="currency_id" invisible="True" nolabel="1"/><field name="amount" string="Total"/>
<label string="" colspan="1"/><field name="amount" string="Total"/>
</group>
</group>
</page>
+25
View File
@@ -147,6 +147,17 @@
<field name="view_id" eval="view_voucher_tree"/>
<field name="search_view_id" ref="view_voucher_filter"/>
</record>
<record id="action_journal_voucher_tree" model="ir.actions.act_window.view">
<field eval="1" name="sequence"/>
<field name="view_mode">tree</field>
<field name="act_window_id" ref="action_voucher_list"/>
</record>
<record id="action_journal_voucher_form" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_voucher_form"/>
<field name="act_window_id" ref="action_voucher_list"/>
</record>
<menuitem action="action_voucher_list" id="menu_encode_entries_by_voucher" parent="account.menu_finance_entries" sequence="6"/>
<act_window
@@ -168,5 +179,19 @@
<field name="search_view_id" ref="view_voucher_filter"/>
</record>
<record id="view_bank_statement_form_voucher" model="ir.ui.view">
<field name="name">account.bank.statement.voucher.form.inherit</field>
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@name='statement_line_ids']/field[@name='line_ids']/tree/field[@name='amount']" position="after">
<field name="voucher_id" context="{'default_type': amount &lt; 0 and 'payment' or 'receipt', 'type': amount &lt; 0 and 'payment' or 'receipt', 'default_partner_id': partner_id, 'default_journal_id': parent.journal_id, 'default_amount': abs(amount), 'default_reference': ref, 'default_date': date, 'default_name': name}"/>
<field name="amount_reconciled"/>
</xpath>
</field>
</record>
</data>
</openerp>
+1 -1
View File
@@ -16,7 +16,7 @@
</xpath>
<xpath expr="//label[@string='description']"
position="attributes">
<attribute name="string">Install more applications. A few applications are proposed according to the Association Profile you selected. You will be able to install them based on our requirements.</attribute>
<attribute name="string">Here are specific applications related to the Association Profile you selected.</attribute>
</xpath>
<xpath expr="//button[@string='Install Modules']" position="attributes">
<attribute name="string">Configure</attribute>
+3 -1
View File
@@ -59,7 +59,9 @@
],
'demo_xml': ['auction_demo.xml','board_auction_demo.xml'],
'test': ['test/auction.yml'],
'test': ['test/auction.yml',
'test/auction_report.yml',
],
'installable': True,
'active': False,
+125
View File
@@ -0,0 +1,125 @@
-
In order to test the PDF reports defined on auction, we will print a auction artist
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.auction.artists').create(cr, uid, [ref('auction.auction_deposit_1_lot_1'),ref('auction.auction_deposit_1_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_artist_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print a auction Bid
-
!python {model: auction.bid}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.auction.bids').create(cr, uid, [ref('auction.auction_date_1_bid_3'),ref('auction.auction_date_1_bid_4')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_bid_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print a lots list Report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.lots.list').create(cr, uid, [ref('auction.auction_deposit_3_lot_1'),ref('auction.auction_deposit_3_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_lots_list_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print a lots inventory Report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.lots.list.inventory').create(cr, uid, [ref('auction.auction_deposit_4_lot_1'),ref('auction.auction_deposit_4_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_lots_inventory_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print a deposit seller Report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.deposit.seller').create(cr, uid, [ref('auction.auction_deposit_5_lot_1'),ref('auction.auction_deposit_5_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_deposit_seller_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print a catalog
-
!python {model: auction.dates}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.auction.cat_flagy').create(cr, uid, [ref('auction.auction_date_1'),ref('auction.auction_date_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_catalog_list.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print buyer form report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.buyer_form_report').create(cr, uid, [ref('auction.auction_deposit_6_lot_1'),ref('auction.auction_deposit_6_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_buyer_form.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on auction, we will print bids phones report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.bids.phones.details').create(cr, uid, [ref('auction.auction_deposit_7_lot_1'),ref('auction.auction_deposit_7_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_bids_phones_details.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a auction, we will print a Auction Total
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.auction.total.rml').create(cr, uid, [ref('auction.auction_deposit_8_lot_1'),ref('auction.auction_deposit_8_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_total_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a auction, we will print a Auction Result
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.auction.result').create(cr, uid, [ref('auction.auction_deposit_9_lot_1'),ref('auction.auction_deposit_9_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_result_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a auction, we will print a Auction Lot
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.bids.lots').create(cr, uid, [ref('auction.auction_deposit_10_lot_1'),ref('auction.auction_deposit_10_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_lot_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a auction, we will print a Auction Buyer list report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.buyer.list').create(cr, uid, [ref('auction.auction_deposit_10_lot_1'),ref('auction.auction_deposit_10_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_buyer_list_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a auction, we will print a Auction Flagey Hussier report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.flagey.huissier').create(cr, uid, [ref('auction.auction_deposit_3_lot_1'),ref('auction.auction_deposit_10_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_flagey_hussier_report.'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a auction, we will print Auction Seller Form report
-
!python {model: auction.lots}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.seller_form_report').create(cr, uid, [ref('auction.auction_deposit_3_lot_1'),ref('auction.auction_deposit_10_lot_2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'auction-auction_seller_form_report.'+format), 'wb+').write(data)
@@ -31,8 +31,7 @@
<label string="Otherwise these details will not be visible from address/contact." colspan="4"/>
<label string="Do you want to migrate your Address data in Contact Data?" colspan="4" />
<group colspan="6">
<label string="Migrate:" colspan="1"/>
<field name="migrate" string="Yes" colspan="1"/>
<field name="migrate" string="Migrate" colspan="1"/>
</group>
</group>
</group>
+1 -1
View File
@@ -3,7 +3,7 @@
<data>
<report auto="False" id="base.ir_module_reference_print" model="ir.module.module" name="ir.module.reference.graph" rml="base_module_doc_rst/report/ir_module_reference_graph.rml" string="Technical guide"/>
<report id="report_proximity_graph" model="ir.module.module" name="proximity.graph" string="Proximity grpah"/>
<report id="report_proximity_graph" model="ir.module.module" name="proximity.graph" string="Proximity graph"/>
</data>
</openerp>
+3 -2
View File
@@ -18,8 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import base_report_designer
import wizard
import base_report_designer
import installer
import openerp_sxw2rml
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+3 -2
View File
@@ -36,8 +36,9 @@ upload the report using the same wizard.
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': ['base'],
'init_xml': ['base_report_data.xml'],
'update_xml': ['base_report_designer_wizard.xml'],
'init_xml': ['security/base_report_security.xml',
'wizard/base_report_design_view.xml'],
'update_xml': ['base_report_designer_installer.xml'],
'demo_xml': [],
'installable': True,
'active': False,
@@ -20,13 +20,13 @@
##############################################################################
from osv import osv
from wizard.tiny_sxw2rml import sxw2rml
from openerp_sxw2rml import sxw2rml
from StringIO import StringIO
from report import interface
import base64
import pooler
import tools
import addons
class report_xml(osv.osv):
_inherit = 'ir.actions.report.xml'
@@ -37,12 +37,9 @@ class report_xml(osv.osv):
'''
sxwval = StringIO(base64.decodestring(file_sxw))
if file_type=='sxw':
fp = tools.file_open('normalized_oo2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_oo2rml.xsl'),'rb')
if file_type=='odt':
fp = tools.file_open('normalized_odt2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb')
return {'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))}
def upload_report(self, cr, uid, report_id, file_sxw, file_type, context):
@@ -52,11 +49,9 @@ class report_xml(osv.osv):
pool = pooler.get_pool(cr.dbname)
sxwval = StringIO(base64.decodestring(file_sxw))
if file_type=='sxw':
fp = tools.file_open('normalized_oo2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_oo2rml.xsl'),'rb')
if file_type=='odt':
fp = tools.file_open('normalized_odt2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb')
report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
'report_sxw_content': base64.decodestring(file_sxw),
'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())),
@@ -0,0 +1,93 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_report_designer_installer" model="ir.ui.view">
<field name="name">Form View: OpenERP Report Designer Installation</field>
<field name="model">base_report_designer.installer</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_installer"/>
<field name="arch" type="xml">
<data>
<form position="attributes">
<attribute name="string">OpenERP Report Designer Configuration</attribute>
</form>
<separator string="title" position="attributes">
<attribute name="string">OpenERP Report Designer</attribute>
</separator>
<xpath expr="//label[@string='description']" position="attributes">
<attribute name="string">This plug-in allows you to create/modify OpenERP Reports into OpenOffice Writer.</attribute>
</xpath>
<xpath expr="//button[@string='Install Modules']" position="replace">
<button colspan="1" icon="gtk-close" special="cancel" string="_Close" invisible="not context.get('menu',False)"/>
<button name="action_next" icon="gtk-go-forward"
type="object" string="Configure" colspan="1" invisible="context.get('menu',False)"/>
</xpath>
<xpath expr="//button[@string='Skip']" position="replace">
<button name="action_skip" icon="gtk-jump-to" special="cancel"
type="object" string="Skip" colspan="1" invisible="context.get('menu',False)"/>
</xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='string'></attribute>
<attribute name='rowspan'>15</attribute>
</xpath>
<group colspan="8" position="replace">
<group colspan="8" height="450" width="750">
<field name="name" invisible="1"/>
<field name="plugin_file" filename="name"/>
<separator string="Installation and Configuration Steps" colspan="4"/>
<field name="description" nolabel="1" colspan="8"/>
</group>
</group>
</data>
</field>
</record>
<record id="action_report_designer_installer" model="ir.actions.act_window">
<field name="name">OpenERP Report Designer Installation</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base_report_designer.installer</field>
<field name="view_id" ref="view_report_designer_installer"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="report_designer_installer_todo" model="ir.actions.todo">
<field name="action_id" ref="action_report_designer_installer"/>
<field name="sequence">3</field>
</record>
<record id="action_report_designer_wizard" model="ir.actions.act_window">
<field name="name">OpenERP Report Designer</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base_report_designer.installer</field>
<field name="view_id" ref="view_report_designer_installer"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="context">{'menu':True}</field>
</record>
<menuitem icon="terp-graph" id="base.reporting_menu"
name="Reporting" sequence="30" />
<menuitem id="base.next_id_50" name="Configuration"
parent="base.reporting_menu" sequence="3" />
<menuitem parent="base.next_id_50" name="Report Designer"
action="action_report_designer_wizard"
id="menu_action_report_designer_wizard" sequence="70" />
<menuitem parent="base.next_id_50" name="Modify an existing report"
action="action_view_base_report_sxw"
id="menu_wizard_report_designer_modify" sequence="70" groups="base.group_extended"/>
</data>
</openerp>
@@ -1,22 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<wizard string="Modify an existing report"
model="ir.actions.report.xml" name="base_report_designer.modify"
id="wizard_report_designer_modify" />
<menuitem icon="terp-graph" id="base.reporting_menu"
name="Reporting" sequence="30" />
<menuitem id="base.next_id_50" name="Configuration"
parent="base.reporting_menu" groups="base.group_system" sequence="3" />
<menuitem parent="base.next_id_50" name="Report Designer"
action="wizard_report_designer_modify" type="wizard"
id="menu_wizard_report_designer_modify" sequence="70" />
</data>
</openerp>
+63
View File
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields
from osv import osv
import base64
from tools.translate import _
import addons
class base_report_designer_installer(osv.osv_memory):
_name = 'base_report_designer.installer'
_inherit = 'res.config.installer'
def default_get(self, cr, uid, fields, context={}):
data = super(base_report_designer_installer, self).default_get(cr, uid, fields, context)
plugin_file = open(addons.get_module_resource('base_report_designer','plugin', 'openerp_report_designer.zip'),'rb')
data['plugin_file'] = base64.encodestring(plugin_file.read())
return data
_columns = {
'name':fields.char('File name', size=34),
'plugin_file':fields.binary('OpenObject Report Designer Plug-in', readonly=True, help="OpenObject Report Designer plug-in file. Save as this file and install this plug-in in OpenOffice."),
'description':fields.text('Description', readonly=True)
}
_defaults = {
'name' : 'openerp_report_designer.zip',
'description' : """
* Save the OpenERP Report Designer plug-­in.
* Follow these steps to install plug-­in.
1. Open Extension Manager window from Menu Bar of Openoffice writer, Open Tools > Extension Menu.
2. Click on "Add" button.
3. Select path where the openerp_report_designer.zip is located.
4. On the completion of adding package you will get your package under 'Extension Manager' and the status of your package become 'Enabled'.
5. Restart openoffice writer.
* Follow the steps to configure OpenERP Report Designer plug-­in in Openoffice writer.
1. Connect OpenERP Server from Menu bar , OpenERP Report Designer > Server parameter.
2. Select Server url, database and provide user name and password
3. Click "Connect".
4. if your connection success, A message appears like 'You can start creating your report in current document.'.
"""
}
base_report_designer_installer()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -19,6 +19,6 @@
#
##############################################################################
from tiny_sxw2rml import sxw2rml
from openerp_sxw2rml import sxw2rml
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -22,17 +22,11 @@
##############################################################################
#!/usr/bin/python
"""
Tiny SXW2RML - The OpenERP's report engine
OpenERP SXW2RML - The OpenERP's report engine
Tiny SXW2RMLis part of the Tiny report project.
Tiny Report is a module that allows you to render high quality PDF document
OpenERP SXW2RML is part of the OpenERP Report Project.
OpenERP Report is a module that allows you to render high quality PDF document
from an OpenOffice template (.sxw) and any relationnal database.
The whole source code is distributed under the terms of the
GNU Public Licence.
(c) 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de)
(c) 2005-TODAY, Fabien Pinckaers - Tiny sprl
"""
__version__ = '0.9'
@@ -341,8 +335,8 @@ def sxw2rml(sxw_file, xsl, output='.', save_pict=False):
if __name__ == "__main__":
import optparse
parser = optparse.OptionParser(
version="Tiny Report v%s" % __version__,
usage = 'tiny_sxw2rml.py [options] file.sxw')
version="OpenERP Report v%s" % __version__,
usage = 'openerp_sxw2rml.py [options] file.sxw')
parser.add_option("-v", "--verbose", default=False, dest="verbose", help="enable basic debugging")
parser.add_option("-o", "--output", dest="output", default='.', help="directory of image output")
(opt, args) = parser.parse_args()
@@ -0,0 +1,40 @@
About OpenERP Report Designer Plugin
===================================================================
OpenERP Report Desinger Plugin is a Package of OpenOffice Writer.
Using this Plugin , we can modify existing OpenERP Reports and also we can make new nice OpenERP Reports.
How to Install OpenERP Report Designer Plugin into Openoffice 3.2 in Linux?
=====================================================================
- In Openoffice writer, Open Extension Manager window from Tools > Extension Menu
- Click on "Add" button and select path where the openerp_report_designer.zip is located.
- On the completion of adding package you will get your package
under 'Extension Manager' and the status of your package become 'Enabled'
- Close openoffice writer.
- Restart openoffice writer, Now you will find one new menu "OpenERP Report Designer" in Menubar.
How to install the plugin with OpenOffice 2.4 on Windows
========================================================
If you get an error for the installation of the plugin, edit the pythonloader.py file
in $(OPEN_OFFICE_DIR)\program\ and change the value of DEBUG to None.
If you get an error for the uno.exe in window then just close the Quick starter
Openoffice.2.4.1 Too\Option\Openoffic.org in that select the Memory
in that Openoffice.org.QuickStarter
if checked mark is there then just remove it..
If you are using OpenOffice 3.0 and install the Report Desinger with make all
command then change path in makefile
sh /opt/openoffice.org3/program/unopkg add or remove both
And for previous version of Openoffice used
sh /usr/lib/openoffice/program/unopkg add -v $(ZIP_FILE)
@@ -0,0 +1,42 @@
ZIP_FILE=../../openerp_report_designer.zip
all: pack uninstall install
create:
cat script/import \
script/lib/actions.py \
script/lib/error.py \
script/lib/functions.py \
script/lib/gui.py \
script/lib/tools.py \
script/lib/logreport.py\
script/lib/rpc.py\
script/lib/tiny_socket.py\
script/Repeatln.py \
script/Fields.py \
script/Expression.py \
script/modify.py \
script/ServerParameter.py \
script/Change.py \
script/NewReport.py \
script/LoginTest.py \
script/ModifyExistingReport.py \
script/SendToServer.py \
script/About.py \
script/ConvertBracesToField.py \
script/ConvertFieldsToBraces.py \
script/ExportToRML.py \
script/Translation.py \
script/AddAttachment.py > package/OpenERPReport.py
pack: clean create
zip $(ZIP_FILE) `find package/ | grep -v svn`
install:
sh /opt/openoffice.org3/program/unopkg add -v $(ZIP_FILE)
uninstall:
sh /opt/openoffice.org3/program/unopkg remove -v $(ZIP_FILE)
clean:
rm -f $(ZIP_FILE)
@@ -0,0 +1,2 @@
#!/bin/sh
ooffice "-accept=socket,host=localhost,port=2002;urp;"
@@ -0,0 +1,636 @@
<?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
oor:name="Addons" oor:package="org.openoffice.Office">
<node oor:name="AddonUI">
<node oor:name="OfficeMenuBar">
<node oor:name="org.openoffice.openerp.report" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">OpenERP Report Designer</value>
<value xml:lang="fr_FR">OpenERP Rapport Designer</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<node oor:name="Submenu">
<node oor:name="m11" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.serverparam?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Server parameters</value>
<value xml:lang="fr_FR">Paramètres serveur</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m12" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m21" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.repeatln?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add a loop</value>
<value xml:lang="fr_FR"> Ajouter une boucle</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m22" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.fields?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add a field</value>
<value xml:lang="fr_FR">Ajouter un champ</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m23" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.expression?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add an expression</value>
<value xml:lang="fr_FR">Ajouter une expression</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m24" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.langtag?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add a lang tag</value>
<value xml:lang="fr_FR">Ajouter un tag lang</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m25" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.modify?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Modify</value>
<value xml:lang="fr_FR">Modifier</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m26" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m31" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.convertFB?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Conversion Fields -> Brackets</value>
<value xml:lang="fr_FR">Conversion champs -> crochets</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m32" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.convertBF?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Conversion Brackets -> Fields</value>
<value xml:lang="fr_FR">Conversion crochets -> champs</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m33" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.exporttorml?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Export to RML</value>
<value xml:lang="fr_FR">Exporter en RML</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m34" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.addattachment?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add Attachment</value>
<value xml:lang="fr_FR">Envoyer comme attachement</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m35" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m41" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.sendtoserver?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Send to the server</value>
<value xml:lang="fr_FR">Envoyer au serveur</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m42" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.opennewreport?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Open a new report</value>
<value xml:lang="fr_FR">Nouveau rapport</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m43" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.modifyreport?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Modify Existing Report</value>
<value xml:lang="fr_FR">Modifier un rapport</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m45" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m51" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.about?execute</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">About</value>
<value xml:lang="fr_FR">À propos de</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
</node>
</node>
</node>
<node oor:name="OfficeToolBar">
<node oor:name="org.openoffice.openerp.report" oor:op="replace">
<node oor:name="m11" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.serverparam?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Server parameters</value>
<value xml:lang="fr_FR">Paramètres serveur</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m12" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m21" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.repeatln?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add a loop</value>
<value xml:lang="fr_FR">Ajouter une boucle</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m22" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.fields?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add a field</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m23" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.expression?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add an expression</value>
<value xml:lang="fr_FR">Ajouter une expression</value>>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m24" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.langtag?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Add a lang tag</value>
<value xml:lang="fr_FR">Ajouter un tag lang</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m25" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.modify?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Modify</value>
<value xml:lang="fr_FR">Modifier</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m26" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m31" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.convertFB?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Conversion Fields -> Brackets</value>
<value xml:lang="fr_FR">Domaines de conversion -> Supports</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m32" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.convertBF?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Conversion Brackets -> Fields</value>
<value xml:lang="fr_FR">Supports de conversion -> Domaines</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m33" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.exporttorml?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">Export to RML</value>
<value xml:lang="fr_FR">RML à l'exportation</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
<node oor:name="m45" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>private:separator</value>
</prop>
</node>
<node oor:name="m51" oor:op="replace">
<prop oor:name="URL" oor:type="xs:string">
<value>service:org.openoffice.openerp.report.about?execute</value>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value/>
<value xml:lang="en-US">About</value>
<value xml:lang="fr_FR">À propos de</value>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value>_self</value>
</prop>
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.text.TextDocument</value>
</prop>
</node>
</node>
</node>
<node oor:name="Images">
<node oor:name="org.openoffice.openerp.report.image1" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.expression?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/expression_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/expression_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image2" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.repeatln?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/loop_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/loop_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image3" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.fields?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/field_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/field_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image4" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.exporttorml?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/export_rml_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/export_rml_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image5" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.convertFB?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/convetFtoB_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/convetFtoB_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image6" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.convertBF?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/convetBtoF_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/convetBtoF_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image7" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.modify?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/modify_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string">
<value>%origin%/images/modify_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image8" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.serverparam?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/logo_1.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string" oor:width="100">
<value>%origin%/images/logo_s.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image9" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.about?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/aboutus_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string" oor:width="100">
<value>%origin%/images/aboutus_b.png</value>
</prop>
</node>
</node>
<node oor:name="org.openoffice.openerp.report.image10" oor:op="replace">
<prop oor:name="URL">
<value>service:org.openoffice.openerp.report.langtag?execute</value>
</prop>
<node oor:name="UserDefinedImages">
<prop oor:name="ImageSmallURL" oor:type="xs:string">
<value>%origin%/images/lang_s.png</value>
</prop>
<prop oor:name="ImageBigURL" oor:type="xs:string" oor:width="100">
<value>%origin%/images/lang_b.png</value>
</prop>
</node>
</node>
</node>
</node>
</oor:component-data>
@@ -0,0 +1,111 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
from com.sun.star.task import XJobExecutor
if __name__<>'package':
from lib.gui import *
class About(unohelper.Base, XJobExecutor):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
self.win = DBModalDialog(60, 50, 175, 115, "About OpenERP Report Designer")
fdBigFont = createUnoStruct("com.sun.star.awt.FontDescriptor")
fdBigFont.Width = 20
fdBigFont.Height = 25
fdBigFont.Weight = 120
fdBigFont.Family= 3
oLabelTitle1 = self.win.addFixedText("lblTitle1", 1, 1, 35, 30)
oLabelTitle1.Model.TextColor = 16056320
oLabelTitle1.Model.FontDescriptor = fdBigFont
oLabelTitle1.Model.FontRelief = 1
oLabelTitle1.Text = "Open"
oLabelTitle2 = self.win.addFixedText("lblTitle2", 35, 1, 30, 30)
oLabelTitle2.Model.TextColor = 1
oLabelTitle2.Model.FontDescriptor = fdBigFont
oLabelTitle2.Model.FontRelief = 1
oLabelTitle2.Text = "ERP"
oLabelProdDesc = self.win.addFixedText("lblProdDesc", 1, 30, 173, 75)
oLabelProdDesc.Model.TextColor = 1
fdBigFont.Width = 10
fdBigFont.Height = 11
fdBigFont.Weight = 76
oLabelProdDesc.Model.FontDescriptor = fdBigFont
oLabelProdDesc.Model.Align = 1
oLabelProdDesc.Model.FontRelief = 1
oLabelProdDesc.Model.MultiLine = True
oLabelProdDesc.Text = "This package helps you to create or modify\nreports in OpenERP. Once connected to the\nserver, you can design your template of reports\nusing fields and expressions and browsing the\ncomplete structure of OpenERP object database."
oLabelFooter = self.win.addFixedText("lblFooter", -1, -1, 173, 25)
oLabelFooter.Model.TextColor = 255
#oLabelFooter.Model.BackgroundColor = 1
oLabelFooter.Model.Border = 2
oLabelFooter.Model.BorderColor = 255
fdBigFont.Width = 8
fdBigFont.Height = 9
fdBigFont.Weight = 100
oLabelFooter.Model.FontDescriptor = fdBigFont
oLabelFooter.Model.Align = 1
oLabelFooter.Model.FontRelief = 1
oLabelFooter.Model.MultiLine = True
sMessage = "OpenERP Report Designer v1.0 \nCopyright 2007-TODAY Tiny sprl \nThis product is free software, under the GNU Affero General Public License."
oLabelFooter.Text = sMessage
self.win.doModalDialog("",None)
if __name__<>"package" and __name__=="__main__":
About(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( About, "org.openoffice.openerp.report.about", ("com.sun.star.task.Job",),)
@@ -0,0 +1,277 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import os
import uno
import unohelper
import xmlrpclib
import base64
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.error import ErrorDialog
from lib.tools import *
from LoginTest import *
from lib.rpc import *
database="test"
uid = 3
class AddAttachment(unohelper.Base, XJobExecutor ):
Kind = {
'PDF' : 'pdf',
'OpenOffice': 'sxw',
}
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
self.aSearchResult = []
desktop=getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo=oDoc2.getDocumentInfo()
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
if docinfo.getUserFieldValue(2) <> "" and docinfo.getUserFieldValue(3) <> "":
self.win = DBModalDialog(60, 50, 180, 70, "Add Attachment to Server")
self.win.addFixedText("lblResourceType", 2 , 5, 100, 10, "Select Appropriate Resource Type:")
self.win.addComboListBox("lstResourceType", -2, 25, 176, 15,True)
self.win.addButton('btnOkWithoutInformation', -2 , -5, 25 , 15,'OK' ,actionListenerProc = self.btnOkWithoutInformation_clicked )
else:
self.win = DBModalDialog(60, 50, 180, 190, "Add Attachment to Server")
self.win.addFixedText("lblModuleName",2 , 9, 42, 20, "Select Module:")
self.win.addComboListBox("lstmodel", -2, 5, 134, 15,True)
self.lstModel = self.win.getControl( "lstmodel" )
self.dModel = {}
# Open a new connexion to the server
ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_model'),('state', '=', 'installed')])
if not len(ids):
# If the module 'base_report_model' is not installed, use the default model
self.dModel = {
"Partner":'res.partner',
}
else:
ids =self.sock.execute(database, uid, self.password, 'base.report.model' , 'search', [])
res = self.sock.execute(database, uid, self.password, 'base.report.model' , 'read', ids, ['name','model_id'])
models = self.sock.execute(database, uid, self.password, 'ir.model' , 'read', map(lambda x:x['model_id'][0], res), ['model'])
models = dict(map(lambda x:(x['id'],x['model']), models))
self.dModel = dict(map(lambda x: (x['name'],models[x['model_id'][0]]), res))
for item in self.dModel.keys():
self.lstModel.addItem(item, self.lstModel.getItemCount())
self.win.addFixedText("lblSearchName",2 , 25, 60, 10, "Enter Search String:")
self.win.addEdit("txtSearchName", 2, 35, 149, 15,)
self.win.addButton('btnSearch', -2 , 35, 25 , 15,'Search' ,actionListenerProc = self.btnSearch_clicked )
self.win.addFixedText("lblSearchRecord", 2 , 55, 60, 10, "Search Result:")
self.win.addComboListBox("lstResource", -2, 65, 176, 70, False )
self.lstResource = self.win.getControl( "lstResource" )
self.win.addFixedText("lblResourceType", 2 , 137, 100, 20, "Select Appropriate Resource Type:")
self.win.addComboListBox("lstResourceType", -2, 147, 176, 15,True )
self.win.addButton('btnOkWithInformation', -2 , -5, 25 , 15,'OK' ,actionListenerProc = self.btnOkWithInformation_clicked )
self.lstResourceType = self.win.getControl( "lstResourceType" )
for kind in self.Kind.keys():
self.lstResourceType.addItem( kind, self.lstResourceType.getItemCount() )
self.win.addButton('btnCancel', -2 - 27 , -5 , 30 , 15, 'Cancel' ,actionListenerProc = self.btnCancel_clicked )
self.win.doModalDialog("lstResourceType", self.Kind.keys()[0])
def btnSearch_clicked( self, oActionEvent ):
modelSelectedItem = self.win.getListBoxSelectedItem("lstmodel")
if modelSelectedItem == "":
return
desktop=getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo=oDoc2.getDocumentInfo()
self.aSearchResult =self.sock.execute( database, uid, self.password, self.dModel[modelSelectedItem], 'name_search', self.win.getEditText("txtSearchName"))
self.win.removeListBoxItems("lstResource", 0, self.win.getListBoxItemCount("lstResource"))
if self.aSearchResult == []:
ErrorDialog("No search result found !!!", "", "Search ERROR" )
return
for result in self.aSearchResult:
self.lstResource.addItem(result[1],result[0])
def _send_attachment( self, name, data, res_model, res_id ):
desktop = getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo = oDoc2.getDocumentInfo()
params = {
'name': name,
'datas': base64.encodestring( data ),
'datas_fname': name,
'res_model' : res_model,
'res_id' : int(res_id),
}
return self.sock.execute( database, uid, self.password, 'ir.attachment', 'create', params )
def send_attachment( self, model, resource_id ):
desktop = getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo = oDoc2.getDocumentInfo()
if oDoc2.getURL() == "":
ErrorDialog("Please save your file", "", "Saving ERROR" )
return None
url = oDoc2.getURL()
if self.Kind[self.win.getListBoxSelectedItem("lstResourceType")] == "pdf":
url = self.doc2pdf(url[7:])
if url == None:
ErrorDialog( "Ploblem in creating PDF", "", "PDF Error" )
return None
url = url[7:]
data = read_data_from_file( get_absolute_file_path( url ) )
return self._send_attachment( os.path.basename( url ), data, model, resource_id )
def btnOkWithoutInformation_clicked( self, oActionEvent ):
desktop = getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo = oDoc2.getDocumentInfo()
if self.win.getListBoxSelectedItem("lstResourceType") == "":
ErrorDialog("Please select resource type", "", "Selection ERROR" )
return
res = self.send_attachment( docinfo.getUserFieldValue(3), docinfo.getUserFieldValue(2) )
self.win.endExecute()
def btnOkWithInformation_clicked(self,oActionEvent):
if self.win.getListBoxSelectedItem("lstResourceType") == "":
ErrorDialog( "Please select resource type", "", "Selection ERROR" )
return
if self.win.getListBoxSelectedItem("lstResource") == "" or self.win.getListBoxSelectedItem("lstmodel") == "":
ErrorDialog("Please select Model and Resource","","Selection ERROR")
return
resourceid = None
for s in self.aSearchResult:
if s[1] == self.win.getListBoxSelectedItem("lstResource"):
resourceid = s[0]
break
if resourceid == None:
ErrorDialog("No resource selected !!!", "", "Resource ERROR" )
return
res = self.send_attachment( self.dModel[self.win.getListBoxSelectedItem('lstmodel')], resourceid )
self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
def doc2pdf(self, strFile):
oDoc = None
strFilterSubName = ''
strUrl = convertToURL( strFile )
desktop = getDesktop()
oDoc = desktop.loadComponentFromURL( strUrl, "_blank", 0, Array(self._MakePropertyValue("Hidden",True)))
if oDoc:
strFilterSubName = ""
# select appropriate filter
if oDoc.supportsService("com.sun.star.presentation.PresentationDocument"):
strFilterSubName = "impress_pdf_Export"
elif oDoc.supportsService("com.sun.star.sheet.SpreadsheetDocument"):
strFilterSubName = "calc_pdf_Export"
elif oDoc.supportsService("com.sun.star.text.WebDocument"):
strFilterSubName = "writer_web_pdf_Export"
elif oDoc.supportsService("com.sun.star.text.GlobalDocument"):
strFilterSubName = "writer_globaldocument_pdf_Export"
elif oDoc.supportsService("com.sun.star.text.TextDocument"):
strFilterSubName = "writer_pdf_Export"
elif oDoc.supportsService("com.sun.star.drawing.DrawingDocument"):
strFilterSubName = "draw_pdf_Export"
elif oDoc.supportsService("com.sun.star.formula.FormulaProperties"):
strFilterSubName = "math_pdf_Export"
elif oDoc.supportsService("com.sun.star.chart.ChartDocument"):
strFilterSubName = "chart_pdf_Export"
else:
pass
filename = len(strFilterSubName) > 0 and convertToURL( os.path.splitext( strFile )[0] + ".pdf" ) or None
if len(strFilterSubName) > 0:
oDoc.storeToURL( filename, Array(self._MakePropertyValue("FilterName", strFilterSubName ),self._MakePropertyValue("CompressMode", "1" )))
oDoc.close(True)
# Can be None if len(strFilterSubName) <= 0
return filename
def _MakePropertyValue(self, cName = "", uValue = u"" ):
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
if cName:
oPropertyValue.Name = cName
if uValue:
oPropertyValue.Value = uValue
return oPropertyValue
if __name__<>"package" and __name__=="__main__":
AddAttachment(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( AddAttachment, "org.openoffice.openerp.report.addattachment", ("com.sun.star.task.Job",),)
@@ -0,0 +1,109 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
if __name__<>"package":
from lib.gui import *
from lib.functions import *
from lib.rpc import *
class Change:
def __init__(self, aVal= None, sURL=""):
self.win=DBModalDialog(60, 50, 120, 90, "Connect to Open ERP Server")
self.win.addFixedText("lblVariable", 38, 12, 60, 15, "Server")
self.win.addEdit("txtHost",-2,9,60,15,sURL[sURL.find("/")+2:sURL.rfind(":")])
self.win.addFixedText("lblReportName",45 , 31, 60, 15, "Port")
self.win.addEdit("txtPort",-2,28,60,15,sURL[sURL.rfind(":")+1:])
self.win.addFixedText("lblLoginName", 2, 51, 60, 15, "Protocol Connection")
self.win.addComboListBox("lstProtocol", -2, 48, 60, 15, True)
self.lstProtocol = self.win.getControl( "lstProtocol" )
# self.lstProtocol.addItem( "XML-RPC", 0)
#self.lstProtocol.addItem( "XML-RPC secure", 1)
#self.lstProtocol.addItem( "NET-RPC (faster)", 2)
self.win.addButton( 'btnOK', -2, -5, 30, 15, 'Ok', actionListenerProc = self.btnOk_clicked )
self.win.addButton( 'btnCancel', -2 - 30 - 5 ,-5, 30, 15, 'Cancel', actionListenerProc = self.btnCancel_clicked )
self.aVal=aVal
self.protocol = {
'XML-RPC': 'http://',
'XML-RPC secure': 'https://',
'NET-RPC': 'socket://',
}
for i in self.protocol.keys():
self.lstProtocol.addItem(i,self.lstProtocol.getItemCount() )
sValue=self.protocol.keys()[0]
if sURL<>"":
sValue=self.protocol.keys()[self.protocol.values().index(sURL[:sURL.find("/")+2])]
self.win.doModalDialog( "lstProtocol", sValue)
def btnOk_clicked(self,oActionEvent):
global url
url = self.protocol[self.win.getListBoxSelectedItem("lstProtocol")]+self.win.getEditText("txtHost")+":"+self.win.getEditText("txtPort")
self.sock=RPCSession(url)
docinfo=doc.getDocumentInfo()
docinfo.setUserFieldValue(0,url)
res=self.sock.listdb()
if res == -1:
self.aVal.append(url)
elif res == 0:
self.aVal.append("No Database found !!!")
else:
self.aVal.append(url)
self.aVal.append(res)
self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
@@ -0,0 +1,285 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import unohelper
import string
import re
import base64
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from LoginTest import *
from lib.logreport import *
from lib.rpc import *
database="test"
uid = 1
class ConvertBracesToField( unohelper.Base, XJobExecutor ):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
self.logobj=Logger()
if not loginstatus and __name__=="package":
exit(1)
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
self.aReportSyntex=[]
self.getBraces(self.aReportSyntex)
self.setValue()
def setValue(self):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo= doc.getDocumentInfo()
count = 0
regexes = [
['[a-zA-Z0-9_]+\.[a-zA-Z0-9_.]+',"Field"],
['\\[\\[ *repeatIn\\( *([a-zA-Z0-9_\.]+), *\'([a-zA-Z0-9_]+)\' *\\) *\\]\\]', "RepeatIn"],
['\\[\\[ *([a-zA-Z0-9_\.]+) *\\]\\]', "Field"]
# ['\\[\\[ ([a-zA-Z0-9_]+\.[a-zA-Z1-9]) \\]\\]',"Field"],
# ['\\[\\[ [a-zA-Z0-9_\.]+ and ([a-zA-Z0-9_\.]+) or .+? \\]\\]',"Field"],
# ['\\[\\[ ([a-zA-Z0-9_\.]+) or .+? \\]\\]',"Field"],
# ['\\[\\[ ([a-zA-Z0-9_\.]+) and .+? \\]\\]',"Field"],
# ['\\[\\[ .+? or ([a-zA-Z0-9_\.]+) \\]\\]',"Field"],
# ['\\[\\[ (.+?) and ([a-zA-Z0-9_\.]+) \\]\\]',"Field"],
# ['\\[\\[ .+? % ([a-zA-Z0-9_\.]+) \\]\\]',"Field"]
]
oFieldObject = []
oRepeatInObjects = []
saRepeatInList = []
sHost = docinfo.getUserFieldValue(0)
nCount = 0
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
nCount += 1
getList(oRepeatInObjects,sHost,nCount)
for ro in oRepeatInObjects:
if ro.find("(")<>-1:
saRepeatInList.append( [ ro[:ro.find("(")], ro[ro.find("(")+1:ro.find(")")] ])
try:
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
for reg in regexes:
res=re.findall(reg[0],oPar.Items[1])
if len(res) <> 0:
if res[0][0] == "objects":
sTemp = docinfo.getUserFieldValue(3)
sTemp = "|-." + sTemp[sTemp.rfind(".")+1:] + ".-|"
oPar.Items=(sTemp.encode("utf-8"),oPar.Items[1].replace(' ',""))
oPar.update()
elif type(res[0]) <> type(u''):
sObject = self.getRes(self.sock, docinfo.getUserFieldValue(3), res[0][0][res[0][0].find(".")+1:].replace(".","/"))
r = self.sock.execute(database, uid, self.password, docinfo.getUserFieldValue(3) , 'fields_get')
sExpr="|-." + r[res[0][0][res[0][0].rfind(".")+1:]]["string"] + ".-|"
oPar.Items=(sExpr.encode("utf-8"),oPar.Items[1].replace(' ',""))
oPar.update()
else:
obj = None
for rl in saRepeatInList:
if rl[0] == res[0][:res[0].find(".")]:
obj=rl[1]
try:
sObject = self.getRes(self.sock, obj, res[0][res[0].find(".")+1:].replace(".","/"))
r = self.sock.execute(database, uid, self.password, sObject , 'read',[1])
except Exception,e:
r = "TTT"
self.logobj.log_write('ConvertBracesToField', LOG_ERROR, str(e))
if len(r) <> 0:
if r <> "TTT":
if len(res)>1:
sExpr=""
print res
if reg[1] == 'Field':
for ires in res:
try:
sExpr=r[0][ires[ires.rfind(".")+1:]]
break
except Exception,e:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ConvertBracesToField', LOG_ERROR,info)
try:
oPar.Items=(sExpr.encode("utf-8") ,oPar.Items[1])
oPar.update()
except:
oPar.Items=(str(sExpr) ,oPar.Items[1])
oPar.update()
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ConvertBracesToField', LOG_ERROR, info)
else:
sExpr=r[0][res[0][res[0].rfind(".")+1:]]
try:
if sExpr:
oPar.Items=(sExpr.encode("utf-8") ,oPar.Items[1])
oPar.update()
else:
oPar.Items=(u"/",oPar.Items[1])
oPar.update()
except:
oPar.Items=(str(sExpr) ,oPar.Items[1])
oPar.update()
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ConvertBracesToField', LOG_ERROR,info)
else:
oPar.Items=(u""+r,oPar.Items[1])
oPar.update()
else:
oPar.Items=(u"TTT",oPar.Items[1])
oPar.update()
except:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ConvertBraceToField', LOG_ERROR, info)
def getRes(self,sock,sObject,sVar):
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
res = sock.execute(database, uid, self.password, sObject , 'fields_get')
key = res.keys()
key.sort()
myval=None
if not sVar.find("/")==-1:
myval=sVar[:sVar.find("/")]
else:
myval=sVar
for k in key:
if (res[k]['type'] in ['many2one']) and k==myval:
sObject = self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:])
return sObject
def getBraces(self,aReportSyntex=[]):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
aSearchString=[]
aReplaceString=[]
aRes=[]
try:
regexes = [
['\\[\\[ *repeatIn\\( *([a-zA-Z0-9_\.]+), *\'([a-zA-Z0-9_]+)\' *\\) *\\]\\]', "RepeatIn"],
['\\[\\[ *([a-zA-Z0-9_\.]+) *\\]\\]', "Field"],
['\\[\\[ *.+? *\\]\\]', "Expression"]
]
search = doc.createSearchDescriptor()
search.SearchRegularExpression = True
for reg in regexes:
search.SearchString = reg[0]
found = doc.findFirst( search )
while found:
res=re.findall(reg[0],found.String)
print len(res)
if found.String not in [r[0] for r in aReportSyntex] and len(res) == 1 :
text=found.getText()
oInputList = doc.createInstance("com.sun.star.text.TextField.DropDown")
if reg[1]<>"Expression":
oInputList.Items=(u""+found.String,u""+found.String)
else:
oInputList.Items=(u"?",u""+found.String)
aReportSyntex.append([oInputList,reg[1]])
text.insertTextContent(found,oInputList,False)
found.String =""
else:
aRes.append([res,reg[1]])
found = doc.findNext(found.End, search)
search = doc.createSearchDescriptor()
search.SearchRegularExpression = False
for res in aRes:
for r in res[0]:
search.SearchString=r
found=doc.findFirst(search)
while found:
text=found.getText()
oInputList = doc.createInstance("com.sun.star.text.TextField.DropDown")
if res[1]<>"Expression":
oInputList.Items=(u""+found.String,u""+found.String)
else:
oInputList.Items=(u"?",u""+found.String)
aReportSyntex.append([oInputList,res[1]])
text.insertTextContent(found,oInputList,False)
found.String =""
found = doc.findNext(found.End, search)
except:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ConvertBraceToField', LOG_ERROR, info)
if __name__<>"package":
ConvertBracesToField(None)
else:
g_ImplementationHelper.addImplementation( ConvertBracesToField, "org.openoffice.openerp.report.convertBF", ("com.sun.star.task.Job",),)
@@ -0,0 +1,85 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import unohelper
import string
import re
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from LoginTest import *
database="test"
uid = 3
class ConvertFieldsToBraces( unohelper.Base, XJobExecutor ):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
self.aReportSyntex=[]
self.getFields()
def getFields(self):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
oPar.getAnchor().Text.insertString(oPar.getAnchor(),oPar.Items[1],False)
oPar.dispose()
if __name__<>"package":
ConvertFieldsToBraces(None)
else:
g_ImplementationHelper.addImplementation( ConvertFieldsToBraces, "org.openoffice.openerp.report.convertFB", ("com.sun.star.task.Job",),)
@@ -0,0 +1,132 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import os
import uno
import unohelper
import string
import tempfile
import base64
import sys
reload(sys)
sys.setdefaultencoding("utf8")
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from LoginTest import *
from lib.error import *
from lib.tools import *
from lib.logreport import *
from lib.rpc import *
database="test"
uid = 3
class ExportToRML( unohelper.Base, XJobExecutor ):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
global url
self.sock=RPCSession(url)
# Read Data from sxw file
tmpsxw = tempfile.mktemp('.'+"sxw")
if not doc.hasLocation():
mytype = Array(makePropertyValue("MediaType","application/vnd.sun.xml.writer"),)
doc.storeAsURL("file://"+tmpsxw,mytype)
data = read_data_from_file( get_absolute_file_path( doc.getURL()[7:] ) )
file_type = doc.getURL()[7:].split(".")[-1]
if docinfo.getUserFieldValue(2) == "":
ErrorDialog("Please Save this file on server","Use Send To Server Option in OpenERP Report Menu","Error")
exit(1)
filename = self.GetAFileName()
if not filename:
exit(1)
global passwd
self.password = passwd
try:
res = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'sxwtorml',base64.encodestring(data),file_type)
if res['report_rml_content']:
write_data_to_file( get_absolute_file_path( filename[7:] ), res['report_rml_content'] )
except Exception,e:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ExportToRML',LOG_ERROR, info)
ErrorDialog("Can't save the file to the hard drive.", "Exception: %s" % e, "Error" )
def GetAFileName(self):
sFilePickerArgs = Array(10)
oFileDialog = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oFileDialog.initialize(sFilePickerArgs)
oFileDialog.appendFilter("OpenERP Report File Save To ....","*.rml")
f_path = "OpenERP-"+ os.path.basename( tempfile.mktemp("","") ) + ".rml"
initPath = tempfile.gettempdir()
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
if oUcb.exists(initPath):
oFileDialog.setDisplayDirectory('file://' + ( os.name == 'nt' and '/' or '' ) + initPath )
oFileDialog.setDefaultName(f_path )
sPath = oFileDialog.execute() == 1 and oFileDialog.Files[0] or None
oFileDialog.dispose()
return sPath
if __name__<>"package" and __name__=="__main__":
ExportToRML(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( ExportToRML, "org.openoffice.openerp.report.exporttorml", ("com.sun.star.task.Job",),)
@@ -0,0 +1,115 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.error import ErrorDialog
from lib.functions import *
database="test"
uid = 3
class Expression(unohelper.Base, XJobExecutor ):
def __init__(self,sExpression="",sName="", bFromModify=False):
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
self.win = DBModalDialog(60, 50, 180, 65, "Expression Builder")
self.win.addFixedText("lblExpression",17 , 10, 35, 15, "Expression :")
self.win.addEdit("txtExpression", -5, 5, 123, 15)
self.win.addFixedText("lblName", 2, 30, 50, 15, "Displayed Name :")
self.win.addEdit("txtName", -5, 25, 123, 15)
self.win.addButton( "btnOK", -5, -5, 40, 15, "OK", actionListenerProc = self.btnOk_clicked )
self.win.addButton( "btnCancel", -5 - 40 -5, -5, 40, 15, "Cancel", actionListenerProc = self.btnCancel_clicked )
self.bModify=bFromModify
if self.bModify==True:
self.win.setEditText("txtExpression",sExpression)
self.win.setEditText("txtName",sName)
self.win.doModalDialog("",None)
def btnOk_clicked( self, oActionEvent ):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
text = doc.Text
cursor = doc.getCurrentController().getViewCursor()
if self.bModify==True:
oCurObj=cursor.TextField
sKey=u""+self.win.getEditText("txtName")
sValue=u"[[ " + self.win.getEditText("txtExpression") + " ]]"
oCurObj.Items = (sKey,sValue)
oCurObj.update()
self.win.endExecute()
else:
oInputList = doc.createInstance("com.sun.star.text.TextField.DropDown")
if self.win.getEditText("txtName")!="" and self.win.getEditText("txtExpression")!="":
sKey=u""+self.win.getEditText("txtName")
sValue=u"[[ " + self.win.getEditText("txtExpression") + " ]]"
if cursor.TextTable==None:
oInputList.Items = (sKey,sValue)
text.insertTextContent(cursor,oInputList,False)
else:
oTable = cursor.TextTable
oCurCell = cursor.Cell
tableText = oTable.getCellByName( oCurCell.CellName )
oInputList.Items = (sKey,sValue)
tableText.insertTextContent(cursor,oInputList,False)
self.win.endExecute()
else:
ErrorDialog("Please Fill appropriate data in Name field or \nExpression field")
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
Expression()
elif __name__=="package":
g_ImplementationHelper.addImplementation( Expression, "org.openoffice.openerp.report.expression", ("com.sun.star.task.Job",),)
@@ -0,0 +1,291 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.functions import *
from lib.error import ErrorDialog
from LoginTest import *
from lib.logreport import *
from lib.rpc import *
database="report"
uid = 3
class Fields(unohelper.Base, XJobExecutor ):
def __init__(self,sVariable="",sFields="",sDisplayName="",bFromModify=False):
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
self.logobj=Logger()
self.win = DBModalDialog(60, 50, 200, 225, "Field Builder")
self.win.addFixedText("lblVariable", 27, 12, 60, 15, "Variable :")
self.win.addComboBox("cmbVariable", 180-120-2, 10, 130, 15,True, itemListenerProc=self.cmbVariable_selected)
self.insVariable = self.win.getControl( "cmbVariable" )
self.win.addFixedText("lblFields", 10, 32, 60, 15, "Variable Fields :")
self.win.addComboListBox("lstFields", 180-120-2, 30, 130, 150, False,True,itemListenerProc=self.lstbox_selected)
self.insField = self.win.getControl( "lstFields" )
self.win.addFixedText("lblUName", 8, 187, 60, 15, "Displayed name :")
self.win.addEdit("txtUName", 180-120-2, 185, 130, 15,)
self.win.addButton('btnOK',-5 ,-5,45,15,'Ok' ,actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-5 - 45 - 5 ,-5,45,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
self.sValue=None
self.sObj=None
self.aSectionList=[]
self.sGDisplayName=sDisplayName
self.aItemList=[]
self.aComponentAdd=[]
self.aObjectList=[]
self.aListFields=[]
self.aVariableList=[]
EnumDocument(self.aItemList,self.aComponentAdd)
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.sMyHost= ""
if not docinfo.getUserFieldValue(3) == "" and not docinfo.getUserFieldValue(0)=="":
self.sMyHost = docinfo.getUserFieldValue(0)
self.count = 0
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
self.count += 1
getList(self.aObjectList, self.sMyHost,self.count)
cursor = doc.getCurrentController().getViewCursor()
text = cursor.getText()
tcur = text.createTextCursorByRange(cursor)
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == "Objects", self.aObjectList ) )
for i in range(len(self.aItemList)):
try:
anItem = self.aItemList[i][1]
component = self.aComponentAdd[i]
if component == "Document":
sLVal = anItem[anItem.find(",'") + 2:anItem.find("')")]
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == sLVal, self.aObjectList ) )
if tcur.TextSection:
getRecersiveSection(tcur.TextSection,self.aSectionList)
if component in self.aSectionList:
sLVal = anItem[anItem.find(",'") + 2:anItem.find("')")]
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == sLVal, self.aObjectList ) )
if tcur.TextTable:
if not component == "Document" and component[component.rfind(".")+1:] == tcur.TextTable.Name:
VariableScope(tcur, self.aVariableList, self.aObjectList, self.aComponentAdd, self.aItemList, component)
except:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('Fields', LOG_ERROR, info)
self.bModify=bFromModify
if self.bModify==True:
sItem=""
for anObject in self.aObjectList:
if anObject[:anObject.find("(")] == sVariable:
sItem = anObject
self.insVariable.setText(sItem)
genTree(
sItem[sItem.find("(")+1:sItem.find(")")],
self.aListFields,
self.insField,
self.sMyHost,
2,
ending_excl=['one2many','many2one','many2many','reference'],
recur=['many2one']
)
self.sValue= self.win.getListBoxItem("lstFields",self.aListFields.index(sFields))
for var in self.aVariableList:
self.model_ids =self.sock.execute(database, uid, self.password, 'ir.model' , 'search', [('model','=',var[var.find("(")+1:var.find(")")])])
fields=['name','model']
self.model_res = self.sock.execute(database, uid, self.password, 'ir.model', 'read', self.model_ids,fields)
if self.model_res <> []:
self.insVariable.addItem(var[:var.find("(")+1] + self.model_res[0]['name'] + ")" ,self.insVariable.getItemCount())
else:
self.insVariable.addItem(var ,self.insVariable.getItemCount())
self.win.doModalDialog("lstFields",self.sValue)
else:
ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice")
self.win.endExecute()
def lstbox_selected(self,oItemEvent):
try:
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
sItem= self.win.getComboBoxText("cmbVariable")
for var in self.aVariableList:
if var[:var.find("(")+1]==sItem[:sItem.find("(")+1]:
sItem = var
sMain=self.aListFields[self.win.getListBoxSelectedItemPos("lstFields")]
sObject=self.getRes(self.sock,sItem[sItem.find("(")+1:-1],sMain[1:])
ids = self.sock.execute(database, uid, self.password, sObject , 'search', [])
res = self.sock.execute(database, uid, self.password, sObject , 'read',[ids[0]])
self.win.setEditText("txtUName",res[0][sMain[sMain.rfind("/")+1:]])
except:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('Fields', LOG_ERROR, info)
self.win.setEditText("txtUName","TTT")
if self.bModify:
self.win.setEditText("txtUName",self.sGDisplayName)
def getRes(self,sock ,sObject,sVar):
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
res = sock.execute(database, uid, self.password, sObject , 'fields_get')
key = res.keys()
key.sort()
myval=None
if not sVar.find("/")==-1:
myval=sVar[:sVar.find("/")]
else:
myval=sVar
if myval in key:
if (res[myval]['type'] in ['many2one']):
sObject = res[myval]['relation']
return self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:])
else:
return sObject
def cmbVariable_selected(self,oItemEvent):
if self.count > 0 :
try:
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.win.removeListBoxItems("lstFields", 0, self.win.getListBoxItemCount("lstFields"))
self.aListFields=[]
tempItem = self.win.getComboBoxText("cmbVariable")
for var in self.aVariableList:
if var[:var.find("(")] == tempItem[:tempItem.find("(")]:
sItem=var
genTree(
sItem[sItem.find("(")+1:sItem.find(")")],
self.aListFields,
self.insField,
self.sMyHost,
2,
ending_excl=['one2many','many2one','many2many','reference'],
recur=['many2one']
)
except:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('Fields', LOG_ERROR, info)
def btnOk_clicked( self, oActionEvent ):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
cursor = doc.getCurrentController().getViewCursor()
for i in self.win.getListBoxSelectedItemsPos("lstFields"):
itemSelected = self.aListFields[i]
itemSelectedPos = i
txtUName=self.win.getEditText("txtUName")
sKey=u""+txtUName
if itemSelected != "" and txtUName != "" and self.bModify==True :
txtUName=self.sGDisplayName
sKey=u""+txtUName
txtUName=self.sGDisplayName
oCurObj=cursor.TextField
sObjName=self.insVariable.getText()
sObjName=sObjName[:sObjName.find("(")]
sValue=u"[[ " + sObjName + self.aListFields[itemSelectedPos].replace("/",".") + " ]]"
oCurObj.Items = (sKey,sValue)
oCurObj.update()
self.win.endExecute()
elif itemSelected != "" and txtUName != "" :
oInputList = doc.createInstance("com.sun.star.text.TextField.DropDown")
sObjName=self.win.getComboBoxText("cmbVariable")
sObjName=sObjName[:sObjName.find("(")]
widget = ( cursor.TextTable and cursor.TextTable.getCellByName( cursor.Cell.CellName ) or doc.Text )
sValue = u"[[ " + sObjName + self.aListFields[itemSelectedPos].replace("/",".") + " ]]"
oInputList.Items = (sKey,sValue)
widget.insertTextContent(cursor,oInputList,False)
self.win.endExecute()
else:
ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields")
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
Fields()
elif __name__=="package":
g_ImplementationHelper.addImplementation( Fields, "org.openoffice.openerp.report.fields", ("com.sun.star.task.Job",),)
@@ -0,0 +1,55 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
if __name__<>"package":
from ServerParameter import *
from lib.gui import *
class LoginTest:
def __init__(self):
if not loginstatus:
ServerParameter(None)
@@ -0,0 +1,213 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
import base64, tempfile
from com.sun.star.task import XJobExecutor
import os
import sys
if __name__<>'package':
from lib.gui import *
from lib.error import *
from LoginTest import *
from lib.logreport import *
from lib.rpc import *
database="test"
uid = 3
#
class ModifyExistingReport(unohelper.Base, XJobExecutor):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
self.win = DBModalDialog(60, 50, 180, 120, "Modify Existing Report")
self.win.addFixedText("lblReport", 2, 3, 60, 15, "Report Selection")
self.win.addComboListBox("lstReport", -1,15,178,80 , False )
self.lstReport = self.win.getControl( "lstReport" )
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.logobj=Logger()
self.hostname = docinfo.getUserFieldValue(0)
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
# Open a new connexion to the server
ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
if not len(ids):
ErrorDialog("Please Install base_report_designer module", "", "Module Uninstalled Error")
exit(1)
ids = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'search', [('report_xsl', '=', False),('report_xml', '=', False)])
fields=['id', 'name','report_name','model']
self.reports = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'read', ids, fields)
self.report_with_id = []
for report in self.reports:
if report['name']<>"":
model_ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search', [('model','=', report['model'])])
model_res_other =self.sock.execute(database, uid, self.password, 'ir.model', 'read', model_ids, [ 'name', 'model' ] )
if model_res_other <> []:
name = model_res_other[0]['name'] + " - " + report['name']
else:
name = report['name'] + " - " + report['model']
self.report_with_id.append( (report['id'], name, report['model'] ) )
self.report_with_id.sort( lambda x, y: cmp( x[1], y[1] ) )
for id, report_name, model_name in self.report_with_id:
self.lstReport.addItem( report_name, self.lstReport.getItemCount() )
self.win.addButton('btnSave',10,-5,50,15,'Open Report' ,actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-10 ,-5,50,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
self.win.addButton('btnDelete',15 -80 ,-5,50,15,'Delete Report',actionListenerProc = self.btnDelete_clicked)
self.win.doModalDialog("lstReport",self.report_with_id[0][1] )
def btnOk_clicked(self, oActionEvent):
try:
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
selectedItemPos = self.win.getListBoxSelectedItemPos( "lstReport" )
id = self.report_with_id[ selectedItemPos ][0]
res = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'report_get', id)
if res['file_type'] in ['sxw','odt'] :
file_type = res['file_type']
else :
file_type = 'sxw'
fp_name = tempfile.mktemp('.'+file_type)
fp_name1="r"+fp_name
fp_path=os.path.join(fp_name1).replace("\\","/")
fp_win=fp_path[1:]
filename = ( os.name == 'nt' and fp_win or fp_name )
if res['report_sxw_content']:
write_data_to_file( filename, base64.decodestring(res['report_sxw_content']))
url = "file:///%s" % filename
arr=Array(makePropertyValue("MediaType","application/vnd.sun.xml.writer"),)
oDoc2 = desktop.loadComponentFromURL(url, "openerp", 55, arr)
docinfo2=oDoc2.getDocumentInfo()
docinfo2.setUserFieldValue(0, self.hostname)
docinfo2.setUserFieldValue(1,self.password)
docinfo2.setUserFieldValue(2,id)
docinfo2.setUserFieldValue(3,self.report_with_id[selectedItemPos][2])
oParEnum = oDoc2.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
oPar.SelectedItem = oPar.Items[0]
oPar.update()
if oDoc2.isModified():
if oDoc2.hasLocation() and not oDoc2.isReadonly():
oDoc2.store()
ErrorDialog("Download is Completed","Your file has been placed here :\n"+ fp_name,"Download Message")
obj=Logger()
obj.log_write('Modify Existing Report',LOG_INFO, ':successful download report %s using database %s' % (self.report_with_id[selectedItemPos][2], database))
except Exception, e:
ErrorDialog("Report has not been downloaded", "Report: %s\nDetails: %s" % ( fp_name, str(e) ),"Download Message")
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ModifyExistingReport', LOG_ERROR, info)
self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
def btnDelete_clicked( self, oActionEvent ):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
selectedItemPos = self.win.getListBoxSelectedItemPos( "lstReport" )
name=self.win.getListBoxSelectedItem ("lstReport")
id = self.report_with_id[ selectedItemPos ][0]
temp = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'unlink', id,)
str_value='ir.actions.report.xml,'+str(id)
ids = self.sock.execute(database, uid, self.password, 'ir.values' , 'search',[('value','=',str_value)])
if ids:
rec = self.sock.execute(database, uid, self.password, 'ir.values', 'unlink', ids,)
else :
pass
if temp:
ErrorDialog("Report","Report has been Delete:\n "+name,"Message")
self.logobj.log_write('Delete Report',LOG_INFO, ':successful delete report %s using database %s' % (name, database))
else:
ErrorDialog("Report","Report has not Delete:\n"+name," Message")
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
ModifyExistingReport(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( ModifyExistingReport, "org.openoffice.openerp.report.modifyreport", ("com.sun.star.task.Job",),)
@@ -0,0 +1,119 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.error import ErrorDialog
from lib.functions import *
from lib.logreport import *
from LoginTest import *
from lib.rpc import *
database="test"
uid = 3
#
#
#
# Start OpenOffice.org, listen for connections and open testing document
#
#
class NewReport(unohelper.Base, XJobExecutor):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
self.logobj=Logger()
if not loginstatus and __name__=="package":
exit(1)
self.win=DBModalDialog(60, 50, 180, 115, "Open New Report")
self.win.addFixedText("lblModuleSelection", 2, 2, 60, 15, "Module Selection")
self.win.addComboListBox("lstModule", -2,13,176,80 , False)
self.lstModule = self.win.getControl( "lstModule" )
self.aModuleName=[]
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search',[])
fields = [ 'model','name']
res = self.sock.execute(database, uid, self.password, 'ir.model' , 'read', ids, fields)
res.sort(lambda x, y: cmp(x['name'],y['name']))
for i in range(len(res)):
self.lstModule.addItem(res[i]['name'],self.lstModule.getItemCount())
self.aModuleName.append(res[i]['model'])
self.win.addButton('btnOK',-2 ,-5, 70,15,'Use Module in Report' ,actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-2 - 70 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
self.win.doModalDialog("",None)
def btnOk_clicked(self,oActionEvent):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
docinfo.setUserFieldValue(3,self.aModuleName[self.lstModule.getSelectedItemPos()])
self.logobj.log_write('Module Name',LOG_INFO, ':Module use in creating a report %s using database %s' % (self.aModuleName[self.lstModule.getSelectedItemPos()], database))
self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
NewReport(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( \
NewReport,
"org.openoffice.openerp.report.opennewreport",
("com.sun.star.task.Job",),)
@@ -0,0 +1,300 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.error import ErrorDialog
from lib.functions import *
from ServerParameter import *
from lib.logreport import *
from lib.rpc import *
from LoginTest import *
database="test_db1"
uid = 3
#class RepeatIn:
class RepeatIn( unohelper.Base, XJobExecutor ):
def __init__(self,sObject="",sVariable="",sFields="",sDisplayName="",bFromModify=False):
# Interface Design
LoginTest()
self.logobj=Logger()
if not loginstatus and __name__=="package":
exit(1)
self.win = DBModalDialog(60, 50, 180, 250, "RepeatIn Builder")
self.win.addFixedText("lblVariable", 2, 12, 60, 15, "Objects to loop on :")
self.win.addComboBox("cmbVariable", 180-120-2, 10, 120, 15,True, itemListenerProc=self.cmbVariable_selected)
self.insVariable = self.win.getControl( "cmbVariable" )
self.win.addFixedText("lblFields", 10, 32, 60, 15, "Field to loop on :")
self.win.addComboListBox("lstFields", 180-120-2, 30, 120, 150, False,itemListenerProc=self.lstbox_selected)
self.insField = self.win.getControl( "lstFields" )
self.win.addFixedText("lblName", 12, 187, 60, 15, "Variable name :")
self.win.addEdit("txtName", 180-120-2, 185, 120, 15,)
self.win.addFixedText("lblUName", 8, 207, 60, 15, "Displayed name :")
self.win.addEdit("txtUName", 180-120-2, 205, 120, 15,)
self.win.addButton('btnOK',-2 ,-10,45,15,'Ok', actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-2 - 45 - 5 ,-10,45,15,'Cancel', actionListenerProc = self.btnCancel_clicked )
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
# Variable Declaration
self.sValue=None
self.sObj=None
self.aSectionList=[]
self.sGVariable=sVariable
self.sGDisplayName=sDisplayName
self.aItemList=[]
self.aComponentAdd=[]
self.aObjectList=[]
self.aListRepeatIn=[]
self.aVariableList=[]
# Call method to perform Enumration on Report Document
EnumDocument(self.aItemList,self.aComponentAdd)
# Perform checking that Field-1 and Field - 4 is available or not alos get Combobox
# filled if condition is true
desktop = getDesktop()
doc = desktop.getCurrentComponent()
docinfo = doc.getDocumentInfo()
# Check weather Field-1 is available if not then exit from application
self.sMyHost= ""
if not docinfo.getUserFieldValue(3) == "" and not docinfo.getUserFieldValue(0)=="":
self.sMyHost= docinfo.getUserFieldValue(0)
self.count=0
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
self.count += 1
getList(self.aObjectList, self.sMyHost,self.count)
cursor = doc.getCurrentController().getViewCursor()
text = cursor.getText()
tcur = text.createTextCursorByRange(cursor)
self.aVariableList.extend( filter( lambda obj: obj[:obj.find(" ")] == "List", self.aObjectList ) )
for i in range(len(self.aItemList)):
try:
anItem = self.aItemList[i][1]
component = self.aComponentAdd[i]
if component == "Document":
sLVal = anItem[anItem.find(",'") + 2:anItem.find("')")]
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == sLVal, self.aObjectList ) )
if tcur.TextSection:
getRecersiveSection(tcur.TextSection,self.aSectionList)
if component in self.aSectionList:
sLVal = anItem[anItem.find(",'") + 2:anItem.find("')")]
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == sLVal, self.aObjectList ) )
if tcur.TextTable:
if not component == "Document" and component[component.rfind(".") + 1:] == tcur.TextTable.Name:
VariableScope( tcur, self.aVariableList, self.aObjectList, self.aComponentAdd, self.aItemList, component )
except :
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('RepeatIn', LOG_ERROR, info)
self.bModify=bFromModify
if self.bModify==True:
if sObject=="":
self.insVariable.setText("List of "+docinfo.getUserFieldValue(3))
self.insField.addItem("objects",self.win.getListBoxItemCount("lstFields"))
self.win.setEditText("txtName", sVariable)
self.win.setEditText("txtUName",sDisplayName)
self.sValue= "objects"
else:
sItem=""
for anObject in self.aObjectList:
if anObject[:anObject.find("(")] == sObject:
sItem = anObject
self.insVariable.setText( sItem )
genTree(
sItem[sItem.find("(")+1:sItem.find(")")],
self.aListRepeatIn,
self.insField,
self.sMyHost,
2,
ending=['one2many','many2many'],
recur=['one2many','many2many']
)
self.sValue= self.win.getListBoxItem("lstFields",self.aListRepeatIn.index(sFields))
for var in self.aVariableList:
if var[:8] <> 'List of ':
self.model_ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search', [('model','=',var[var.find("(")+1:var.find(")")])])
else:
self.model_ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search', [('model','=',var[8:])])
fields=['name','model']
self.model_res = self.sock.execute(database, uid, self.password, 'ir.model', 'read', self.model_ids,fields)
if self.model_res <> []:
if var[:8]<>'List of ':
self.insVariable.addItem(var[:var.find("(")+1] + self.model_res[0]['name'] + ")" ,self.insVariable.getItemCount())
else:
self.insVariable.addItem('List of ' + self.model_res[0]['name'] ,self.insVariable.getItemCount())
else:
self.insVariable.addItem(var ,self.insVariable.getItemCount())
self.win.doModalDialog("lstFields",self.sValue)
else:
ErrorDialog("Please Select Appropriate module" ,"Create new report from: \nOpenERP -> Open a New Report")
self.win.endExecute()
def lstbox_selected(self,oItemEvent):
sItem=self.win.getListBoxSelectedItem("lstFields")
sMain=self.aListRepeatIn[self.win.getListBoxSelectedItemPos("lstFields")]
if self.bModify==True:
self.win.setEditText("txtName", self.sGVariable)
self.win.setEditText("txtUName",self.sGDisplayName)
else:
self.win.setEditText("txtName",sMain[sMain.rfind("/")+1:])
self.win.setEditText("txtUName","|-."+sItem[sItem.rfind("/")+1:]+".-|")
def cmbVariable_selected(self,oItemEvent):
if self.count > 0 :
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.win.removeListBoxItems("lstFields", 0, self.win.getListBoxItemCount("lstFields"))
sItem=self.win.getComboBoxText("cmbVariable")
for var in self.aVariableList:
if var[:8]=='List of ':
if var[:8]==sItem[:8]:
sItem = var
elif var[:var.find("(")+1] == sItem[:sItem.find("(")+1]:
sItem = var
self.aListRepeatIn=[]
data = ( sItem[sItem.rfind(" ") + 1:] == docinfo.getUserFieldValue(3) ) and docinfo.getUserFieldValue(3) or sItem[sItem.find("(")+1:sItem.find(")")]
genTree( data, self.aListRepeatIn, self.insField, self.sMyHost, 2, ending=['one2many','many2many'], recur=['one2many','many2many'] )
self.win.selectListBoxItemPos("lstFields", 0, True )
else:
sItem=self.win.getComboBoxText("cmbVariable")
for var in self.aVariableList:
if var[:8]=='List of ' and var[:8] == sItem[:8]:
sItem = var
if sItem.find(".")==-1:
temp=sItem[sItem.rfind("x_"):]
else:
temp=sItem[sItem.rfind(".")+1:]
self.win.setEditText("txtName",temp)
self.win.setEditText("txtUName","|-."+temp+".-|")
self.insField.addItem("objects",self.win.getListBoxItemCount("lstFields"))
self.win.selectListBoxItemPos("lstFields", 0, True )
def btnOk_clicked(self, oActionEvent):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
cursor = doc.getCurrentController().getViewCursor()
selectedItem = self.win.getListBoxSelectedItem( "lstFields" )
selectedItemPos = self.win.getListBoxSelectedItemPos( "lstFields" )
txtName = self.win.getEditText( "txtName" )
txtUName = self.win.getEditText( "txtUName" )
if selectedItem != "" and txtName != "" and txtUName != "":
sKey=u""+ txtUName
if selectedItem == "objects":
sValue=u"[[ repeatIn(" + selectedItem + ",'" + txtName + "') ]]"
else:
sObjName=self.win.getComboBoxText("cmbVariable")
sObjName=sObjName[:sObjName.find("(")]
sValue=u"[[ repeatIn(" + sObjName + self.aListRepeatIn[selectedItemPos].replace("/",".") + ",'" + txtName +"') ]]"
if self.bModify == True:
oCurObj = cursor.TextField
oCurObj.Items = (sKey,sValue)
oCurObj.update()
else:
oInputList = doc.createInstance("com.sun.star.text.TextField.DropDown")
if self.win.getListBoxSelectedItem("lstFields") == "objects":
oInputList.Items = (sKey,sValue)
doc.Text.insertTextContent(cursor,oInputList,False)
else:
sValue=u"[[ repeatIn(" + sObjName + self.aListRepeatIn[selectedItemPos].replace("/",".") + ",'" + txtName +"') ]]"
if cursor.TextTable==None:
oInputList.Items = (sKey,sValue)
doc.Text.insertTextContent(cursor,oInputList,False)
else:
oInputList.Items = (sKey,sValue)
widget = ( cursor.TextTable or selectedItem <> 'objects' ) and cursor.TextTable.getCellByName( cursor.Cell.CellName ) or doc.Text
widget.insertTextContent(cursor,oInputList,False)
self.win.endExecute()
else:
ErrorDialog("Please Fill appropriate data in Object Field or Name field \nor select perticular value from the list of fields")
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
RepeatIn()
elif __name__=="package":
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation( RepeatIn, "org.openoffice.openerp.report.repeatln", ("com.sun.star.task.Job",),)
@@ -0,0 +1,241 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import random
import xmlrpclib
import base64, tempfile
from com.sun.star.task import XJobExecutor
import os
import sys
if __name__<>'package':
from lib.gui import *
from lib.error import *
from lib.functions import *
from lib.logreport import *
from lib.tools import *
from LoginTest import *
from lib.rpc import *
database="report"
uid = 3
#
#
class SendtoServer(unohelper.Base, XJobExecutor):
Kind = {
'PDF' : 'pdf',
'OpenOffice': 'sxw',
'HTML' : 'html'
}
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
LoginTest()
self.logobj=Logger()
if not loginstatus and __name__=="package":
exit(1)
global passwd
self.password = passwd
global url
self.sock=RPCSession(url)
desktop=getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo=oDoc2.getDocumentInfo()
self.ids = self.sock.execute(database, uid, self.password, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
if not len(self.ids):
ErrorDialog("Please Install base_report_designer module", "", "Module Uninstalled Error")
exit(1)
report_name = ""
name=""
if docinfo.getUserFieldValue(2)<>"" :
try:
fields=['name','report_name']
self.res_other = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'read', [int(docinfo.getUserFieldValue(2))],fields)
name = self.res_other[0]['name']
report_name = self.res_other[0]['report_name']
except:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logob.log_write('ServerParameter', LOG_ERROR, info)
elif docinfo.getUserFieldValue(3) <> "":
name = ""
result = "rnd"
for i in range(5):
result =result + random.choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')
report_name = docinfo.getUserFieldValue(3) + "." + result
else:
ErrorDialog("Please select appropriate module...","Note: use OpenERP Report -> Open a new Report", "Module selection ERROR");
exit(1)
self.win = DBModalDialog(60, 50, 180, 100, "Send To Server")
self.win.addFixedText("lblName",10 , 9, 40, 15, "Report Name :")
self.win.addEdit("txtName", -5, 5, 123, 15,name)
self.win.addFixedText("lblReportName", 2, 30, 50, 15, "Technical Name :")
self.win.addEdit("txtReportName", -5, 25, 123, 15,report_name)
self.win.addCheckBox("chkHeader", 51, 45, 70 ,15, "Corporate Header")
self.win.addFixedText("lblResourceType", 2 , 60, 50, 15, "Select Rpt. Type :")
self.win.addComboListBox("lstResourceType", -5, 58, 123, 15,True,itemListenerProc=self.lstbox_selected)
self.lstResourceType = self.win.getControl( "lstResourceType" )
self.txtReportName=self.win.getControl( "txtReportName" )
self.txtReportName.Enable=False
for kind in self.Kind.keys():
self.lstResourceType.addItem( kind, self.lstResourceType.getItemCount() )
self.win.addButton( "btnSend", -5, -5, 80, 15, "Send Report to Server", actionListenerProc = self.btnOk_clicked)
self.win.addButton( "btnCancel", -5 - 80 -5, -5, 40, 15, "Cancel", actionListenerProc = self.btnCancel_clicked)
self.win.doModalDialog("lstResourceType", self.Kind.keys()[0])
def lstbox_selected(self,oItemEvent):
pass
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
def btnOk_clicked(self, oActionEvent):
if self.win.getEditText("txtName") <> "" and self.win.getEditText("txtReportName") <> "":
desktop=getDesktop()
oDoc2 = desktop.getCurrentComponent()
docinfo=oDoc2.getDocumentInfo()
self.getInverseFieldsRecord(1)
fp_name = tempfile.mktemp('.'+"sxw")
if not oDoc2.hasLocation():
oDoc2.storeAsURL("file://"+fp_name,Array(makePropertyValue("MediaType","application/vnd.sun.xml.writer"),))
if docinfo.getUserFieldValue(2)=="":
name=self.win.getEditText("txtName"),
name_id={}
try:
name_id = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml' , 'search',[('name','=',name)])
if not name_id:
id=self.getID()
docinfo.setUserFieldValue(2,id)
rec = {
'name': self.win.getEditText("txtReportName"),
'key': 'action',
'model': docinfo.getUserFieldValue(3),
'value': 'ir.actions.report.xml,'+str(id),
'key2': 'client_print_multi',
'object': True
}
res = self.sock.execute(database, uid, self.password, 'ir.values' , 'create',rec )
else :
ErrorDialog(" Report Name is all ready given !!!\n\n\n Please specify other Name","","Report Name")
self.logobj.log_write('SendToServer',LOG_WARNING, ':Report name all ready given DB %s' % (database))
self.win.endExecute()
except Exception,e:
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ServerParameter', LOG_ERROR, info)
else:
id = docinfo.getUserFieldValue(2)
vId = self.sock.execute(database, uid, self.password, 'ir.values' , 'search', [('value','=','ir.actions.report.xml,'+str(id))])
rec = { 'name': self.win.getEditText("txtReportName") }
res = self.sock.execute(database, uid, self.password, 'ir.values' , 'write',vId,rec)
oDoc2.store()
data = read_data_from_file( get_absolute_file_path( oDoc2.getURL()[7:] ) )
self.getInverseFieldsRecord(0)
#sock = xmlrpclib.ServerProxy(docinfo.getUserFieldValue(0) +'/xmlrpc/object')
file_type = oDoc2.getURL()[7:].split(".")[-1]
res = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'upload_report', int(docinfo.getUserFieldValue(2)),base64.encodestring(data),file_type,{})
params = {
'name': self.win.getEditText("txtName"),
'model': docinfo.getUserFieldValue(3),
'report_name': self.win.getEditText("txtReportName"),
'header': (self.win.getCheckBoxState("chkHeader") <> 0),
'report_type': self.Kind[self.win.getListBoxSelectedItem("lstResourceType")],
}
if self.win.getListBoxSelectedItem("lstResourceType")=='OpenOffice':
params['report_type']=file_type
res = self.sock.execute(database, uid, self.password, 'ir.actions.report.xml', 'write', int(docinfo.getUserFieldValue(2)), params)
self.logobj.log_write('SendToServer',LOG_INFO, ':Report %s successfully send using %s'%(params['name'],database))
self.win.endExecute()
else:
ErrorDialog("Either Report Name or Technical Name is blank !!!\nPlease specify appropriate Name","","Blank Field ERROR")
self.logobj.log_write('SendToServer',LOG_WARNING, ':Either Report Name or Technical Name is blank')
self.win.endExecute()
def getID(self):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
params = {
'name': self.win.getEditText("txtName"),
'model': docinfo.getUserFieldValue(3),
'report_name': self.win.getEditText('txtReportName')
}
id=self.sock.execute(database, uid, self.password, 'ir.actions.report.xml' ,'create', params)
return id
def getInverseFieldsRecord(self,nVal):
desktop=getDesktop()
doc = desktop.getCurrentComponent()
count=0
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
oPar.SelectedItem = oPar.Items[nVal]
if nVal==0:
oPar.update()
if __name__<>"package" and __name__=="__main__":
SendtoServer(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( SendtoServer, "org.openoffice.openerp.report.sendtoserver", ("com.sun.star.task.Job",),)
@@ -0,0 +1,208 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.error import ErrorDialog
from lib.functions import *
from lib.logreport import *
from lib.rpc import *
from Change import *
database="test"
class ServerParameter( unohelper.Base, XJobExecutor ):
def __init__(self,ctx):
self.ctx = ctx
self.module = "openerp_report"
self.version = "0.1"
desktop=getDesktop()
log_detail(self)
self.logobj=Logger()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.win=DBModalDialog(60, 50, 160, 108, "Server Connection Parameter")
self.win.addFixedText("lblVariable", 2, 12, 35, 15, "Server URL")
if docinfo.getUserFieldValue(0)=="":
docinfo.setUserFieldValue(0,"http://localhost:8069")
self.win.addEdit("txtHost",-34,9,91,15,docinfo.getUserFieldValue(0))
self.win.addButton('btnChange',-2 ,9,30,15,'Change', actionListenerProc = self.btnChange_clicked )
self.win.addFixedText("lblDatabaseName", 6, 31, 31, 15, "Database")
#self.win.addFixedText("lblMsg", -2,28,123,15)
# self.win.addComboListBox("lstDatabase", -2,28,123,15, True)
# self.lstDatabase = self.win.getControl( "lstDatabase" )
#self.win.selectListBoxItem( "lstDatabase", docinfo.getUserFieldValue(2), True )
#self.win.setEnabled("lblMsg",False)
self.win.addFixedText("lblLoginName", 17, 51, 20, 15, "Login")
self.win.addEdit("txtLoginName",-2,48,123,15,docinfo.getUserFieldValue(1))
self.win.addFixedText("lblPassword", 6, 70, 31, 15, "Password")
self.win.addEdit("txtPassword",-2,67,123,15,)
self.win.setEchoChar("txtPassword",42)
self.win.addButton('btnOK',-2 ,-5, 60,15,'Connect' ,actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-2 - 60 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
sValue=""
if docinfo.getUserFieldValue(0)<>"":
global url
global result
url=docinfo.getUserFieldValue(0)
self.sock=RPCSession(url)
res=self.sock.listdb()
result=res
if res == -1:
self.win.addEdit("lstDatabase",-2,28,123,15)
# sValue="Could not connect to the server!"
# self.lstDatabase.addItem("Could not connect to the server!",0)
elif res == 0:
sValue="No Database found !!!"
self.lstDatabase.addItem("No Database found !!!",0)
else:
self.win.addComboListBox("lstDatabase", -2,28,123,15, True)
self.lstDatabase = self.win.getControl( "lstDatabase" )
self.win.removeListBoxItems("lstDatabase", 0, self.win.getListBoxItemCount("lstDatabase"))
for i in range(len(res)):
self.lstDatabase.addItem(res[i],i)
sValue = database
if sValue:
self.win.doModalDialog("lstDatabase",sValue)
else:
self.win.doModalDialog("lstDatabase",None)
#self.win.doModalDialog("lstDatabase",docinfo.getUserFieldValue(2))
def btnOk_clicked(self,oActionEvent):
sLogin=self.win.getEditText("txtLoginName")
sPassword=self.win.getEditText("txtPassword")
global url
global result
if result==-1:
sDatabase=self.win.getEditText("lstDatabase")
else:
sDatabase=self.win.getListBoxSelectedItem("lstDatabase")
self.sock=RPCSession(url)
UID = self.sock.login(sDatabase,sLogin,sPassword)
if not UID :
ErrorDialog("Connection Refuse...","Please enter valid Login/Password")
self.win.endExecute()
try:
ids = self.sock.execute(sDatabase,UID,sPassword, 'res.groups' , 'search', [('name','=','OpenOfficeReportDesigner')])
ids_module =self.sock.execute(sDatabase, UID, sPassword, 'ir.module.module', 'search', [('name','=','base_report_designer'),('state', '=', 'installed')])
dict_groups =self.sock.execute(sDatabase, UID,sPassword, 'res.groups' , 'read',ids,['users'])
except :
import traceback,sys
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ServerParameter', LOG_ERROR, info)
if not len(ids) :
ErrorDialog("Group Not Found!!! Create a group named \n\n"'"OpenOfficeReportDesigner"'" \n\n ","","Group Name Error")
self.logobj.log_write('Group Error',LOG_WARNING, ':Create a group OpenOfficeReportDesigner using database %s' % (sDatabase))
self.win.endExecute()
if not len(ids_module):
ErrorDialog("Please Install base_report_designer module", "", "Module Uninstalled Error")
self.logobj.log_write('Module Not Found',LOG_WARNING, ':base_report_designer not install in database %s' % (sDatabase))
self.win.endExecute()
if UID not in dict_groups[0]['users']:
ErrorDialog("Connection Refuse...","You have not access these Report Designer")
self.logobj.log_write('Connection Refuse',LOG_WARNING, " Not Access Report Designer ")
self.win.endExecute()
else:
desktop=getDesktop()
doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
docinfo.setUserFieldValue(0,self.win.getEditText("txtHost"))
docinfo.setUserFieldValue(1,self.win.getEditText("txtLoginName"))
global passwd
passwd=self.win.getEditText("txtPassword")
global loginstatus
loginstatus=True
global database
database=sDatabase
global uid
uid=UID
#docinfo.setUserFieldValue(2,self.win.getListBoxSelectedItem("lstDatabase"))
#docinfo.setUserFieldValue(3,"")
ErrorDialog(" You can start creating your report in \n \t the current document.","After Creating sending to the server.","Message")
self.logobj.log_write('successful login',LOG_INFO, ':successful login from %s using database %s' % (sLogin, sDatabase))
self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
def btnChange_clicked(self,oActionEvent):
aVal=[]
url= self.win.getEditText("txtHost")
Change(aVal,url)
if aVal[1]== -1:
self.win.getEditText("lstDatabase")
elif aVal[1]==0:
ErrorDialog(aVal[0],"")
else:
self.win.setEditText("txtHost",aVal[0])
self.win.removeListBoxItems("lstDatabase", 0, self.win.getListBoxItemCount("lstDatabase"))
for i in range(len(aVal[1])):
self.lstDatabase.addItem(aVal[1][i],i)
if __name__<>"package" and __name__=="__main__":
ServerParameter(None)
elif __name__=="package":
g_ImplementationHelper.addImplementation( ServerParameter, "org.openoffice.openerp.report.serverparam", ("com.sun.star.task.Job",),)
@@ -0,0 +1,274 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import string
import unohelper
import xmlrpclib
from com.sun.star.task import XJobExecutor
if __name__<>"package":
from lib.gui import *
from lib.functions import *
from lib.error import ErrorDialog
from LoginTest import *
from lib.rpc import *
database="test_001"
uid = 3
class AddLang(unohelper.Base, XJobExecutor ):
def __init__(self,sVariable="",sFields="",sDisplayName="",bFromModify=False):
LoginTest()
if not loginstatus and __name__=="package":
exit(1)
global passwd
self.password = passwd
self.win = DBModalDialog(60, 50, 180, 225, "Set Lang Builder")
self.win.addFixedText("lblVariable", 27, 12, 60, 15, "Variable :")
self.win.addComboBox("cmbVariable", 180-120-2, 10, 120, 15,True,
itemListenerProc=self.cmbVariable_selected)
self.insVariable = self.win.getControl( "cmbVariable" )
self.win.addFixedText("lblFields", 10, 32, 60, 15, "Variable Fields :")
self.win.addComboListBox("lstFields", 180-120-2, 30, 120, 150, False,itemListenerProc=self.lstbox_selected)
self.insField = self.win.getControl( "lstFields" )
self.win.addFixedText("lblUName", 8, 187, 60, 15, "Displayed name :")
self.win.addEdit("txtUName", 180-120-2, 185, 120, 15,)
self.win.addButton('btnOK',-5 ,-5, 45, 15, 'Ok', actionListenerProc = self.btnOk_clicked )
self.win.addButton('btnCancel',-5 - 45 - 5 ,-5,45,15,'Cancel', actionListenerProc = self.btnCancel_clicked )
self.sValue=None
self.sObj=None
self.aSectionList=[]
self.sGDisplayName=sDisplayName
self.aItemList=[]
self.aComponentAdd=[]
self.aObjectList=[]
self.aListFields=[]
self.aVariableList=[]
EnumDocument(self.aItemList,self.aComponentAdd)
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.sMyHost= ""
global url
self.sock=RPCSession(url)
if not docinfo.getUserFieldValue(3) == "" and not docinfo.getUserFieldValue(0)=="":
self.sMyHost= docinfo.getUserFieldValue(0)
self.count=0
oParEnum = doc.getTextFields().createEnumeration()
while oParEnum.hasMoreElements():
oPar = oParEnum.nextElement()
if oPar.supportsService("com.sun.star.text.TextField.DropDown"):
self.count += 1
getList(self.aObjectList, self.sMyHost,self.count)
cursor = doc.getCurrentController().getViewCursor()
text=cursor.getText()
tcur=text.createTextCursorByRange(cursor)
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == "Objects", self.aObjectList ) )
for i in range(len(self.aItemList)):
anItem = self.aItemList[i][1]
component = self.aComponentAdd[i]
if component == "Document":
sLVal = anItem[anItem.find(",'") + 2:anItem.find("')")]
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == sLVal, self.aObjectList ) )
if tcur.TextSection:
getRecersiveSection(tcur.TextSection,self.aSectionList)
if component in self.aSectionList:
sLVal = anItem[anItem.find(",'") + 2:anItem.find("')")]
self.aVariableList.extend( filter( lambda obj: obj[:obj.find("(")] == sLVal, self.aObjectList ) )
if tcur.TextTable:
if not component == "Document" and component[component.rfind(".") + 1:] == tcur.TextTable.Name:
VariableScope(tcur,self.insVariable,self.aObjectList,self.aComponentAdd,self.aItemList,component)
self.bModify=bFromModify
if self.bModify==True:
sItem=""
for anObject in self.aObjectList:
if anObject[:anObject.find("(")] == sVariable:
sItem = anObject
self.insVariable.setText( sItem )
genTree(sItem[sItem.find("(")+1:sItem.find(")")],self.aListFields, self.insField,self.sMyHost,2,ending_excl=['one2many','many2one','many2many','reference'], recur=['many2one'])
self.sValue= self.win.getListBoxItem("lstFields",self.aListFields.index(sFields))
for var in self.aVariableList:
self.model_ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search', [('model','=',var[var.find("(")+1:var.find(")")])])
fields=['name','model']
self.model_res = self.sock.execute(database, uid, self.password, 'ir.model', 'read', self.model_ids,fields)
if self.model_res <> []:
self.insVariable.addItem(var[:var.find("(")+1] + self.model_res[0]['name'] + ")" ,self.insVariable.getItemCount())
else:
self.insVariable.addItem(var ,self.insVariable.getItemCount())
self.win.doModalDialog("lstFields",self.sValue)
else:
ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice")
self.win.endExecute()
def lstbox_selected(self,oItemEvent):
try:
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
sItem= self.win.getComboBoxText("cmbVariable")
for var in self.aVariableList:
if var[:var.find("(")+1]==sItem[:sItem.find("(")+1]:
sItem = var
sMain=self.aListFields[self.win.getListBoxSelectedItemPos("lstFields")]
t=sMain.rfind('/lang')
if t!=-1:
sObject=self.getRes(self.sock,sItem[sItem.find("(")+1:-1],sMain[1:])
ids = self.sock.execute(database, uid, self.password, sObject , 'search', [])
res = self.sock.execute(database, uid, self.password, sObject , 'read',[ids[0]])
self.win.setEditText("txtUName",res[0][sMain[sMain.rfind("/")+1:]])
else:
ErrorDialog("Please select the Language Field")
except:
import traceback;traceback.print_exc()
self.win.setEditText("txtUName","TTT")
if self.bModify:
self.win.setEditText("txtUName",self.sGDisplayName)
def getRes(self,sock ,sObject,sVar):
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
res = sock.execute(database, uid, self.password, sObject , 'fields_get')
key = res.keys()
key.sort()
myval=None
if not sVar.find("/")==-1:
myval=sVar[:sVar.find("/")]
else:
myval=sVar
if myval in key:
if (res[myval]['type'] in ['many2one']):
sObject = res[myval]['relation']
return self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:])
else:
return sObject
def cmbVariable_selected(self,oItemEvent):
if self.count > 0 :
try:
desktop=getDesktop()
doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo()
self.win.removeListBoxItems("lstFields", 0, self.win.getListBoxItemCount("lstFields"))
self.aListFields=[]
tempItem = self.win.getComboBoxText("cmbVariable")
for var in self.aVariableList:
if var[:var.find("(")] == tempItem[:tempItem.find("(")]:
sItem=var
genTree(
sItem[ sItem.find("(") + 1:sItem.find(")")],
self.aListFields,
self.insField,
self.sMyHost,
2,
ending_excl=['one2many','many2one','many2many','reference'],
recur=['many2one']
)
except:
import traceback;traceback.print_exc()
def btnOk_clicked( self, oActionEvent ):
self.bOkay = True
desktop=getDesktop()
doc = desktop.getCurrentComponent()
cursor = doc.getCurrentController().getViewCursor()
itemSelected = self.win.getListBoxSelectedItem( "lstFields" )
itemSelectedPos = self.win.getListBoxSelectedItemPos( "lstFields" )
txtUName = self.win.getEditText("txtUName")
sKey=u""+ txtUName
if itemSelected != "" and txtUName != "" and self.bModify==True :
oCurObj=cursor.TextField
sObjName=self.insVariable.getText()
sObjName=sObjName[:sObjName.find("(")]
sValue=u"[[ setLang" + sObjName + self.aListFields[itemSelectedPos].replace("/",".") + ")" " ]]"
oCurObj.Items = (sKey,sValue)
oCurObj.update()
self.win.endExecute()
elif itemSelected != "" and txtUName != "" :
oInputList = doc.createInstance("com.sun.star.text.TextField.DropDown")
sObjName=self.win.getComboBoxText("cmbVariable")
sObjName=sObjName[:sObjName.find("(")]
widget = ( cursor.TextTable and cursor.TextTable.getCellByName( cursor.Cell.CellName ) or doc.Text )
sValue = u"[[setLang" + "(" + sObjName + self.aListFields[itemSelectedPos].replace("/",".") +")" " ]]"
oInputList.Items = (sKey,sValue)
widget.insertTextContent(cursor,oInputList,False)
self.win.endExecute()
else:
ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields")
def btnCancel_clicked( self, oActionEvent ):
self.win.endExecute()
if __name__<>"package" and __name__=="__main__":
AddLang()
elif __name__=="package":
g_ImplementationHelper.addImplementation( AddLang, "org.openoffice.openerp.report.langtag", ("com.sun.star.task.Job",),)
@@ -0,0 +1,61 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import Expression
import lib
import Fields
import modify
import Repeatln
import ServerParameter
import NewReport
import LoginTest
import Change
import About
import AddAttachment
import ConvertBracesToField
import ConvertFieldsToBraces
import ExportToRML
import SendtoServer
@@ -0,0 +1,49 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import compileall
compileall.compile_dir('package')
@@ -0,0 +1,2 @@
__name__="package"
@@ -0,0 +1,28 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import actions
import error
import functions
import gui
import logreport
import rpc
import tiny_socket
@@ -0,0 +1,111 @@
##########################################################################
#
# Portions of this file are under the following copyright and license:
#
#
# Copyright (c) 2003-2004 Danny Brewer
# d29583@groovegarden.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See: http://www.gnu.org/licenses/lgpl.html
#
#
# and other portions are under the following copyright and license:
#
#
# OpenERP, Open Source Management Solution>..
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
import uno
import unohelper
import os
#--------------------------------------------------
# An ActionListener adapter.
# This object implements com.sun.star.awt.XActionListener.
# When actionPerformed is called, this will call an arbitrary
# python procedure, passing it...
# 1. the oActionEvent
# 2. any other parameters you specified to this object's constructor (as a tuple).
if __name__<>"package":
os.system( "ooffice '-accept=socket,host=localhost,port=2002;urp;'" )
passwd=""
database=""
uid=""
loginstatus=False
from com.sun.star.awt import XActionListener
class ActionListenerProcAdapter( unohelper.Base, XActionListener ):
def __init__( self, oProcToCall, tParams=() ):
self.oProcToCall = oProcToCall # a python procedure
self.tParams = tParams # a tuple
# oActionEvent is a com.sun.star.awt.ActionEvent struct.
def actionPerformed( self, oActionEvent ):
if callable( self.oProcToCall ):
apply( self.oProcToCall, (oActionEvent,) + self.tParams )
#--------------------------------------------------
# An ItemListener adapter.
# This object implements com.sun.star.awt.XItemListener.
# When itemStateChanged is called, this will call an arbitrary
# python procedure, passing it...
# 1. the oItemEvent
# 2. any other parameters you specified to this object's constructor (as a tuple).
from com.sun.star.awt import XItemListener
class ItemListenerProcAdapter( unohelper.Base, XItemListener ):
def __init__( self, oProcToCall, tParams=() ):
self.oProcToCall = oProcToCall # a python procedure
self.tParams = tParams # a tuple
# oItemEvent is a com.sun.star.awt.ItemEvent struct.
def itemStateChanged( self, oItemEvent ):
if callable( self.oProcToCall ):
apply( self.oProcToCall, (oItemEvent,) + self.tParams )
#--------------------------------------------------
# An TextListener adapter.
# This object implements com.sun.star.awt.XTextistener.
# When textChanged is called, this will call an arbitrary
# python procedure, passing it...
# 1. the oTextEvent
# 2. any other parameters you specified to this object's constructor (as a tuple).
from com.sun.star.awt import XTextListener
class TextListenerProcAdapter( unohelper.Base, XTextListener ):
def __init__( self, oProcToCall, tParams=() ):
self.oProcToCall = oProcToCall # a python procedure
self.tParams = tParams # a tuple
# oTextEvent is a com.sun.star.awt.TextEvent struct.
def textChanged( self, oTextEvent ):
if callable( self.oProcToCall ):
apply( self.oProcToCall, (oTextEvent,) + self.tParams )

Some files were not shown because too many files have changed in this diff Show More