[imp] vouchers
bzr revid: fp@tinyerp.com-20100914221534-qhe2zpb1dyo0ogmc
This commit is contained in:
@@ -141,7 +141,7 @@ class account_bank_statement(osv.osv):
|
||||
'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'),
|
||||
states={'confirm':[('readonly', True)]}),
|
||||
'balance_end': fields.function(_end_balance, method=True, string='Balance'),
|
||||
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, required=True),
|
||||
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
|
||||
'line_ids': fields.one2many('account.bank.statement.line',
|
||||
'statement_id', 'Statement lines',
|
||||
states={'confirm':[('readonly', True)]}),
|
||||
@@ -711,7 +711,7 @@ class account_bank_statement_line(osv.osv):
|
||||
'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, required=True),
|
||||
'company_id': fields.related('statement_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
|
||||
}
|
||||
_defaults = {
|
||||
'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
|
||||
|
||||
@@ -1117,7 +1117,6 @@ class account_move_line(osv.osv):
|
||||
context['period_id'] = m.period_id.id
|
||||
|
||||
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
|
||||
company_currency = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
|
||||
move_id = vals.get('move_id', False)
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id'])
|
||||
is_new_move = False
|
||||
@@ -1156,7 +1155,10 @@ class account_move_line(osv.osv):
|
||||
if a.id == vals['account_id']:
|
||||
ok = True
|
||||
break
|
||||
if (account.currency_id) and 'amount_currency' not in vals and account.currency_id.id <> company_currency:
|
||||
|
||||
# Automatically convert in the account's secondary currency if there is one and
|
||||
# the provided values were not already multi-currency
|
||||
if account.currency_id and 'amount_currency' not in vals and account.currency_id.id != account.company_id.currency_id.id:
|
||||
vals['currency_id'] = account.currency_id.id
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
ctx = {}
|
||||
|
||||
@@ -69,19 +69,19 @@ class account_balance(report_sxw.rml_parse, common_report_header):
|
||||
return super(account_balance ,self)._get_account(data)
|
||||
|
||||
def lines(self, form, ids=[], done=None):#, level=1):
|
||||
def _process_child(accounts,disp_acc,parent):
|
||||
def _process_child(accounts, disp_acc, parent):
|
||||
account_rec = [acct for acct in accounts if acct['id']==parent][0]
|
||||
res = {
|
||||
'id': account_rec['id'],
|
||||
'type': account_rec['type'],
|
||||
'type': account_rec['type'],
|
||||
'code': account_rec['code'],
|
||||
'name': account_rec['name'],
|
||||
'level': account_rec['level'],
|
||||
'debit': account_rec['debit'],
|
||||
'credit': account_rec['credit'],
|
||||
'balance': account_rec['balance'],
|
||||
'parent_id':account_rec['parent_id'],
|
||||
'bal_type':'',
|
||||
'parent_id': account_rec['parent_id'],
|
||||
'bal_type': '',
|
||||
}
|
||||
self.sum_debit += account_rec['debit']
|
||||
self.sum_credit += account_rec['credit']
|
||||
@@ -96,7 +96,7 @@ class account_balance(report_sxw.rml_parse, common_report_header):
|
||||
if account_rec['child_id']:
|
||||
for child in account_rec['child_id']:
|
||||
_process_child(accounts,disp_acc,child)
|
||||
|
||||
|
||||
obj_account = self.pool.get('account.account')
|
||||
if not ids:
|
||||
ids = self.ids
|
||||
@@ -113,6 +113,7 @@ class account_balance(report_sxw.rml_parse, common_report_header):
|
||||
elif form['filter'] == 'filter_date':
|
||||
ctx['date_from'] = form['date_from']
|
||||
ctx['date_to'] = form['date_to']
|
||||
ctx['state'] = form['target_move']
|
||||
parents = ids
|
||||
child_ids = obj_account._get_children_and_consol(self.cr, self.uid, ids, ctx)
|
||||
if child_ids:
|
||||
|
||||
@@ -40,6 +40,9 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
new_ids = ids
|
||||
self.sortby = data['form'].get('sortby', 'sort_date')
|
||||
self.query = data['form'].get('query_line', '')
|
||||
self.init_query = data['form']['initial_bal_query']
|
||||
self.init_balance = data['form']['initial_balance']
|
||||
self.display_account = data['form']['display_account']
|
||||
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)
|
||||
@@ -79,10 +82,10 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
"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 form.get('initial_balance', False):
|
||||
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, form['initial_bal_query']))
|
||||
"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)
|
||||
|
||||
@@ -99,10 +102,10 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
num_entry = self.cr.fetchone()[0] or 0
|
||||
sold_account = self._sum_balance_account(child_account,form)
|
||||
self.sold_accounts[child_account.id] = sold_account
|
||||
if form['display_account'] == 'bal_movement':
|
||||
if self.display_account == 'bal_movement':
|
||||
if child_account.type != 'view' and num_entry <> 0 :
|
||||
res.append(child_account)
|
||||
elif form['display_account'] == 'bal_solde':
|
||||
elif self.display_account == 'bal_solde':
|
||||
if child_account.type != 'view' and num_entry <> 0 :
|
||||
if ( sold_account <> 0.0):
|
||||
res.append(child_account)
|
||||
@@ -150,7 +153,7 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
self.cr.execute(sql, (account.id,))
|
||||
res_lines = self.cr.dictfetchall()
|
||||
res_init = []
|
||||
if res_lines and form['initial_balance']:
|
||||
if res_lines and self.init_balance:
|
||||
#FIXME: replace the label of lname with a string translatable
|
||||
sql = """
|
||||
SELECT 0 AS lid, '' AS ldate, '' AS lcode, COALESCE(SUM(l.amount_currency),0.0) AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id,
|
||||
@@ -165,7 +168,7 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
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
|
||||
""" %(form['initial_bal_query'])
|
||||
""" %(self.init_query)
|
||||
|
||||
self.cr.execute(sql, (account.id,))
|
||||
res_init = self.cr.dictfetchall()
|
||||
@@ -193,10 +196,10 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
|
||||
sum_debit = self.cr.fetchone()[0] or 0.0
|
||||
if form.get('initial_balance', False):
|
||||
if self.init_balance:
|
||||
self.cr.execute("SELECT sum(debit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, form['initial_bal_query']))
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
|
||||
# Add initial balance to the result
|
||||
sum_debit += self.cr.fetchone()[0] or 0.0
|
||||
return sum_debit
|
||||
@@ -206,10 +209,10 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.query))
|
||||
sum_credit = self.cr.fetchone()[0] or 0.0
|
||||
if form.get('initial_balance', False):
|
||||
if self.init_balance:
|
||||
self.cr.execute("SELECT sum(credit) "\
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, form['initial_bal_query']))
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
|
||||
# Add initial balance to the result
|
||||
sum_credit += self.cr.fetchone()[0] or 0.0
|
||||
return sum_credit
|
||||
@@ -219,10 +222,10 @@ class general_ledger(rml_parse.rml_parse, common_report_header):
|
||||
"FROM account_move_line l "\
|
||||
"WHERE l.account_id = %s AND %s"%(account.id, self.query))
|
||||
sum_balance = self.cr.fetchone()[0] or 0.0
|
||||
if form.get('initial_balance', False):
|
||||
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, form['initial_bal_query']))
|
||||
"WHERE l.account_id = %s AND %s "%(account.id, self.init_query))
|
||||
# Add initial balance to the result
|
||||
sum_balance += self.cr.fetchone()[0] or 0.0
|
||||
return sum_balance
|
||||
|
||||
@@ -99,12 +99,12 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
## Compute Code
|
||||
#
|
||||
self.initial_balance = data['form'].get('initial_balance', True)
|
||||
self.display_partner = data['form'].get('display_partner', 'non-zero_balance')
|
||||
# self.initial_balance = data['form'].get('initial_balance', True)
|
||||
self.display_partner = data['form'].get('display_partner', 'non-zero_balance')
|
||||
self.query = data['form'].get('query_line', '')
|
||||
self.init_query = data['form'].get('initial_bal_query', '')
|
||||
self.result_selection = data['form'].get('result_selection')
|
||||
|
||||
|
||||
if (self.result_selection == 'customer' ):
|
||||
self.ACCOUNT_TYPE = ('receivable',)
|
||||
elif (self.result_selection == 'supplier'):
|
||||
@@ -150,81 +150,81 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
|
||||
res = self.cr.dictfetchall()
|
||||
|
||||
#For include intial balance..
|
||||
if self.initial_balance:
|
||||
self.cr.execute(
|
||||
"SELECT '1' AS type, '' AS ref, l.account_id AS account_id, '' AS account_name, '' AS code, '' AS name, sum(debit) AS debit, sum(credit) AS credit, " \
|
||||
"CASE WHEN sum(debit) > sum(credit) " \
|
||||
"THEN sum(debit) - sum(credit) " \
|
||||
"ELSE 0 " \
|
||||
"END AS sdebit, " \
|
||||
"CASE WHEN sum(debit) < sum(credit) " \
|
||||
"THEN sum(credit) - sum(debit) " \
|
||||
"ELSE 0 " \
|
||||
"END AS scredit, " \
|
||||
"(SELECT sum(debit-credit) " \
|
||||
"FROM account_move_line l " \
|
||||
"WHERE partner_id = p.id " \
|
||||
" AND " + self.init_query + " " \
|
||||
"AND blocked = TRUE " \
|
||||
") AS enlitige " \
|
||||
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
|
||||
"JOIN account_account ac ON (l.account_id = ac.id) " \
|
||||
"WHERE ac.type IN %s " \
|
||||
"AND " + self.init_query + "" \
|
||||
"GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \
|
||||
"ORDER BY l.account_id, p.name",
|
||||
(self.ACCOUNT_TYPE, ))
|
||||
res1 = self.cr.dictfetchall()
|
||||
final_init = {}
|
||||
res_init = {}
|
||||
debit = credit = 0
|
||||
for r in res1:
|
||||
if final_init.get(r['account_id'], False):
|
||||
res_init = final_init[r['account_id']]
|
||||
debit += final_init[r['account_id']]['debit']
|
||||
credit += final_init[r['account_id']]['credit']
|
||||
res_init['credit'] = credit
|
||||
res_init['debit'] = debit
|
||||
res_init['type'] = 3
|
||||
res_init['ref'] = ''
|
||||
res_init['code'] = ''
|
||||
res_init['name'] = 'Initial Balance'
|
||||
res_init['balance'] = debit - credit
|
||||
res_init['enlitige'] = 0.0 # fix me
|
||||
res_init['account_id'] = final_init[r['account_id']]['account_id']
|
||||
else:
|
||||
res_init = {}
|
||||
debit = r['debit']
|
||||
credit = r['credit']
|
||||
res_init['credit'] = credit
|
||||
res_init['debit'] = debit
|
||||
res_init['type'] = 3
|
||||
res_init['ref'] = ''
|
||||
res_init['code'] = ''
|
||||
res_init['name'] = 'Initial Balance'
|
||||
res_init['balance'] = debit - credit
|
||||
res_init['enlitige'] = 0.0 # fix me
|
||||
res_init['account_id'] = r['account_id']
|
||||
final_init[r['account_id']] = res_init
|
||||
|
||||
# if self.initial_balance:
|
||||
# self.cr.execute(
|
||||
# "SELECT '1' AS type, '' AS ref, l.account_id AS account_id, '' AS account_name, '' AS code, '' AS name, sum(debit) AS debit, sum(credit) AS credit, " \
|
||||
# "CASE WHEN sum(debit) > sum(credit) " \
|
||||
# "THEN sum(debit) - sum(credit) " \
|
||||
# "ELSE 0 " \
|
||||
# "END AS sdebit, " \
|
||||
# "CASE WHEN sum(debit) < sum(credit) " \
|
||||
# "THEN sum(credit) - sum(debit) " \
|
||||
# "ELSE 0 " \
|
||||
# "END AS scredit, " \
|
||||
# "(SELECT sum(debit-credit) " \
|
||||
# "FROM account_move_line l " \
|
||||
# "WHERE partner_id = p.id " \
|
||||
# " AND " + self.init_query + " " \
|
||||
# "AND blocked = TRUE " \
|
||||
# ") AS enlitige " \
|
||||
# "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
|
||||
# "JOIN account_account ac ON (l.account_id = ac.id) " \
|
||||
# "WHERE ac.type IN %s " \
|
||||
# "AND " + self.init_query + "" \
|
||||
# "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \
|
||||
# "ORDER BY l.account_id, p.name",
|
||||
# (self.ACCOUNT_TYPE, ))
|
||||
# res1 = self.cr.dictfetchall()
|
||||
# final_init = {}
|
||||
# res_init = {}
|
||||
# debit = credit = 0
|
||||
# for r in res1:
|
||||
# if final_init.get(r['account_id'], False):
|
||||
# res_init = final_init[r['account_id']]
|
||||
# debit += final_init[r['account_id']]['debit']
|
||||
# credit += final_init[r['account_id']]['credit']
|
||||
# res_init['credit'] = credit
|
||||
# res_init['debit'] = debit
|
||||
# res_init['type'] = 3
|
||||
# res_init['ref'] = ''
|
||||
# res_init['code'] = ''
|
||||
# res_init['name'] = 'Initial Balance'
|
||||
# res_init['balance'] = debit - credit
|
||||
# res_init['enlitige'] = 0.0 # fix me
|
||||
# res_init['account_id'] = final_init[r['account_id']]['account_id']
|
||||
# else:
|
||||
# res_init = {}
|
||||
# debit = r['debit']
|
||||
# credit = r['credit']
|
||||
# res_init['credit'] = credit
|
||||
# res_init['debit'] = debit
|
||||
# res_init['type'] = 3
|
||||
# res_init['ref'] = ''
|
||||
# res_init['code'] = ''
|
||||
# res_init['name'] = 'Initial Balance'
|
||||
# res_init['balance'] = debit - credit
|
||||
# res_init['enlitige'] = 0.0 # fix me
|
||||
# res_init['account_id'] = r['account_id']
|
||||
# final_init[r['account_id']] = res_init
|
||||
|
||||
if self.display_partner == 'non-zero_balance':
|
||||
full_account = [r for r in res if r['sdebit'] > 0 or r['scredit'] > 0]
|
||||
else:
|
||||
full_account = [r for r in res]
|
||||
|
||||
|
||||
## We will now compute Total
|
||||
subtotal_row = self._add_subtotal(full_account)
|
||||
if not self.initial_balance:
|
||||
return subtotal_row
|
||||
|
||||
#If include initial balance is selected..
|
||||
subtotal = copy.deepcopy(subtotal_row)
|
||||
init_acnt = []
|
||||
for row in subtotal_row:
|
||||
if final_init and row.get('account_id', False) and not row['account_id'] in init_acnt and final_init.get(row['account_id'], False):
|
||||
subtotal.insert(subtotal.index(row), final_init[row['account_id']])
|
||||
init_acnt.append(row['account_id'])
|
||||
return subtotal
|
||||
# if not self.initial_balance:
|
||||
# return subtotal_row
|
||||
#
|
||||
# #If include initial balance is selected..
|
||||
# subtotal = copy.deepcopy(subtotal_row)
|
||||
# init_acnt = []
|
||||
# for row in subtotal_row:
|
||||
# if final_init and row.get('account_id', False) and not row['account_id'] in init_acnt and final_init.get(row['account_id'], False):
|
||||
# subtotal.insert(subtotal.index(row), final_init[row['account_id']])
|
||||
# init_acnt.append(row['account_id'])
|
||||
return subtotal_row
|
||||
|
||||
def _add_subtotal(self, cleanarray):
|
||||
i = 0
|
||||
@@ -354,14 +354,14 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
|
||||
"AND " + self.query + "" ,
|
||||
(tuple(self.account_ids), ))
|
||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||
if self.initial_balance:
|
||||
self.cr.execute(
|
||||
"SELECT sum(debit) " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN %s " \
|
||||
"AND " + self.init_query + "" ,
|
||||
(tuple(self.account_ids), ))
|
||||
temp_res += float(self.cr.fetchone()[0] or 0.0)
|
||||
# if self.initial_balance:
|
||||
# self.cr.execute(
|
||||
# "SELECT sum(debit) " \
|
||||
# "FROM account_move_line AS l " \
|
||||
# "WHERE l.account_id IN %s " \
|
||||
# "AND " + self.init_query + "" ,
|
||||
# (tuple(self.account_ids), ))
|
||||
# temp_res += float(self.cr.fetchone()[0] or 0.0)
|
||||
return temp_res
|
||||
|
||||
def _sum_credit(self):
|
||||
@@ -375,14 +375,14 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
|
||||
"AND " + self.query + "" ,
|
||||
(tuple(self.account_ids),))
|
||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||
if self.initial_balance:
|
||||
self.cr.execute(
|
||||
"SELECT sum(credit) " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN %s " \
|
||||
"AND " + self.init_query + "" ,
|
||||
(tuple(self.account_ids),))
|
||||
temp_res += float(self.cr.fetchone()[0] or 0.0)
|
||||
# if self.initial_balance:
|
||||
# self.cr.execute(
|
||||
# "SELECT sum(credit) " \
|
||||
# "FROM account_move_line AS l " \
|
||||
# "WHERE l.account_id IN %s " \
|
||||
# "AND " + self.init_query + "" ,
|
||||
# (tuple(self.account_ids),))
|
||||
# temp_res += float(self.cr.fetchone()[0] or 0.0)
|
||||
return temp_res
|
||||
|
||||
def _sum_litige(self):
|
||||
@@ -397,15 +397,15 @@ class partner_balance(report_sxw.rml_parse, common_report_header):
|
||||
"AND l.blocked=TRUE ",
|
||||
(tuple(self.account_ids), ))
|
||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||
if self.initial_balance:
|
||||
self.cr.execute(
|
||||
"SELECT sum(debit-credit) " \
|
||||
"FROM account_move_line AS l " \
|
||||
"WHERE l.account_id IN %s " \
|
||||
"AND l.blocked=TRUE "\
|
||||
"AND " + self.init_query + "" ,
|
||||
(tuple(self.account_ids), ))
|
||||
temp_res += float(self.cr.fetchone()[0] or 0.0)
|
||||
# if self.initial_balance:
|
||||
# self.cr.execute(
|
||||
# "SELECT sum(debit-credit) " \
|
||||
# "FROM account_move_line AS l " \
|
||||
# "WHERE l.account_id IN %s " \
|
||||
# "AND l.blocked=TRUE "\
|
||||
# "AND " + self.init_query + "" ,
|
||||
# (tuple(self.account_ids), ))
|
||||
# temp_res += float(self.cr.fetchone()[0] or 0.0)
|
||||
return temp_res
|
||||
|
||||
def _sum_sdebit(self):
|
||||
|
||||
@@ -198,3 +198,8 @@
|
||||
"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
|
||||
"access_product_category_analytic_accounting","product.category","product.model_product_category","analytic.group_analytic_accounting",1,0,0,0
|
||||
"access_product_template_analytic_accounting","product.template","product.model_product_template","analytic.group_analytic_accounting",1,0,0,0
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
@@ -29,16 +29,55 @@ class account_chart(osv.osv_memory):
|
||||
_name = "account.chart"
|
||||
_description = "Account chart"
|
||||
_columns = {
|
||||
'fiscalyear': fields.many2one('account.fiscalyear', \
|
||||
'fiscalyear': fields.many2one('account.fiscalyear', \
|
||||
'Fiscal year', \
|
||||
help = 'Keep empty for all open fiscal years'),
|
||||
'target_move': fields.selection([('all', 'All Entries'),
|
||||
'period_from': fields.many2one('account.period', 'Start period'),
|
||||
'period_to': fields.many2one('account.period', 'End period'),
|
||||
'target_move': fields.selection([('all', 'All Entries'),
|
||||
('posted', 'All Posted Entries')], 'Target Moves', required = True),
|
||||
}
|
||||
|
||||
def _get_fiscalyear(self, cr, uid, context=None):
|
||||
"""Return default Fiscalyear value"""
|
||||
return self.pool.get('account.fiscalyear').find(cr, uid)
|
||||
now = time.strftime('%Y-%m-%d')
|
||||
fiscalyears = self.pool.get('account.fiscalyear').search(cr, uid, [('date_start', '<', now), ('date_stop', '>', now)], limit=1 )
|
||||
return fiscalyears and fiscalyears[0] or False
|
||||
|
||||
def _build_periods(self, cr, uid, period_from, period_to):
|
||||
period_obj = self.pool.get('account.period')
|
||||
period_date_start = period_obj.read(cr, uid, period_from, ['date_start'])['date_start']
|
||||
period_date_stop = period_obj.read(cr, uid, period_to, ['date_stop'])['date_stop']
|
||||
if period_date_start > period_date_stop:
|
||||
raise osv.except_osv(_('Error'),_('Start period should be smaller then End period'))
|
||||
return period_obj.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop)])
|
||||
|
||||
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear_id=False, context=None):
|
||||
res = {}
|
||||
res['value'] = {'period_from': False, 'period_to': False}
|
||||
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
|
||||
ORDER BY p.date_start ASC
|
||||
LIMIT 1) AS period_start
|
||||
UNION
|
||||
SELECT * FROM (SELECT p.id
|
||||
FROM account_period p
|
||||
LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
|
||||
WHERE f.id = %s
|
||||
AND p.date_start < NOW()
|
||||
ORDER BY p.date_stop DESC
|
||||
LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
|
||||
periods = [i[0] for i in cr.fetchall()]
|
||||
if periods and len(periods) > 1:
|
||||
start_period = periods[0]
|
||||
end_period = periods[1]
|
||||
res['value'] = {'period_from': start_period, 'period_to': end_period}
|
||||
return res
|
||||
|
||||
def account_chart_open_window(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
@@ -56,7 +95,10 @@ class account_chart(osv.osv_memory):
|
||||
result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree')
|
||||
id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id']
|
||||
result = act_obj.read(cr, uid, [id], context=context)[0]
|
||||
result['context'] = str({'fiscalyear': data['fiscalyear'], \
|
||||
result['periods'] = []
|
||||
if data['period_from'] and data['period_to']:
|
||||
result['periods'] = self._build_periods(cr, uid, data['period_from'], data['period_to'])
|
||||
result['context'] = str({'fiscalyear': data['fiscalyear'], 'periods': result['periods'], \
|
||||
'state': data['target_move']})
|
||||
if data['fiscalyear']:
|
||||
result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']], context=context)[0]['code']
|
||||
|
||||
@@ -7,16 +7,18 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Account charts">
|
||||
<group colspan="4" >
|
||||
<field name="fiscalyear"/>
|
||||
<label align="0.7" colspan="6" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
|
||||
<group colspan="4">
|
||||
<field name="fiscalyear" on_change="onchange_fiscalyear(fiscalyear)"/>
|
||||
<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"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<separator string="" colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
<label string ="" colspan="2"/>
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel" />
|
||||
<button icon="terp-gtk-go-back-rtl" string="Open Charts" name="account_chart_open_window" type="object" />
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="terp-gtk-go-back-rtl" string="Open Charts" name="account_chart_open_window" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -21,15 +21,21 @@
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from osv import osv
|
||||
from osv import osv, fields
|
||||
|
||||
class account_balance_report(osv.osv_memory):
|
||||
_inherit = "account.common.account.report"
|
||||
_name = 'account.balance.report'
|
||||
_description = 'Account Balance Report'
|
||||
|
||||
_columns = {
|
||||
'target_move': fields.selection([('all', 'All Entries'),
|
||||
('posted', 'All Posted Entries')], 'Target Moves', required=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'journal_ids': [],
|
||||
'target_move': 'all'
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
@@ -45,6 +51,7 @@ class account_balance_report(osv.osv_memory):
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, query_line, context=None):
|
||||
data = self.pre_print_report(cr, uid, ids, data, query_line, context=context)
|
||||
data['form'].update(self.read(cr, uid, ids, ['target_move'])[0])
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'account.account.balance', 'datas': data}
|
||||
|
||||
account_balance_report()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="fiscalyear_id" position="after">
|
||||
<field name="display_account"/>
|
||||
<field name="target_move"/>
|
||||
<newline/>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
@@ -37,7 +37,7 @@ class account_report_general_ledger(osv.osv_memory):
|
||||
'landscape': True,
|
||||
'amount_currency': True,
|
||||
'sortby': 'sort_date',
|
||||
'initial_balance': True,
|
||||
'initial_balance': False,
|
||||
}
|
||||
|
||||
def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, context=None):
|
||||
|
||||
@@ -29,13 +29,13 @@ class account_partner_balance(osv.osv_memory):
|
||||
_name = 'account.partner.balance'
|
||||
_description = 'Print Account Partner Balance'
|
||||
_columns = {
|
||||
'initial_balance': fields.boolean('Include Initial Balances'
|
||||
,help='It adds initial balance row on report which display previous sum amount of debit/credit/balance'),
|
||||
# 'initial_balance': fields.boolean('Include Initial Balances'
|
||||
# ,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')
|
||||
}
|
||||
_defaults = {
|
||||
'initial_balance': True,
|
||||
# 'initial_balance': True,
|
||||
'display_partner': 'non-zero_balance'
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class account_partner_balance(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, ['initial_balance', 'display_partner'])[0])
|
||||
data['form'].update(self.read(cr, uid, ids, ['display_partner'])[0])
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.partner.balance',
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="fiscalyear_id" position="after">
|
||||
<field name="result_selection"/>
|
||||
<field name="initial_balance"/>
|
||||
<!-- <field name="initial_balance"/> -->
|
||||
<field name="display_partner"/>
|
||||
<newline/>
|
||||
</field>
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
"voucher_sequence.xml",
|
||||
"voucher_workflow.xml",
|
||||
"voucher_report.xml",
|
||||
"wizard/account_voucher_open_view.xml",
|
||||
"wizard/account_voucher_unreconcile_view.xml",
|
||||
"voucher_view.xml",
|
||||
"voucher_payment_receipt_view.xml",
|
||||
@@ -53,7 +52,6 @@
|
||||
"test/sales_receipt.yml",
|
||||
"test/sales_payment.yml",
|
||||
],
|
||||
|
||||
'certificate': '0037580727101',
|
||||
"active": False,
|
||||
"installable": True,
|
||||
|
||||
@@ -54,7 +54,7 @@ class report_voucher(report_sxw.rml_parse):
|
||||
voucher_line = self.pool.get('account.voucher.line').search(self.cr, self.uid, [('partner_id','=',move_ids.partner_id.id), ('voucher_id','=',voucher_id)])
|
||||
if voucher_line:
|
||||
voucher = self.pool.get('account.voucher.line').browse(self.cr, self.uid, voucher_line)[0]
|
||||
return voucher.ref
|
||||
return voucher.name
|
||||
else:
|
||||
return
|
||||
report_sxw.report_sxw(
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
<images/>
|
||||
</stylesheet>
|
||||
<story>
|
||||
<para style="P8">[[ repeatIn(objects,'voucher') ]]</para>
|
||||
<para style="P8">[[ repeatIn(objects,'voucher') ]]</para>ref
|
||||
<para style="terp_default_8">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
@@ -167,7 +167,7 @@
|
||||
<para style="terp_tblheader_Details">Journal:</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9">[[ voucher.type ]]</para>
|
||||
<para style="terp_default_9">[[ voucher.journal_id.name ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">Number:</para>
|
||||
@@ -252,7 +252,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_8_Italic">[[ move_ids.name ]] - [[ get_ref(voucher.id,move_ids) ]]</para>
|
||||
<para style="terp_default_8_Italic">[[ move_ids.name ]] - [[ voucher.reference or '' ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_9_50">
|
||||
|
||||
@@ -134,8 +134,7 @@ class account_voucher(osv.osv):
|
||||
],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'pre_line':fields.boolean('Previous Payments ?', required=False),
|
||||
'date_due': fields.date('Due Date'),
|
||||
# 'term_id':fields.many2one('account.payment.term', 'Term', required=False),
|
||||
'date_due': fields.date('Due Date', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
}
|
||||
_defaults = {
|
||||
'period_id': _get_period,
|
||||
@@ -166,6 +165,7 @@ class account_voucher(osv.osv):
|
||||
voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount})
|
||||
|
||||
if not voucher.tax_id:
|
||||
self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0})
|
||||
continue
|
||||
|
||||
tax = [tax_pool.browse(cr, uid, voucher.tax_id.id)]
|
||||
@@ -196,7 +196,6 @@ class account_voucher(osv.osv):
|
||||
self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
|
||||
return True
|
||||
|
||||
# TODO: review this code.
|
||||
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}):
|
||||
tax_pool = self.pool.get('account.tax')
|
||||
partner_pool = self.pool.get('res.partner')
|
||||
@@ -215,17 +214,26 @@ class account_voucher(osv.osv):
|
||||
|
||||
for line in line_ids:
|
||||
line_amount = 0.0
|
||||
if line[1]:
|
||||
line_amount = voucher_line_pool.browse(cr, uid, line[1]).untax_amount
|
||||
else:
|
||||
line_amount = line[2].get('amount')
|
||||
line_amount = line[2].get('amount')
|
||||
voucher_line_ids += [line[1]]
|
||||
voucher_total += line_amount
|
||||
|
||||
total = voucher_total
|
||||
total_tax = 0.0
|
||||
if tax_id:
|
||||
tax = [tax_pool.browse(cr, uid, tax_id)]
|
||||
if partner_id:
|
||||
partner = partner_pool.browse(cr, uid, partner_id) or False
|
||||
taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
|
||||
tax = tax_pool.browse(cr, uid, taxes)
|
||||
|
||||
if not tax[0].price_include:
|
||||
for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes'):
|
||||
total_tax += tax_line.get('amount')
|
||||
total += total_tax
|
||||
|
||||
res.update({
|
||||
'amount':total,
|
||||
'amount':total or voucher_total,
|
||||
'tax_amount':total_tax
|
||||
})
|
||||
return {
|
||||
@@ -246,6 +254,44 @@ class account_voucher(osv.osv):
|
||||
})
|
||||
return {'value':default}
|
||||
|
||||
def onchange_journal_voucher(self, cr, uid, ids, partner_id=False, journal_id=False, context={}):
|
||||
"""price
|
||||
Returns a dict that contains new values and context
|
||||
|
||||
@param partner_id: latest value from user input for field partner_id
|
||||
@param args: other arguments
|
||||
@param context: context arguments, like lang, time zone
|
||||
|
||||
@return: Returns a dict which contains new values, and context
|
||||
"""
|
||||
default = {
|
||||
'value':{},
|
||||
}
|
||||
|
||||
if not partner_id or not journal_id:
|
||||
return default
|
||||
|
||||
partner_pool = self.pool.get('res.partner')
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
|
||||
journal = journal_pool.browse(cr, uid, journal_id)
|
||||
partner = partner_pool.browse(cr, uid, partner_id)
|
||||
account_id = False
|
||||
tr_type = False
|
||||
if journal.type in ('sale','sale_refund'):
|
||||
account_id = partner.property_account_receivable.id
|
||||
tr_type = 'sale'
|
||||
elif journal.type in ('purchase', 'purchase_refund','expense'):
|
||||
account_id = partner.property_account_payable.id
|
||||
tr_type = 'purchase'
|
||||
else:
|
||||
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
||||
tr_type = 'receipt'
|
||||
|
||||
default['value']['account_id'] = account_id
|
||||
default['value']['type'] = tr_type
|
||||
return default
|
||||
|
||||
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}):
|
||||
"""price
|
||||
Returns a dict that contains new values and context
|
||||
@@ -311,17 +357,22 @@ class account_voucher(osv.osv):
|
||||
total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit)
|
||||
elif company_currency != currency_id and ttype == 'receipt':
|
||||
total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit)
|
||||
|
||||
|
||||
for line in moves:
|
||||
if line.credit and line.reconcile_partial_id:
|
||||
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
|
||||
continue
|
||||
if line.debit and line.reconcile_partial_id and ttype == 'payment':
|
||||
continue
|
||||
|
||||
total_credit += line.credit or 0.0
|
||||
total_debit += line.debit or 0.0
|
||||
|
||||
for line in moves:
|
||||
if line.credit and line.reconcile_partial_id:
|
||||
if line.credit and line.reconcile_partial_id and ttype == 'receipt':
|
||||
continue
|
||||
if line.debit and line.reconcile_partial_id and ttype == 'payment':
|
||||
continue
|
||||
|
||||
rs = {
|
||||
'name':line.move_id.name,
|
||||
'type': line.credit and 'dr' or 'cr',
|
||||
@@ -370,7 +421,7 @@ class account_voucher(osv.osv):
|
||||
}
|
||||
}
|
||||
|
||||
def onchange_journal(self, cr, uid, ids, journal_id):
|
||||
def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context={}):
|
||||
if not journal_id:
|
||||
return False
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
@@ -379,8 +430,10 @@ class account_voucher(osv.osv):
|
||||
tax_id = False
|
||||
if account_id and account_id.tax_ids:
|
||||
tax_id = account_id.tax_ids[0].id
|
||||
|
||||
return {'value':{'tax_id':tax_id}}
|
||||
|
||||
vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
|
||||
vals['value'].update({'tax_id':tax_id})
|
||||
return vals
|
||||
|
||||
def proforma_voucher(self, cr, uid, ids):
|
||||
self.action_move_line_create(cr, uid, ids)
|
||||
@@ -424,7 +477,7 @@ class account_voucher(osv.osv):
|
||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
|
||||
return super(account_voucher, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
# TODO
|
||||
# TODO: may be we can remove this method if not used anyware
|
||||
def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
|
||||
res = {}
|
||||
if not partner_id:
|
||||
@@ -496,7 +549,7 @@ class account_voucher(osv.osv):
|
||||
if credit < 0:
|
||||
debit = -credit
|
||||
credit = 0.0
|
||||
|
||||
|
||||
move_line = {
|
||||
'name':inv.name or '/',
|
||||
'debit':debit,
|
||||
@@ -510,7 +563,9 @@ class account_voucher(osv.osv):
|
||||
'date':inv.date,
|
||||
'date_maturity':inv.date_due
|
||||
}
|
||||
master_line = move_line_pool.create(cr, uid, move_line)
|
||||
|
||||
if (debit == 0.0 or credit == 0.0 or debit+credit > 0) and (debit > 0.0 or credit > 0.0):
|
||||
master_line = move_line_pool.create(cr, uid, move_line)
|
||||
|
||||
rec_list_ids = []
|
||||
line_total = debit - credit
|
||||
@@ -524,6 +579,7 @@ class account_voucher(osv.osv):
|
||||
if not line.amount:
|
||||
continue
|
||||
amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, line.amount)
|
||||
|
||||
move_line = {
|
||||
'journal_id':inv.journal_id.id,
|
||||
'period_id':inv.period_id.id,
|
||||
@@ -532,6 +588,7 @@ class account_voucher(osv.osv):
|
||||
'move_id':move_id,
|
||||
'partner_id':inv.partner_id.id,
|
||||
'currency_id':inv.currency_id.id,
|
||||
'amount_currency':line.amount,
|
||||
'analytic_account_id':line.account_analytic_id and line.account_analytic_id.id or False,
|
||||
'quantity':1,
|
||||
'credit':0.0,
|
||||
@@ -552,11 +609,10 @@ class account_voucher(osv.osv):
|
||||
line_total -= amount
|
||||
move_line['credit'] = amount
|
||||
|
||||
if inv.tax_id:
|
||||
if inv.tax_id and inv.type in ('sale', 'purchase'):
|
||||
move_line.update({
|
||||
'account_tax_id':inv.tax_id.id,
|
||||
})
|
||||
|
||||
master_line = move_line_pool.create(cr, uid, move_line)
|
||||
if line.move_line_id.id:
|
||||
rec_ids = [master_line, line.move_line_id.id]
|
||||
@@ -574,7 +630,8 @@ class account_voucher(osv.osv):
|
||||
'debit':diff<0 and -diff or 0.0,
|
||||
}
|
||||
account_id = False
|
||||
if inv.journal_id.type in ('sale','sale_refund', 'cash','bank'):
|
||||
if inv.type in ('sale', 'receipt'):
|
||||
# if inv.journal_id.type in ('sale','sale_refund', 'cash', 'bank'):
|
||||
account_id = inv.partner_id.property_account_receivable.id
|
||||
else:
|
||||
account_id = inv.partner_id.property_account_payable.id
|
||||
@@ -585,7 +642,7 @@ class account_voucher(osv.osv):
|
||||
'move_id': move_id,
|
||||
'state':'posted'
|
||||
})
|
||||
move_pool.post(cr, uid, [move_id], context={})
|
||||
#move_pool.post(cr, uid, [move_id], context={})
|
||||
for rec_ids in rec_list_ids:
|
||||
if len(rec_ids) >= 2:
|
||||
move_line_pool.reconcile_partial(cr, uid, rec_ids)
|
||||
@@ -604,48 +661,33 @@ class account_voucher(osv.osv):
|
||||
default['date'] = time.strftime('%Y-%m-%d')
|
||||
return super(account_voucher, self).copy(cr, uid, id, default, context)
|
||||
|
||||
# TODO
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
"""
|
||||
Returns views and fields for current model where view will depend on {view_type}.
|
||||
@param view_id: list of fields, which required to read signatures
|
||||
@param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
|
||||
@param context: context arguments, like lang, time zone
|
||||
@param toolbar: contains a list of reports, wizards, and links related to current model
|
||||
|
||||
@return: Returns a dict that contains definition for fields, views, and toolbars
|
||||
"""
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
voucher_type = {
|
||||
'sale':'view_sale_receipt_form',
|
||||
'purchase':'view_purchase_receipt_form',
|
||||
'payment':'view_vendor_payment_form',
|
||||
'receipt':'view_vendor_receipt_form'
|
||||
}
|
||||
if view_type == 'form':
|
||||
tview = voucher_type.get(context.get('type'))
|
||||
tview = tview or 'view_voucher_form'
|
||||
result = data_pool._get_id(cr, uid, 'account_voucher', tview)
|
||||
view_id = data_pool.browse(cr, uid, result, context=context).res_id
|
||||
|
||||
res = super(account_voucher, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
|
||||
#Restrict the list of journal view in search view
|
||||
if view_type == 'search':
|
||||
type_search = {
|
||||
'bank':[('type','in',['bank','cash'])],
|
||||
'cash':[('type','in',['bank','cash'])],
|
||||
'sale':[('type','in',['sale','purchase_refund'])],
|
||||
'purchase':[('type','in',['purchase','sale_refund'])],
|
||||
'expense':[('type','in',['purchase'])],
|
||||
'sale_refund':[('type','in',['sale','purchase_refund'])],
|
||||
'purchase_refund':[('type','in',['purchase','sale_refund'])]
|
||||
}
|
||||
domain = type_search.get(context.get('journal_type'))
|
||||
journal_list = journal_pool.name_search(cr, uid, '', domain)
|
||||
res['fields']['journal_id']['selection'] = journal_list
|
||||
return res
|
||||
# # TODO: remove this
|
||||
# def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
# """
|
||||
# Returns views and fields for current model where view will depend on {view_type}.
|
||||
# @param view_id: list of fields, which required to read signatures
|
||||
# @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
|
||||
# @param context: context arguments, like lang, time zone
|
||||
# @param toolbar: contains a list of reports, wizards, and links related to current model
|
||||
#
|
||||
# @return: Returns a dict that contains definition for fields, views, and toolbars
|
||||
# """
|
||||
# data_pool = self.pool.get('ir.model.data')
|
||||
# journal_pool = self.pool.get('account.journal')
|
||||
# voucher_type = {
|
||||
# 'sale':'view_sale_receipt_form',
|
||||
# 'purchase':'view_purchase_receipt_form',
|
||||
# 'payment':'view_vendor_payment_form',
|
||||
# 'receipt':'view_vendor_receipt_form'
|
||||
# }
|
||||
# if view_type == 'form':
|
||||
# tview = voucher_type.get(context.get('type'))
|
||||
# tview = tview or 'view_voucher_form'
|
||||
# result = data_pool._get_id(cr, uid, 'account_voucher', tview)
|
||||
# view_id = data_pool.browse(cr, uid, result, context=context).res_id
|
||||
#
|
||||
# res = super(account_voucher, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
# return res
|
||||
|
||||
account_voucher()
|
||||
|
||||
@@ -733,9 +775,10 @@ class account_voucher_line(osv.osv):
|
||||
journal = journal_pool.browse(cr, user, journal_id)
|
||||
account_id = False
|
||||
ttype = 'cr'
|
||||
if journal.type in ('sale', 'purchase_refund'):
|
||||
if journal.type in ('sale', 'sale_refund'):
|
||||
account_id = journal.default_credit_account_id and journal.default_credit_account_id.id or False
|
||||
elif journal.type in ('purchase', 'expense', 'sale_refund'):
|
||||
ttype = 'cr'
|
||||
elif journal.type in ('purchase', 'expense', 'purchase_refund'):
|
||||
account_id = journal.default_debit_account_id and journal.default_debit_account_id.id or False
|
||||
ttype = 'dr'
|
||||
elif partner_id:
|
||||
|
||||
@@ -1,6 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_voucher_filter_customer_pay" model="ir.ui.view">
|
||||
<field name="name">account.voucher.customer.pay.select</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Vouchers">
|
||||
<group col='8' colspan='4'>
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date"/>
|
||||
<field name="number"/>
|
||||
<field name="partner_id" string="Customer"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
<field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('bank','cash'))]"/>
|
||||
<field name="period_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference"/>
|
||||
<field name="name"/>
|
||||
<field name="narration"/>
|
||||
<field name="amount"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="10">
|
||||
<filter string="Customer" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_voucher_filter_vendor_pay" model="ir.ui.view">
|
||||
<field name="name">account.voucher.purchase.pay.select</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Vouchers">
|
||||
<group col='8' colspan='4'>
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date"/>
|
||||
<field name="number"/>
|
||||
<field name="partner_id" string="Supplier"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
<field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('bank','cash'))]"/>
|
||||
<field name="period_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference"/>
|
||||
<field name="name"/>
|
||||
<field name="narration"/>
|
||||
<field name="amount"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="10">
|
||||
<filter string="Supplier" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_vendor_payment_form">
|
||||
<field name="name">account.voucher.payment.form</field>
|
||||
<field name="model">account.voucher</field>
|
||||
@@ -26,7 +106,7 @@
|
||||
<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="Payment Lines" editable="bottom">
|
||||
<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)]"
|
||||
@@ -85,13 +165,27 @@
|
||||
|
||||
<record id="action_vendor_payment" model="ir.actions.act_window">
|
||||
<field name="name">Vendor Payment</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment')]</field>
|
||||
<field name="context">{'journal_type':'bank', 'type':'payment'}</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'type':'payment'}</field>
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="search_view_id" ref="view_voucher_filter_vendor_pay"/>
|
||||
<field name="target">current</field>
|
||||
</record>
|
||||
<record id="action_vendor_payment_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_vendor_payment"/>
|
||||
</record>
|
||||
<record id="action_vendor_payment_form" model="ir.actions.act_window.view">
|
||||
<field eval="2" name="sequence"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_vendor_payment_form"/>
|
||||
<field name="act_window_id" ref="action_vendor_payment"/>
|
||||
</record>
|
||||
|
||||
|
||||
<menuitem action="action_vendor_payment" icon="STOCK_JUSTIFY_FILL" sequence="12"
|
||||
id="menu_action_vendor_payment" parent="account.menu_finance_payables"/>
|
||||
|
||||
@@ -177,13 +271,26 @@
|
||||
|
||||
<record id="action_vendor_receipt" model="ir.actions.act_window">
|
||||
<field name="name">Sales Payment</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]</field>
|
||||
<field name="context">{'journal_type':'bank', 'type':'receipt'}</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'type':'receipt'}</field>
|
||||
<field name="search_view_id" ref="view_voucher_filter_customer_pay"/>
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="target">current</field>
|
||||
</record>
|
||||
<record id="action_vendor_receipt_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_vendor_receipt"/>
|
||||
</record>
|
||||
<record id="action_vendor_receipt_form" model="ir.actions.act_window.view">
|
||||
<field eval="2" name="sequence"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_vendor_receipt_form"/>
|
||||
<field name="act_window_id" ref="action_vendor_receipt"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_vendor_receipt" icon="STOCK_JUSTIFY_FILL" sequence="12"
|
||||
id="menu_action_vendor_receipt" parent="account.menu_finance_receivables"/>
|
||||
</data>
|
||||
|
||||
@@ -1,16 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_voucher_filter_vendor" model="ir.ui.view">
|
||||
<field name="name">account.voucher.purchase.select</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Vouchers">
|
||||
<group col='8' colspan='4'>
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date"/>
|
||||
<field name="number"/>
|
||||
<field name="partner_id" string="Supplier"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
<field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('purchase','purchase_refund'))]"/>
|
||||
<field name="period_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference"/>
|
||||
<field name="name"/>
|
||||
<field name="narration"/>
|
||||
<field name="amount"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="10">
|
||||
<filter string="Supplier" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_voucher_filter_sale" model="ir.ui.view">
|
||||
<field name="name">account.voucher.sale.select</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Vouchers">
|
||||
<group col='8' colspan='4'>
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date"/>
|
||||
<field name="number"/>
|
||||
<field name="partner_id" string="Customer"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
<field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('sale','sale_refund'))]"/>
|
||||
<field name="period_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference"/>
|
||||
<field name="name"/>
|
||||
<field name="narration"/>
|
||||
<field name="amount"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="10">
|
||||
<filter string="Customer" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="act_pay_voucher" model="ir.actions.act_window">
|
||||
<field name="name">Sales Payment</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt'), ('partner_id','=',partner_id)]</field>
|
||||
<field name="context">{'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id}</field>
|
||||
<field name="context">{'type':'receipt', 'partner_id': partner_id, 'referance':referance}</field>
|
||||
<field name="view_id" ref="view_vendor_receipt_form"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_sale_receipt_form">
|
||||
<field name="name">account.voucher.sale.form</field>
|
||||
<field name="model">account.voucher</field>
|
||||
@@ -19,7 +99,7 @@
|
||||
<form string="Sales Receipt">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id)" string="Customer"/>
|
||||
<field name="journal_id" domain="[('type','in',['sale','purchase_refund'])]" widget="selection" on_change="onchange_journal(journal_id)"/>
|
||||
<field name="journal_id" domain="[('type','in',['sale','sale_refund'])]" widget="selection" on_change="onchange_journal(journal_id, line_cr_ids, tax_id, partner_id)"/>
|
||||
<field name="number"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="date" on_change="onchange_date(date)"/>
|
||||
@@ -50,10 +130,11 @@
|
||||
<field name="reference"
|
||||
attrs="{'invisible':[('pay_now','!=','pay_now')]}"
|
||||
/>
|
||||
<field name="date_due" attrs="{'invisible':[('pay_now','=','pay_now')]}"/>
|
||||
</group>
|
||||
<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" on_change="onchange_price(line_ids, tax_id, partner_id)" nolabel="1"/><button type="object" icon="terp-stock_format-scientific" name="compute_tax" string="Compute Tax" attrs="{'invisible': [('state','!=','draft')]}"/>
|
||||
<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 colspan="1" string=""/><field name="amount" string="Total"/>
|
||||
</group>
|
||||
</group>
|
||||
@@ -73,7 +154,7 @@
|
||||
<button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/>
|
||||
<button name="cancel_voucher" string="Cancel" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to confirm this record ?"/>
|
||||
<button name="proforma_voucher" string="Post" states="draft" icon="terp-camera_test"/>
|
||||
<button icon="terp-dolar_ok!" name="%(act_pay_voucher)d" context="{'title':'Sales Payment', 'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id}" type="action" string="Pay" attrs="{'invisible':[('pay_now','!=','pay_now'),('state','!=','posted')]}"/>
|
||||
<button icon="terp-dolar_ok!" name="%(act_pay_voucher)d" context="{'title':'Sales Payment', 'type':'receipt', 'partner_id': partner_id}" type="action" string="Pay" attrs="{'invisible':[('pay_now','!=','pay_now'),('state','!=','posted')]}"/>
|
||||
<button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
|
||||
</group>
|
||||
</form>
|
||||
@@ -83,23 +164,38 @@
|
||||
<!-- Sales Voucher -->
|
||||
<record id="action_sale_receipt" model="ir.actions.act_window">
|
||||
<field name="name">Sales Receipt</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type','in',['sale','purchase_refund']), ('type','=','sale')]</field>
|
||||
<field name="context">{'journal_type':'sale', 'type':'sale'}</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="target">new</field>
|
||||
<field name="domain">[('journal_id.type','in',['sale','sale_refund']), ('type','=','sale')]</field>
|
||||
<field name="context">{'type':'sale'}</field>
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="search_view_id" ref="view_voucher_filter_sale"/>
|
||||
<field name="target">current</field>
|
||||
</record>
|
||||
<record id="action_sale_receipt_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_sale_receipt"/>
|
||||
</record>
|
||||
<record id="action_sale_receipt_form" model="ir.actions.act_window.view">
|
||||
<field eval="2" name="sequence"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_sale_receipt_form"/>
|
||||
<field name="act_window_id" ref="action_sale_receipt"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_action_sale_receipt" icon="STOCK_JUSTIFY_FILL"
|
||||
action="action_sale_receipt" parent="account.menu_finance_receivables" sequence="10"/>
|
||||
|
||||
action="action_sale_receipt"
|
||||
parent="account.menu_finance_receivables"
|
||||
sequence="10"/>
|
||||
|
||||
<!-- Purchase Vouchers -->
|
||||
<record id="act_pay_bills" model="ir.actions.act_window">
|
||||
<field name="name">Bill Payment</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment'), ('partner_id','=',partner_id)]</field>
|
||||
<field name="context">{'journal_type':'bank', 'type':'payment', 'partner_id': partner_id}</field>
|
||||
<field name="context">{'type':'payment', 'partner_id': partner_id, 'referance':reference}</field>
|
||||
<field name="view_id" ref="view_vendor_payment_form"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
@@ -111,10 +207,10 @@
|
||||
<form string="Vendor Bills">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" string="Vendor" on_change="onchange_partner_id(partner_id, journal_id, amount)"/>
|
||||
<field name="journal_id" domain="[('type','in',['purchase','sale_refund'])]" widget="selection" select="1" on_change="onchange_journal(journal_id)"/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="journal_id" domain="[('type','in',['purchase','purchase_refund'])]" widget="selection" select="1" on_change="onchange_journal(journal_id, line_dr_ids, tax_id, partner_id)"/>
|
||||
<field name="number"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="account_id" domain="[('type','=','other')]" invisible="True"/>
|
||||
<field name="type" invisible="True"/>
|
||||
</group>
|
||||
@@ -137,11 +233,10 @@
|
||||
<separator string="Payment Terms" colspan="2"/>
|
||||
<field name="date" string="Bill Date" select="1" on_change="onchange_date(date)"/>
|
||||
<field name="date_due"/>
|
||||
<field name="amount" required="0" string="Amount Due"/>
|
||||
</group>
|
||||
<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" on_change="onchange_price(line_ids, tax_id, partner_id)" nolabel="1"/><button type="object" icon="terp-stock_format-scientific" name="compute_tax" string="Compute Tax" attrs="{'invisible': [('state','!=','draft')]}"/>
|
||||
<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 colspan="1" string=""/><field name="amount" string="Total"/>
|
||||
</group>
|
||||
</group>
|
||||
@@ -161,7 +256,7 @@
|
||||
<button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/>
|
||||
<button name="cancel_voucher" string="Cancel" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to confirm this record ?"/>
|
||||
<button name="proforma_voucher" string="Post" states="draft" icon="terp-camera_test"/>
|
||||
<button icon="terp-dolar_ok!" name="%(act_pay_bills)d" context="{'title':'Bill Payment', 'journal_type':'bank', 'type':'payment', 'partner_id': partner_id}" type="action" string="Pay Bill" attrs="{'invisible':[('state','!=','posted')]}"/>
|
||||
<button icon="terp-dolar_ok!" name="%(act_pay_bills)d" context="{'title':'Bill Payment', 'type':'payment', 'partner_id': partner_id}" type="action" string="Pay Bill" attrs="{'invisible':[('state','!=','posted')]}"/>
|
||||
<button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
|
||||
</group>
|
||||
</form>
|
||||
@@ -169,13 +264,26 @@
|
||||
</record>
|
||||
<record id="action_purchase_receipt" model="ir.actions.act_window">
|
||||
<field name="name">Vendor Bills</field>
|
||||
<field name="res_model">account.voucher.open</field>
|
||||
<field name="res_model">account.voucher</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('journal_id.type','in',['purchase','sale_refund']), ('type','=','purchase')]</field>
|
||||
<field name="context">{'journal_type':'purchase', 'type':'purchase'}</field>
|
||||
<field name="view_id" ref="account_open_vouchers_view"/>
|
||||
<field name="target">new</field>
|
||||
<field name="domain">[('journal_id.type','in',['purchase','purchase_refund']), ('type','=','purchase')]</field>
|
||||
<field name="context">{'type':'purchase'}</field>
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="search_view_id" eval="view_voucher_filter_vendor"/>
|
||||
<field name="target">current</field>
|
||||
</record>
|
||||
<record id="action_purchase_receipt_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_purchase_receipt"/>
|
||||
</record>
|
||||
<record id="action_purchase_receipt_form" model="ir.actions.act_window.view">
|
||||
<field eval="2" name="sequence"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_purchase_receipt_form"/>
|
||||
<field name="act_window_id" ref="action_purchase_receipt"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_action_purchase_receipt" icon="STOCK_JUSTIFY_FILL"
|
||||
action="action_purchase_receipt" parent="account.menu_finance_payables" sequence="10"/>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_voucher_form">
|
||||
<field name="name">account.voucher.form</field>
|
||||
<field name="model">account.voucher</field>
|
||||
@@ -28,39 +28,57 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Accounting Voucher">
|
||||
<group col="6" colspan="4">
|
||||
<field name="partner_id" required="1" on_change="onchange_journal_voucher(partner_id, journal_id)"/>
|
||||
<field name="journal_id" widget="selection" select="1" on_change="onchange_journal_voucher(partner_id, journal_id)"/>
|
||||
<field name="type" required="1"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id)"/>
|
||||
<field name="type" on_change="onchange_partner_id(partner_id, journal_id)"/>
|
||||
<field name="journal_id" widget="selection" select="1" on_change="onchange_partner_id(partner_id, journal_id)"/>
|
||||
<field name="account_id" widget="selection" invisible="True"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Voucher Entry">
|
||||
<field name="line_ids" on_change="onchange_price(line_ids, False, partner_id)" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180">
|
||||
<tree string="Voucher Lines" editable="top">
|
||||
<field name="line_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180">
|
||||
<tree string="Voucher Items" editable="bottom">
|
||||
<field name="account_id"/>
|
||||
<field name="name"/>
|
||||
<field name="amount"/>
|
||||
<field name="amount" sum="Total Amount"/>
|
||||
<field name="type"/>
|
||||
<field name="account_analytic_id" domain="[('parent_id','!=',False)]"/>
|
||||
<field name="account_analytic_id" groups="base.group_extended"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
<!--
|
||||
<field name="line_dr_ids" attrs="{'invisible':[('type','in',['sale', 'receipt', False])]}" on_change="onchange_price(line_dr_ids, False, partner_id)" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="180">
|
||||
<tree string="Purchase and Payments" editable="top">
|
||||
<field name="account_id"/>
|
||||
<field name="name"/>
|
||||
<field name="amount" sum="Total Amount"/>
|
||||
<field name="type" groups="base.group_extended"/>
|
||||
<field name="account_analytic_id" domain="[('parent_id','!=',False)]" groups="base.group_extended"/>
|
||||
</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="amount" string="Total"/>
|
||||
<field name="number"/>
|
||||
<field name="date" select="1" on_change="onchange_date(date)"/>
|
||||
<field name="currency_id" select="1" attrs="{'readonly':[('type','in',['sale', 'purchase'])]}"/>
|
||||
<group col="2" colspan="1" >
|
||||
<separator string="Other Information" colspan="2"/>
|
||||
<field name="number"/>
|
||||
<field name="date" on_change="onchange_date(date)"/>
|
||||
<field name="currency_id" attrs="{'readonly':[('type','in',['sale', 'purchase'])]}"/>
|
||||
</group>
|
||||
<group col="4" colspan="1" attrs="{'invisible':[('type','in',['payment', 'receipt', False])]}">
|
||||
<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 colspan="1" string=""/><field name="amount" string="Total"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Journal Items" groups="base.group_extended" attrs="{'invisible': [('state','!=','posted')]}">
|
||||
<group col="6" colspan="4">
|
||||
<field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/>
|
||||
<field name="company_id" widget="selection" groups="base.group_multi_company"/>
|
||||
<field name="period_id"/>
|
||||
<field name="audit"/>
|
||||
</group>
|
||||
@@ -73,7 +91,7 @@
|
||||
<button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/>
|
||||
<button name="proforma_voucher" string="Post" states="draft" icon="terp-camera_test"/>
|
||||
<button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
|
||||
<button name="%(action_view_account_voucher_unreconcile)d" string="Cancel" type="action" states="posted" icon="terp-stock_effects-object-colorize"/>
|
||||
<button name="cancel_voucher" string="Cancel" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to unreconcile this record ?"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
@@ -83,48 +101,7 @@
|
||||
<field name="name">account.voucher.select</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Vouchers">
|
||||
<group col='8' colspan='4'>
|
||||
<filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
|
||||
<filter icon="terp-check" string="Proforma" domain="[('state','=','proforma')]" help="Proforma Vouchers"/>
|
||||
<filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<filter icon="gtk-cancel" string="Cancel" domain="[('state','=','cancel')]" help="Cancel Vouchers" groups="base.group_extended"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="number" select='1'/>
|
||||
<field name="account_id" select="1"/>
|
||||
<field name="partner_id" select='1'/>
|
||||
<field name="date" select='1'/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
<field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" />
|
||||
<field name="period_id" context="{'period_id': self}" groups="base.group_extended"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." col='8' colspan='4'>
|
||||
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id'}"/>
|
||||
<filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type', 'set_visible':True}"/>
|
||||
<filter string="States" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="name" select='1'/>
|
||||
<field name="narration" select="1"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_voucher_filter_new" model="ir.ui.view">
|
||||
<field name="name">account.voucher.select</field>
|
||||
<field name="model">account.voucher</field>
|
||||
<field name="type">search</field>
|
||||
<field name="priority">1</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Vouchers">
|
||||
<group col='8' colspan='4'>
|
||||
@@ -133,9 +110,9 @@
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-stock_effects-object-colorize" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date" select='1'/>
|
||||
<field name="number" select='1'/>
|
||||
<field name="partner_id" select='1'/>
|
||||
<field name="date"/>
|
||||
<field name="number"/>
|
||||
<field name="partner_id"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col='8' colspan='4'>
|
||||
@@ -143,18 +120,19 @@
|
||||
<field name="period_id" groups="base.group_extended"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="12" col="10">
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference"/>
|
||||
<field name="name"/>
|
||||
<field name="narration"/>
|
||||
<field name="amount"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="10">
|
||||
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
|
||||
<filter string="States" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." col='8' colspan='4'>
|
||||
<field name="reference" select="1"/>
|
||||
<field name="name" select='1'/>
|
||||
<field name="narration" select="1"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
@@ -199,7 +177,7 @@
|
||||
<field name="view_id" eval="view_voucher_tree"/>
|
||||
<field name="domain">[('state','=','posted')]</field>
|
||||
<field name="context">{'state':'posted'}</field>
|
||||
<field name="search_view_id" ref="view_voucher_filter_new"/>
|
||||
<field name="search_view_id" ref="view_voucher_filter"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -19,5 +19,4 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_voucher_open
|
||||
import account_voucher_unreconcile
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
# -*- 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, osv
|
||||
from tools.translate import _
|
||||
import tools
|
||||
|
||||
class account_voucher_open(osv.osv_memory):
|
||||
_name = "account.voucher.open"
|
||||
_description = "Account Voucher"
|
||||
|
||||
def _get_period(self, cr, uid, context={}):
|
||||
"""
|
||||
Return default account period value
|
||||
"""
|
||||
ids = self.pool.get('account.period').find(cr, uid, context=context)
|
||||
period_id = False
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
return period_id
|
||||
|
||||
def _get_journal(self, cr, uid, context={}):
|
||||
"""
|
||||
Return journal based on the journal type
|
||||
"""
|
||||
journal_id = False
|
||||
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
if context.get('journal_type', False):
|
||||
jids = journal_pool.search(cr, uid, [('type','=', context.get('journal_type'))])
|
||||
journal_id = jids[0]
|
||||
return journal_id
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
"""
|
||||
Returns views and fields for current model where view will depend on {view_type}.
|
||||
@param cr: A database cursor
|
||||
@param user: ID of the user currently logged in
|
||||
@param view_id: list of fields, which required to read signatures
|
||||
@param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx)
|
||||
@param context: context arguments, like lang, time zone
|
||||
@param toolbar: contains a list of reports, wizards, and links related to current model
|
||||
|
||||
@return: Returns a dict that contains definition for fields, views, and toolbars
|
||||
"""
|
||||
res = super(account_voucher_open, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
|
||||
|
||||
if not view_id:
|
||||
return res
|
||||
|
||||
period_pool = self.pool.get('account.period')
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
|
||||
journal_id = self._get_journal(cr, uid, context)
|
||||
period_id = self._get_period(cr, uid, context)
|
||||
|
||||
journal = False
|
||||
if journal_id:
|
||||
journal = journal_pool.read(cr, uid, [journal_id], ['name'])[0]['name']
|
||||
else:
|
||||
journal = "All"
|
||||
|
||||
period = False
|
||||
if period_id:
|
||||
period = period_pool.browse(cr, uid, [period_id], ['name'])[0]['name']
|
||||
|
||||
menu = self.pool.get('ir.ui.menu').browse(cr, uid, context.get('active_id'))
|
||||
name = menu.name
|
||||
|
||||
view = """<?xml version="1.0" encoding="utf-8"?>
|
||||
<form string="Standard entries">
|
||||
<separator string="Open %s !" colspan="4"/>
|
||||
<group colspan="4" >
|
||||
<label width="300" string="Journal : %s"/>
|
||||
<newline/>
|
||||
<label width="300" string="Period : %s"/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<label string ="" colspan="2"/>
|
||||
<button icon="terp-gtk-go-back-rtl" string="Ok" name="action_open_window" type="object"/>
|
||||
</group>
|
||||
</form>""" % (str(name), str(journal), str(period))
|
||||
|
||||
res.update({
|
||||
'arch':view
|
||||
})
|
||||
return res
|
||||
|
||||
def action_open_window(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
This function Open action move line window on given period and Journal/Payment Mode
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: account move journal’s ID or list of IDs
|
||||
@return: dictionary of Open action move line window on given period and Journal/Payment Mode
|
||||
"""
|
||||
|
||||
period_pool = self.pool.get('account.journal.period')
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
journal_pool = self.pool.get('account.journal')
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
journal_id = self._get_journal(cr, uid, context)
|
||||
period_id = self._get_period(cr, uid, context)
|
||||
|
||||
menu = self.pool.get('ir.ui.menu').browse(cr, uid, context.get('active_id'))
|
||||
name = context.get('title', menu.name)
|
||||
|
||||
result = data_pool._get_id(cr, uid, 'account_voucher', 'view_voucher_filter_new')
|
||||
res_id = data_pool.browse(cr, uid, result, context=context).res_id
|
||||
|
||||
res = {
|
||||
'domain':menu.action.domain,
|
||||
'name': name,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,graph,form',
|
||||
'res_model': 'account.voucher',
|
||||
'view_id': False,
|
||||
'context': "{'search_default_journal_id':%d, 'search_default_period_id':%d, 'partner_id':%s}" % (journal_id, period_id, context.get('partner_id',False)),
|
||||
'type': 'ir.actions.act_window',
|
||||
'search_view_id': res_id
|
||||
}
|
||||
return res
|
||||
|
||||
account_voucher_open()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_open_vouchers_view" model="ir.ui.view">
|
||||
<field name="name">Open Vouchers</field>
|
||||
<field name="model">account.voucher.open</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Open Vouchers">
|
||||
<separator string="Open Vouchers !" colspan="4"/>
|
||||
<group colspan="4" >
|
||||
<label width="300" string="Journal :"/>
|
||||
<newline/>
|
||||
<label width="300" string="Period :"/>
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
<label string ="" colspan="2"/>
|
||||
<button icon="terp-gtk-go-back-rtl" string="Ok" name="action_open_window" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -70,7 +70,7 @@ class account_analytic_account(osv.osv):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date', False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
|
||||
r = dict(cr.fetchall())
|
||||
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context)
|
||||
|
||||
@@ -90,7 +90,7 @@ class account_analytic_account(osv.osv):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),))
|
||||
r = dict(cr.fetchall())
|
||||
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context=context)
|
||||
|
||||
@@ -111,11 +111,10 @@ class account_analytic_account(osv.osv):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),))
|
||||
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
|
||||
return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context)
|
||||
|
||||
def _quantity_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
@@ -182,10 +181,10 @@ class account_analytic_account(osv.osv):
|
||||
'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
|
||||
'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
|
||||
'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'),
|
||||
'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance',store=True),
|
||||
'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit',store=True),
|
||||
'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit',store=True),
|
||||
'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity',store=True),
|
||||
'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'),
|
||||
'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit'),
|
||||
'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit'),
|
||||
'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'),
|
||||
'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'),
|
||||
'partner_id' : fields.many2one('res.partner', 'Associated Partner'),
|
||||
'contact_id' : fields.many2one('res.partner.address', 'Contact'),
|
||||
@@ -216,7 +215,7 @@ class account_analytic_account(osv.osv):
|
||||
'user_id' : lambda self, cr, uid, ctx : uid,
|
||||
'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False),
|
||||
'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False),
|
||||
'date_start': time.strftime('%Y-%m-%d')
|
||||
'date_start': time.strftime('%Y-%m-%d')
|
||||
}
|
||||
|
||||
def check_recursion(self, cr, uid, ids, parent=None):
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_account_analytic_line_analytic_accounting","account.analytic.line","analytic.model_account_analytic_line","analytic.group_analytic_accounting",1,1,1,1
|
||||
"access_account_analytic_account_analytic_accounting","account.analytic.account","analytic.model_account_analytic_account","analytic.group_analytic_accounting",1,1,1,1
|
||||
"access_account_analytic_journal_analytic_accounting","account.analytic.journal","account.model_account_analytic_journal","analytic.group_analytic_accounting",1,1,1,1
|
||||
"access_account_account_analytic_accounting","account.account","account.model_account_account","analytic.group_analytic_accounting",1,0,0,0
|
||||
"access_product_template_analytic_accounting","product.template","product.model_product_template","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
|
||||
"access_product_category_analytic_accounting","product.category","product.model_product_category","analytic.group_analytic_accounting",1,0,0,0
|
||||
|
||||
|
||||
|
@@ -27,6 +27,8 @@ from tools.translate import _
|
||||
from osv import fields, osv
|
||||
from tools import email_send as email
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
class project_task_type(osv.osv):
|
||||
_name = 'project.task.type'
|
||||
_description = 'Task Stage'
|
||||
@@ -395,7 +397,7 @@ class task(osv.osv):
|
||||
if task['date_start'] > task['date_end']:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _is_template(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
for task in self.browse(cr, uid, ids, context=context):
|
||||
@@ -451,9 +453,34 @@ class task(osv.osv):
|
||||
}
|
||||
|
||||
_order = "sequence, priority, date_start, id"
|
||||
|
||||
def _check_recursion(self, cr, uid, ids):
|
||||
obj_task = self.browse(cr, uid, ids[0])
|
||||
parent_ids = [x.id for x in obj_task.parent_ids]
|
||||
children_ids = [x.id for x in obj_task.child_ids]
|
||||
|
||||
if (obj_task.id in children_ids) or (obj_task.id in parent_ids):
|
||||
return False
|
||||
|
||||
while(ids):
|
||||
cr.execute('SELECT DISTINCT task_id '\
|
||||
'FROM project_task_parent_rel '\
|
||||
'WHERE parent_id IN %s', (tuple(ids),))
|
||||
child_ids = map(itemgetter(0), cr.fetchall())
|
||||
c_ids = child_ids
|
||||
if (list(set(parent_ids).intersection(set(c_ids)))) or (obj_task.id in c_ids):
|
||||
return False
|
||||
while len(c_ids):
|
||||
s_ids = self.search(cr, uid, [('parent_ids', 'in', c_ids)])
|
||||
if (list(set(parent_ids).intersection(set(s_ids)))):
|
||||
return False
|
||||
c_ids = s_ids
|
||||
ids = child_ids
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end'])
|
||||
(_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end']),
|
||||
(_check_recursion, _('Error ! You cannot create recursive tasks.'), ['parent_ids'])
|
||||
]
|
||||
#
|
||||
# Override view according to the company definition
|
||||
|
||||
@@ -116,7 +116,7 @@ class project_phase(osv.osv):
|
||||
'sequence': 10,
|
||||
'product_uom': lambda self,cr,uid,c: self.pool.get('product.uom').search(cr, uid, [('name', '=', _('Day'))], context=c)[0]
|
||||
}
|
||||
_order = "name"
|
||||
_order = "project_id, date_start, sequence, name"
|
||||
_constraints = [
|
||||
(_check_recursion,'Loops in phases not allowed',['next_phase_ids', 'previous_phase_ids']),
|
||||
(_check_dates, 'Phase start-date must be lower than phase end-date.', ['date_start', 'date_end']),
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<xpath expr="//page[@string='Tasks Stages']" position="after">
|
||||
<page string="Messages" groups="base.group_extended">
|
||||
<field name="message_ids" nolabel="1" colspan="4">
|
||||
<tree editable="1">
|
||||
<tree editable="1" string="Messages">
|
||||
<field name="message" attrs="{'readonly':[('from_id', '!=', uid)]}"/>
|
||||
<field name="from_id"/>
|
||||
<field name="to_id" attrs="{'readonly':[('from_id', '!=', uid)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user