diff --git a/addons/account/account.py b/addons/account/account.py
index b050f43ad4e..5fc97a13697 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -1027,6 +1027,33 @@ class account_move(osv.osv):
_description = "Account Entry"
_order = 'id desc'
+ def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
+ """
+ Returns a list of tupples containing id, name, as internally it is called {def name_get}
+ result format : {[(id, name), (id, name), ...]}
+
+ @param cr: A database cursor
+ @param user: ID of the user currently logged in
+ @param name: name to search
+ @param args: other arguments
+ @param operator: default operator is 'ilike', it can be changed
+ @param context: context arguments, like lang, time zone
+ @param limit: Returns first 'n' ids of complete result, default is 80.
+
+ @return: Returns a list of tupples containing id and name
+ """
+
+ if not args:
+ args=[]
+ if not context:
+ context={}
+ ids = []
+
+ if name:
+ ids += self.search(cr, user, [('state','=','draft'), ('id','=',name)], limit=limit)
+
+ return self.name_get(cr, user, ids, context=context)
+
def name_get(self, cursor, user, ids, context=None):
if not len(ids):
return []
@@ -2205,7 +2232,6 @@ class account_add_tmpl_wizard(osv.osv_memory):
def _get_def_cparent(self, cr, uid, context):
acc_obj=self.pool.get('account.account')
tmpl_obj=self.pool.get('account.account.template')
- #print "Searching for ",context
tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id'])
if not tids or not tids[0]['parent_id']:
return False
@@ -2247,7 +2273,6 @@ class account_add_tmpl_wizard(osv.osv_memory):
# 'tax_ids': [(6,0,tax_ids)], todo!!
'company_id': company_id,
}
- # print "Creating:", vals
new_account = acc_obj.create(cr, uid, vals)
return {'type':'state', 'state': 'end' }
diff --git a/addons/account/account_installer.xml b/addons/account/account_installer.xml
index 479f9bf1c65..5b57ab130fd 100644
--- a/addons/account/account_installer.xml
+++ b/addons/account/account_installer.xml
@@ -1,14 +1,14 @@
-
- account.installer.view
+
+ account.installer.form
account.installer
form
@@ -54,37 +54,79 @@
-
-
-
-
-
-
-
-
-
-
- Accounting Modules Installation
+
+ account.installer.modules.form
+ account.installer.modules
+ form
+
+
+
+
+
+ Install Extra Accounting Modules In Your Accounting System
+
+
+ From this screen, you can install extra accounting modules in your accounting system. Select the modules to directly install them. If you do not think you need any of these right now, you can easily install them later.
+
+
+ 23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Accounting Chart Configuration
ir.actions.act_window
account.installer
-
+
form
form
new
-
-
+
+ Accounting Modules Installation
+ ir.actions.act_window
+ account.installer.modules
+
+ form
+ form
+ new
+
+
+
+
3
onskip
+
+
+ 5
+ always
+
+
ir.actions.todo
account_installer_action_replace
@@ -92,7 +134,7 @@
-
+
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index d3dd4f1ee78..d122da7d19e 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -407,7 +407,7 @@ class account_move_line(osv.osv):
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2),
- 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly',True)]}, help="The move of this entry line.", select=2),
+ 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", help="The move of this entry line.", select=2),
'narration': fields.related('move_id','narration', type='text', relation='account.move', string='Narration'),
'ref': fields.char('Ref.', size=64),
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
@@ -560,7 +560,7 @@ class account_move_line(osv.osv):
#if jt in ('sale', 'purchase_refund', 'bank', 'cash'):
if jt in ('sale', 'purchase_refund'):
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2)
- elif jt in ('purchase', 'sale_refund', 'expense'):
+ elif jt in ('purchase', 'sale_refund', 'expense', 'bank', 'cash'):
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1)
if val.get('account_id', False):
@@ -798,30 +798,30 @@ class account_move_line(osv.osv):
return j+(p and (':'+p) or '')
return False
-# def onchange_date(self, cr, user, ids, date, context={}):
-# """
-# Returns a dict that contains new values and context
-# @param cr: A database cursor
-# @param user: ID of the user currently logged in
-# @param date: latest value from user input for field date
-# @param args: other arguments
-# @param context: context arguments, like lang, time zone
-# @return: Returns a dict which contains new values, and context
-# """
-# res = {}
-# period_pool = self.pool.get('account.period')
-# pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
-# if pids:
-# res.update({
-# 'period_id':pids[0]
-# })
-# context.update({
-# 'period_id':pids[0]
-# })
-# return {
-# 'value':res,
-# 'context':context,
-# }
+ def onchange_date(self, cr, user, ids, date, context={}):
+ """
+ Returns a dict that contains new values and context
+ @param cr: A database cursor
+ @param user: ID of the user currently logged in
+ @param date: latest value from user input for field date
+ @param args: other arguments
+ @param context: context arguments, like lang, time zone
+ @return: Returns a dict which contains new values, and context
+ """
+ res = {}
+ period_pool = self.pool.get('account.period')
+ pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
+ if pids:
+ res.update({
+ 'period_id':pids[0]
+ })
+ context.update({
+ 'period_id':pids[0]
+ })
+ return {
+ 'value':res,
+ 'context':context,
+ }
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
@@ -882,20 +882,29 @@ class account_move_line(osv.osv):
attrs = []
if field == 'debit':
attrs.append('sum="Total debit"')
+
elif field == 'credit':
attrs.append('sum="Total credit"')
+
elif field == 'account_tax_id':
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
attrs.append("context=\"{'journal_id':journal_id}\"")
+
elif field == 'account_id' and journal.id:
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
+
elif field == 'partner_id':
attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
+
elif field == 'journal_id':
attrs.append("context=\"{'journal_id':journal_id}\"")
+
elif field == 'statement_id':
attrs.append("domain=\"[('state','!=','confirm'),('journal_id.type','=','bank')]\"")
-
+
+ elif field == 'date':
+ attrs.append('on_change="onchange_date(date)"')
+
if field in ('amount_currency', 'currency_id'):
attrs.append('on_change="onchange_currency(account_id, amount_currency,currency_id, date, journal_id)"')
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index daf4ebcac26..68e9cc3ba7e 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -1048,7 +1048,7 @@
-
+
Entry Lines
@@ -1058,9 +1058,10 @@
-
+
+
@@ -1073,8 +1074,8 @@
-
-
+
+
@@ -1377,29 +1378,29 @@
-->
-
- Journal Items
- account.move.line
- form
- tree,form,graph
-
-
- [('journal_id.type', 'in', ['sale', 'purchase_refund'])]
-
+
+
+
+
+
+
+
+
+
-
+
-
- Journal Items
- account.move.line
- form
- tree,form,graph
-
-
- [('journal_id.type', 'in', ['purchase', 'sale_refund'])]
-
+
+
+
+
+
+
+
+
+
-
+
Entry Lines
@@ -2416,22 +2417,22 @@
id="menu_action_account_fiscal_position_form_template"
parent="account_template_folder" sequence="20"/>
-
- Journal Items
- account.move.line
- form
- tree,form,graph
-
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
diff --git a/addons/account/installer.py b/addons/account/installer.py
index cd613f7a6be..250fb5c782c 100644
--- a/addons/account/installer.py
+++ b/addons/account/installer.py
@@ -18,11 +18,13 @@
# along with this program. If not, see .
#
##############################################################################
+
import time
import datetime
from dateutil.relativedelta import relativedelta
from os.path import join as opj
from operator import itemgetter
+
from tools.translate import _
from osv import fields, osv
import netsvc
@@ -55,25 +57,6 @@ class account_installer(osv.osv_memory):
help="Installs localized accounting charts to match as closely as "
"possible the accounting needs of your company based on your "
"country."),
- 'account_analytic_plans':fields.boolean('Multiple Analytic Plans',
- help="Allows invoice lines to impact multiple analytic accounts "
- "simultaneously."),
- 'account_payment':fields.boolean('Suppliers Payment Management',
- help="Streamlines invoice payment and creates hooks to plug "
- "automated payment systems in."),
- 'account_followup':fields.boolean('Followups Management',
- help="Helps you generate reminder letters for unpaid invoices, "
- "including multiple levels of reminding and customized "
- "per-partner policies."),
- 'account_asset':fields.boolean('Assets Management',
- help="Enables asset management in the accounting application, "
- "including asset categories and usage periods."),
- 'account_voucher':fields.boolean('Voucher Management',
- help="Account Voucher module includes all the basic requirements of "
- "Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc... "),
- 'account_voucher_payment':fields.boolean('Voucher and Reconcile Management',
- help="Extension Account Voucher module includes allows to link payment / receipt "
- "entries with voucher, also automatically reconcile during the payment and receipt entries."),
'date_start': fields.date('Start Date', required=True),
'date_stop': fields.date('End Date', required=True),
'period':fields.selection([('month','Monthly'), ('3months','3 Monthly')],
@@ -103,11 +86,6 @@ class account_installer(osv.osv_memory):
return {}
def generate_configurable_chart(self, cr, uid, ids, context=None):
- mod_obj = self.pool.get('ir.model.data')
- result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template')
- id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
- obj_multi = self.pool.get('account.chart.template').browse(cr, uid, id)
-
obj_acc = self.pool.get('account.account')
obj_acc_tax = self.pool.get('account.tax')
obj_journal = self.pool.get('account.journal')
@@ -116,6 +94,14 @@ class account_installer(osv.osv_memory):
obj_fiscal_position_template = self.pool.get('account.fiscal.position.template')
obj_fiscal_position = self.pool.get('account.fiscal.position')
data_pool = self.pool.get('ir.model.data')
+ mod_obj = self.pool.get('ir.model.data')
+
+ result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template')
+ id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
+ obj_multi = self.pool.get('account.chart.template').browse(cr, uid, id)
+
+ if context is None:
+ context = {}
company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id
seq_journal = True
@@ -302,7 +288,7 @@ class account_installer(osv.osv_memory):
data_id = mod_obj.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')])
data = mod_obj.browse(cr, uid, data_id[0])
view_id = data.res_id
-
+
seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0]
if seq_journal:
@@ -405,10 +391,12 @@ class account_installer(osv.osv_memory):
obj_ac_fp.create(cr, uid, vals_acc)
def execute(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
super(account_installer, self).execute(cr, uid, ids, context=context)
record = self.browse(cr, uid, ids, context=context)[0]
- company_id = self.pool.get('res.users').browse(cr,uid,[uid],context)[0].company_id
- for res in self.read(cr,uid,ids):
+ company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id
+ for res in self.read(cr, uid, ids):
if record.charts == 'configurable':
mod_obj = self.pool.get('ir.model.data')
fp = tools.file_open(opj('account','configurable_account_chart.xml'))
@@ -501,20 +489,46 @@ class account_installer(osv.osv_memory):
'Installing chart of accounts %s'%chart)
return modules | set([chart])
-
account_installer()
class account_bank_accounts_wizard(osv.osv_memory):
_name='account.bank.accounts.wizard'
_columns = {
- 'acc_name':fields.char('Account Name.', size=64, required=True),
- 'bank_account_id':fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True),
- 'currency_id':fields.many2one('res.currency', 'Currency'),
- 'account_type':fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Type', size=32),
+ 'acc_name': fields.char('Account Name.', size=64, required=True),
+ 'bank_account_id': fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True),
+ 'currency_id': fields.many2one('res.currency', 'Currency'),
+ 'account_type': fields.selection([('cash','Cash'),('check','Check'),('bank','Bank')], 'Type', size=32),
}
_defaults = {
'currency_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
}
account_bank_accounts_wizard()
+
+class account_installer_modules(osv.osv_memory):
+ _name = 'account.installer.modules'
+ _inherit = 'res.config.installer'
+ _columns = {
+ # Accounting
+ 'account_analytic_plans':fields.boolean('Multiple Analytic Plans',
+ help="Allows invoice lines to impact multiple analytic accounts "
+ "simultaneously."),
+ 'account_payment':fields.boolean('Suppliers Payment Management',
+ help="Streamlines invoice payment and creates hooks to plug "
+ "automated payment systems in."),
+ 'account_followup':fields.boolean('Followups Management',
+ help="Helps you generate reminder letters for unpaid invoices, "
+ "including multiple levels of reminding and customized "
+ "per-partner policies."),
+ 'account_voucher':fields.boolean('Voucher Management',
+ help="Account Voucher module includes all the basic requirements of "
+ "Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc... "),
+ 'account_voucher_payment':fields.boolean('Voucher and Reconcile Management',
+ help="Extension Account Voucher module includes allows to link payment / receipt "
+ "entries with voucher, also automatically reconcile during the payment and receipt entries."),
+ }
+
+account_installer_modules()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/account/invoice.py b/addons/account/invoice.py
index 35437fa019a..d3615e651d0 100644
--- a/addons/account/invoice.py
+++ b/addons/account/invoice.py
@@ -393,21 +393,23 @@ class account_invoice(osv.osv):
p = self.pool.get('res.partner').browse(cr, uid, partner_id)
if company_id:
if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id:
- rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
- pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
+ property_obj = self.pool.get('ir.property')
+ rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
+ pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
if not rec_pro_id:
- rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
+ rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
if not pay_pro_id:
- pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
- rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id'])
- pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id'])
+ pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
+ rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value','res_id'])
+ pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value','res_id'])
rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False
pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company, Please Create account.'))
- rec_obj_acc=self.pool.get('account.account').browse(cr, uid, [rec_res_id])
- pay_obj_acc=self.pool.get('account.account').browse(cr, uid, [pay_res_id])
+ account_obj = self.pool.get('account.account')
+ rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
+ pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
p.property_account_receivable = rec_obj_acc[0]
p.property_account_payable = pay_obj_acc[0]
@@ -487,17 +489,18 @@ class account_invoice(osv.osv):
partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id)
if partner_obj.property_account_payable and partner_obj.property_account_receivable:
if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id:
- rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
- pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
+ property_obj = self.pool.get('ir.property')
+ rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
+ pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)])
if not rec_pro_id:
- rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)])
+ rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)])
if not pay_pro_id:
- pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)])
- rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id'])
- pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id'])
+ pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)])
+ rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id'])
+ pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id'])
rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False
pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False
- if not rec_res_id and not rec_res_id:
+ if not rec_res_id and not pay_res_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company, Please Create account.'))
if type in ('out_invoice', 'out_refund'):
@@ -505,13 +508,14 @@ class account_invoice(osv.osv):
else:
acc_id = pay_res_id
val= {'account_id': acc_id}
+ account_obj = self.pool.get('account.account')
if ids:
if company_id:
inv_obj = self.browse(cr,uid,ids)
for line in inv_obj[0].invoice_line:
if line.account_id:
if line.account_id.company_id.id != company_id:
- result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
+ result_id = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)])
if not result_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company in invoice line account, Please Create account.'))
@@ -519,7 +523,7 @@ class account_invoice(osv.osv):
else:
if invoice_line:
for inv_line in invoice_line:
- obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id'])
+ obj_l = account_obj.browse(cr, uid, inv_line[2]['account_id'])
if obj_l.company_id.id != company_id:
raise osv.except_osv(_('Configration Error !'),
_('invoice line account company is not match with invoice company.'))
@@ -1281,20 +1285,23 @@ class account_invoice_line(osv.osv):
else:
return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}}
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
- fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
+ fpos_obj = self.pool.get('account.fiscal.position')
+ fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False
if part.lang:
context.update({'lang': part.lang})
result = {}
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
-
+
if company_id:
- in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
+ property_obj = self.pool.get('ir.property')
+ account_obj = self.pool.get('account.account')
+ in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
if not in_pro_id:
- in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
- exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
+ in_pro_id = property_obj.search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
+ exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)])
if not exp_pro_id:
- exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
+ exp_pro_id = property_obj.search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)])
if not in_pro_id:
in_acc = res.product_tmpl_id.property_account_income
@@ -1304,7 +1311,7 @@ class account_invoice_line(osv.osv):
else:
app_acc_in = in_acc_cate
else:
- app_acc_in = self.pool.get('account.account').browse(cr, uid, in_pro_id)[0]
+ app_acc_in = account_obj.browse(cr, uid, in_pro_id)[0]
if not exp_pro_id:
ex_acc = res.product_tmpl_id.property_account_expense
ex_acc_cate = res.categ_id.property_account_expense_categ
@@ -1313,7 +1320,7 @@ class account_invoice_line(osv.osv):
else:
app_acc_exp = ex_acc_cate
else:
- app_acc_exp = self.pool.get('account.account').browse(cr, uid, exp_pro_id)[0]
+ app_acc_exp = account_obj.browse(cr, uid, exp_pro_id)[0]
if not in_pro_id and not exp_pro_id:
in_acc = res.product_tmpl_id.property_account_income
in_acc_cate = res.categ_id.property_account_income_categ
@@ -1329,13 +1336,13 @@ class account_invoice_line(osv.osv):
# app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0]
# app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0]
if app_acc_in.company_id.id != company_id and app_acc_exp.company_id.id != company_id:
- in_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)])
- exp_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
+ in_res_id = account_obj.search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)])
+ exp_res_id = account_obj.search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)])
if not in_res_id and not exp_res_id:
raise osv.except_osv(_('Configration Error !'),
_('Can not find account chart for this company, Please Create account.'))
- in_obj_acc=self.pool.get('account.account').browse(cr, uid, in_res_id)
- exp_obj_acc=self.pool.get('account.account').browse(cr, uid, exp_res_id)
+ in_obj_acc = account_obj.browse(cr, uid, in_res_id)
+ exp_obj_acc = account_obj.browse(cr, uid, exp_res_id)
if in_acc or ex_acc:
res.product_tmpl_id.property_account_income = in_obj_acc[0]
res.product_tmpl_id.property_account_expense = exp_obj_acc[0]
@@ -1344,26 +1351,26 @@ class account_invoice_line(osv.osv):
res.categ_id.property_account_expense_categ = exp_obj_acc[0]
if type in ('out_invoice','out_refund'):
- a = res.product_tmpl_id.property_account_income.id
+ a = res.product_tmpl_id.property_account_income.id
if not a:
a = res.categ_id.property_account_income_categ.id
else:
- a = res.product_tmpl_id.property_account_expense.id
+ a = res.product_tmpl_id.property_account_expense.id
if not a:
a = res.categ_id.property_account_expense_categ.id
- a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a)
+ a = fpos_obj.map_account(cr, uid, fpos, a)
if a:
result['account_id'] = a
- taxep=None
+ taxep = None
tax_obj = self.pool.get('account.tax')
if type in ('out_invoice', 'out_refund'):
taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
- tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
+ tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
else:
taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
- tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
+ tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
if type in ('in_invoice', 'in_refund'):
to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit or res.standard_price, qty, address_invoice_id, product, partner_id, context=context)
result.update(to_update)
@@ -1380,11 +1387,10 @@ class account_invoice_line(osv.osv):
if res2 :
domain = {'uos_id':[('category_id','=',res2 )]}
- prod_pool=self.pool.get('product.product')
result['categ_id'] = res.categ_id.id
res_final = {'value':result, 'domain':domain}
- if not company_id and not currency_id:
+ if not company_id or not currency_id:
return res_final
company = self.pool.get('res.company').browse(cr, uid, company_id)
diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml
index fa4f24effc1..5af4787c6a6 100644
--- a/addons/account/test/account_fiscalyear_close.yml
+++ b/addons/account/test/account_fiscalyear_close.yml
@@ -48,7 +48,6 @@
-
!record {model: account.move.journal, id: account_move_journal_0}:
journal_id: account.sales_journal
- period_id: account_period_jan11
-
I clicked on Open Journal Button to check the entries
diff --git a/addons/account/wizard/account_journal_select_view.xml b/addons/account/wizard/account_journal_select_view.xml
index f5df24fa585..348218dd04d 100644
--- a/addons/account/wizard/account_journal_select_view.xml
+++ b/addons/account/wizard/account_journal_select_view.xml
@@ -8,11 +8,11 @@
form
diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py
index 142ade01737..92e8f23da49 100644
--- a/addons/account/wizard/account_move_journal.py
+++ b/addons/account/wizard/account_move_journal.py
@@ -26,23 +26,82 @@ import tools
class account_move_journal(osv.osv_memory):
_name = "account.move.journal"
_description = "Move journal"
- _columns = {
- 'journal_id': fields.many2one('account.journal', 'Journal', required=True),
- 'period_id': fields.many2one('account.period', 'Period', required=True),
- }
def _get_period(self, cr, uid, context={}):
- """Return default account period value"""
+ """
+ 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
- _defaults = {
- 'period_id': _get_period
- }
+ 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_move_journal, 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']
+
+ view = """
+ """ % (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
@@ -50,48 +109,60 @@ class account_move_journal(osv.osv_memory):
@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
-
"""
- jp = self.pool.get('account.journal.period')
- mod_obj = self.pool.get('ir.model.data')
+
+ 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 = {}
- data = self.read(cr, uid, ids, ['journal_id', 'period_id'], context=context)[0]
- cr.execute('select id,name from ir_ui_view where model=%s and type=%s', ('account.move.line', 'form'))
- view_res = cr.fetchone()
- journal_id = data['journal_id']
- period_id = data['period_id']
-
- ids = jp.search(cr, uid, [('journal_id', '=', journal_id), \
- ('period_id', '=', period_id)],context=context)
-
- if not len(ids):
- name = self.pool.get('account.journal').read(cr, uid, [journal_id])[0]['name']
- state = self.pool.get('account.period').read(cr, uid, [period_id])[0]['state']
- if state == 'done':
- raise osv.except_osv(_('UserError'), _('This period is already closed !'))
- company = self.pool.get('account.period').read(cr, uid, [period_id])[0]['company_id'][0]
- jp.create(cr, uid, {'name': name, 'period_id': period_id, 'journal_id': journal_id, 'company_id': company},context=context)
-
- ids = jp.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)],context=context)
- jp = jp.browse(cr, uid, ids, context=context)[0]
- name = (jp.journal_id.code or '') + ':' + (jp.period_id.code or '')
-
- result = mod_obj._get_id(cr, uid, 'account', 'view_account_move_line_filter')
- res = mod_obj.read(cr, uid, result, ['res_id'],context=context)
+
+ journal_id = self._get_journal(cr, uid, context)
+ period_id = self._get_period(cr, uid, context)
+ name = _("Journal Items")
+ if journal_id:
+ ids = period_pool.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)], context=context)
+
+ if not len(ids):
+ journal = journal_pool.browse(cr, uid, journal_id)
+ period = self.pool.get('account.period').browse(cr, uid, period_id)
+
+ name = journal.name
+ state = period.state
+
+ if state == 'done':
+ raise osv.except_osv(_('UserError'), _('This period is already closed !'))
+
+ company = period.company_id.id
+ res = {
+ 'name': name,
+ 'period_id': period_id,
+ 'journal_id': journal_id,
+ 'company_id': company
+ }
+ period_pool.create(cr, uid, res,context=context)
+
+ ids = period_pool.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)],context=context)
+ period = period_pool.browse(cr, uid, ids[0], context=context)
+ name = (period.journal_id.code or '') + ':' + (period.period_id.code or '')
+
+ result = data_pool._get_id(cr, uid, 'account', 'view_account_move_line_filter')
+ res_id = data_pool.browse(cr, uid, result, context=context).res_id
+
return {
- 'domain': "[('journal_id','=',%d), ('period_id','=',%d)]" % (journal_id, period_id),
+# 'domain': str([('journal_id', '=', journal_id), ('period_id', '=', period_id)]),
'name': name,
'view_type': 'form',
- 'view_mode': 'tree,form',
+ 'view_mode': 'tree,form,graph',
'res_model': 'account.move.line',
- 'view_id': view_res,
- 'context': "{'journal_id': %d, 'period_id': %d}" % (journal_id, period_id),
+ 'view_id': False,
+ 'context': "{'journal_id': %d, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (journal_id, journal_id, period_id),
'type': 'ir.actions.act_window',
- 'search_view_id': res['res_id']
- }
-
+ 'search_view_id': res_id
+ }
+
account_move_journal()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/account_move_journal_view.xml b/addons/account/wizard/account_move_journal_view.xml
index d766153a9b4..fbc160f9eb4 100644
--- a/addons/account/wizard/account_move_journal_view.xml
+++ b/addons/account/wizard/account_move_journal_view.xml
@@ -2,40 +2,72 @@
-
+
account.move.journal.form
account.move.journal
form
-
- Entries by Line
+
+ Journal Items
account.move.journal
form
- tree,form
-
- new
+
+ {'journal_type':'sale'}
+ new
+
+
+
+
+ Journal Refund Items
+ account.move.journal
+ form
+
+ {'journal_type':'purchase_refund'}
+ new
+
+
+
+
+ Journal Items
+ account.move.journal
+ form
+
+ {'journal_type':'purchase'}
+ new
+
+
+
+
+ Journal Refund Items
+ account.move.journal
+ form
+
+ {'journal_type':'sale_refund'}
+ new
+
+
+
+
+ Journal Items
+ account.move.journal
+ form
+
+ {'journal_type':'bank'}
+ new
-
-
-
-
-
+
-
\ No newline at end of file
+
diff --git a/addons/account/wizard/account_report_aged_partner_balance_view.xml b/addons/account/wizard/account_report_aged_partner_balance_view.xml
index 4db605bdb1b..8bb3a43938c 100644
--- a/addons/account/wizard/account_report_aged_partner_balance_view.xml
+++ b/addons/account/wizard/account_report_aged_partner_balance_view.xml
@@ -37,7 +37,7 @@
{'record_id':active_id}
new
- Aged Partner Balance is a more detailed report of your receivables by intervals. When opening that report, Open ERP asks for the name of the company, the fiscal period and the size of the interval to be analyzed (in days). Open ERP then calculates a table of credit balance by period. So if you request an interval of 30 days OpenERP generates an analysis of creditors for the past month, past two months, and so on.
+ Aged Partner Balance is a more detailed report of your receivables by intervals. When opening that report, OpenERP asks for the name of the company, the fiscal period and the size of the interval to be analyzed (in days). OpenERP then calculates a table of credit balance by period. So if you request an interval of 30 days OpenERP generates an analysis of creditors for the past month, past two months, and so on.