diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py
index c538614fd0f..019af2cdef5 100644
--- a/addons/account/__openerp__.py
+++ b/addons/account/__openerp__.py
@@ -73,7 +73,6 @@ for a particular financial year and for preparation of vouchers there is a modul
'wizard/account_fiscalyear_close_state.xml',
'wizard/account_chart_view.xml',
'wizard/account_tax_chart_view.xml',
- 'wizard/account_move_journal_view.xml',
'wizard/account_move_line_reconcile_select_view.xml',
'wizard/account_open_closed_fiscalyear_view.xml',
'wizard/account_move_line_unreconcile_select_view.xml',
@@ -128,9 +127,11 @@ for a particular financial year and for preparation of vouchers there is a modul
],
'js': [
'static/src/js/account_move_reconciliation.js',
+ 'static/src/js/account_move_line_quickadd.js',
],
'qweb' : [
"static/src/xml/account_move_reconciliation.xml",
+ "static/src/xml/account_move_line_quickadd.xml",
],
'css':['static/src/css/account_move_reconciliation.css'
],
diff --git a/addons/account/account.py b/addons/account/account.py
index 15881100441..438dff47aae 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -697,44 +697,6 @@ class account_account(osv.osv):
account_account()
-class account_journal_view(osv.osv):
- _name = "account.journal.view"
- _description = "Journal View"
- _columns = {
- 'name': fields.char('Journal View', size=64, required=True, translate=True),
- 'columns_id': fields.one2many('account.journal.column', 'view_id', 'Columns')
- }
- _order = "name"
-
-account_journal_view()
-
-
-class account_journal_column(osv.osv):
-
- def _col_get(self, cr, user, context=None):
- result = []
- cols = self.pool.get('account.move.line')._columns
- for col in cols:
- if col in ('period_id', 'journal_id'):
- continue
- result.append( (col, cols[col].string) )
- result.sort()
- return result
-
- _name = "account.journal.column"
- _description = "Journal Column"
- _columns = {
- 'name': fields.char('Column Name', size=64, required=True),
- 'field': fields.selection(_col_get, 'Field Name', required=True, size=32),
- 'view_id': fields.many2one('account.journal.view', 'Journal View', select=True),
- 'sequence': fields.integer('Sequence', help="Gives the sequence order to journal column.", readonly=True),
- 'required': fields.boolean('Required'),
- 'readonly': fields.boolean('Readonly'),
- }
- _order = "view_id, sequence"
-
-account_journal_column()
-
class account_journal(osv.osv):
_name = "account.journal"
_description = "Journal"
@@ -750,7 +712,6 @@ class account_journal(osv.osv):
" Select 'Opening/Closing Situation' for entries generated for new fiscal years."),
'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]),
'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]),
- 'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."),
'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]", help="It acts as a default account for credit amount"),
'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]", help="It acts as a default account for debit amount"),
'centralisation': fields.boolean('Centralised Counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."),
@@ -886,37 +847,6 @@ class account_journal(osv.osv):
return self.name_get(cr, user, ids, context=context)
- def onchange_type(self, cr, uid, ids, type, currency, context=None):
- obj_data = self.pool.get('ir.model.data')
- user_pool = self.pool.get('res.users')
-
- type_map = {
- 'sale':'account_sp_journal_view',
- 'sale_refund':'account_sp_refund_journal_view',
- 'purchase':'account_sp_journal_view',
- 'purchase_refund':'account_sp_refund_journal_view',
- 'cash':'account_journal_bank_view',
- 'bank':'account_journal_bank_view',
- 'general':'account_journal_view',
- 'situation':'account_journal_view'
- }
-
- res = {}
- view_id = type_map.get(type, 'account_journal_view')
- user = user_pool.browse(cr, uid, uid)
- if type in ('cash', 'bank') and currency and user.company_id.currency_id.id != currency:
- view_id = 'account_journal_bank_view_multi'
- data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)])
- data = obj_data.browse(cr, uid, data_id[0], context=context)
-
- res.update({
- 'centralisation':type == 'situation',
- 'view_id':data.res_id,
- })
- return {
- 'value':res
- }
-
account_journal()
class account_fiscalyear(osv.osv):
@@ -1396,13 +1326,6 @@ class account_move(osv.osv):
'WHERE id IN %s', ('draft', tuple(ids),))
return True
- def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
- balance = 0.0
- for line in line_ids:
- if line[2]:
- balance += (line[2].get('debit',0.00)- (line[2].get('credit',0.00)))
- return {'value': {'balance': balance}}
-
def write(self, cr, uid, ids, vals, context=None):
if context is None:
context = {}
@@ -3208,16 +3131,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
default_account = acc_template_ref.get(template.property_account_income_opening.id)
return default_account
- def _get_view_id(journal_type):
- # Get the journal views
- if journal_type in ('general', 'situation'):
- data = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_view')
- elif journal_type in ('sale_refund', 'purchase_refund'):
- data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_refund_journal_view')
- else:
- data = obj_data.get_object_reference(cr, uid, 'account', 'account_sp_journal_view')
- return data and data[1] or False
-
journal_names = {
'sale': _('Sales Journal'),
'purchase': _('Purchase Journal'),
@@ -3247,7 +3160,6 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'code': journal_codes[journal_type],
'company_id': company_id,
'centralisation': journal_type == 'situation',
- 'view_id': _get_view_id(journal_type),
'analytic_journal_id': _get_analytic_journal(journal_type),
'default_credit_account_id': _get_default_account(journal_type, 'credit'),
'default_debit_account_id': _get_default_account(journal_type, 'debit'),
@@ -3464,11 +3376,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'''
obj_data = self.pool.get('ir.model.data')
obj_journal = self.pool.get('account.journal')
- # Get the id of journal views
- tmp = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view_multi')
- view_id_cur = tmp and tmp[1] or False
- tmp = obj_data.get_object_reference(cr, uid, 'account', 'account_journal_bank_view')
- view_id_cash = tmp and tmp[1] or False
+
# we need to loop again to find next number for journal code
# because we can't rely on the value current_num as,
@@ -3494,10 +3402,8 @@ class wizard_multi_charts_accounts(osv.osv_memory):
'default_debit_account_id': default_account_id,
}
if line['currency_id']:
- vals['view_id'] = view_id_cur
vals['currency'] = line['currency_id']
- else:
- vals['view_id'] = view_id_cash
+
return vals
def _prepare_bank_account(self, cr, uid, line, new_code, acc_template_ref, ref_acc_bank, company_id, context=None):
diff --git a/addons/account/account_bank.py b/addons/account/account_bank.py
index c836600d866..f0da630ec1d 100644
--- a/addons/account/account_bank.py
+++ b/addons/account/account_bank.py
@@ -89,11 +89,6 @@ class bank(osv.osv):
}
acc_bank_id = obj_acc.create(cr,uid,acc,context=context)
- # Get the journal view id
- data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')])
- data = obj_data.browse(cr, uid, data_id[0], context=context)
- view_id_cash = data.res_id
-
jour_obj = self.pool.get('account.journal')
new_code = 1
while True:
@@ -112,7 +107,6 @@ class bank(osv.osv):
'analytic_journal_id': False,
'default_credit_account_id': acc_bank_id,
'default_debit_account_id': acc_bank_id,
- 'view_id': view_id_cash
}
journal_id = jour_obj.create(cr, uid, vals_journal, context=context)
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py
index 6804d5116f1..8d13ec9dc8f 100644
--- a/addons/account/account_invoice.py
+++ b/addons/account/account_invoice.py
@@ -1381,8 +1381,8 @@ class account_invoice_line(osv.osv):
'origin': fields.char('Source Document', size=256, help="Reference of the document that produced this invoice."),
'sequence': fields.integer('Sequence', help="Gives the sequence of this line when displaying the invoice."),
'invoice_id': fields.many2one('account.invoice', 'Invoice Reference', ondelete='cascade', select=True),
- 'uos_id': fields.many2one('product.uom', 'Unit of Measure', ondelete='set null'),
- 'product_id': fields.many2one('product.product', 'Product', ondelete='set null'),
+ 'uos_id': fields.many2one('product.uom', 'Unit of Measure', ondelete='set null', select=True),
+ 'product_id': fields.many2one('product.product', 'Product', ondelete='set null', select=True),
'account_id': fields.many2one('account.account', 'Account', required=True, domain=[('type','<>','view'), ('type', '<>', 'closed')], help="The income or expense account related to the selected product."),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),
'price_subtotal': fields.function(_amount_line, string='Subtotal', type="float",
diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py
index 3b2fe21d95b..7cc9768f00e 100644
--- a/addons/account/account_move_line.py
+++ b/addons/account/account_move_line.py
@@ -220,12 +220,11 @@ class account_move_line(osv.osv):
return context
def _default_get(self, cr, uid, fields, context=None):
+ #default_get should only do the following:
+ # -propose the next amount in debit/credit in order to balance the move
+ # -propose the next account from the journal (default debit/credit account) accordingly
if context is None:
context = {}
- if not context.get('journal_id', False):
- context['journal_id'] = context.get('search_default_journal_id')
- if not context.get('period_id', False):
- context['period_id'] = context.get('search_default_period_id')
account_obj = self.pool.get('account.account')
period_obj = self.pool.get('account.period')
journal_obj = self.pool.get('account.journal')
@@ -234,134 +233,71 @@ class account_move_line(osv.osv):
fiscal_pos_obj = self.pool.get('account.fiscal.position')
partner_obj = self.pool.get('res.partner')
currency_obj = self.pool.get('res.currency')
+
+ if not context.get('journal_id', False):
+ context['journal_id'] = context.get('search_default_journal_id', False)
+ if not context.get('period_id', False):
+ context['period_id'] = context.get('search_default_period_id', False)
context = self.convert_to_period(cr, uid, context)
- #pass the right context when search_defaul_journal_id
- if context.get('search_default_journal_id',False):
- context['journal_id'] = context.get('search_default_journal_id')
+
# Compute simple values
data = super(account_move_line, self).default_get(cr, uid, fields, context=context)
- # Starts: Manual entry from account.move form
- if context.get('lines'):
- total_new = context.get('balance', 0.00)
- if context['journal']:
- journal_data = journal_obj.browse(cr, uid, context['journal'], context=context)
- if journal_data.type == 'purchase':
- if total_new > 0:
- account = journal_data.default_credit_account_id
- else:
- account = journal_data.default_debit_account_id
- else:
- if total_new > 0:
- account = journal_data.default_credit_account_id
- else:
- account = journal_data.default_debit_account_id
- if account and ((not fields) or ('debit' in fields) or ('credit' in fields)) and 'partner_id' in data and (data['partner_id']):
- part = partner_obj.browse(cr, uid, data['partner_id'], context=context)
- account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
- account = account_obj.browse(cr, uid, account, context=context)
- data['account_id'] = account.id
-
- s = -total_new
- data['debit'] = s > 0 and s or 0.0
- data['credit'] = s < 0 and -s or 0.0
- data = self._default_get_move_form_hook(cr, uid, data)
- return data
- # Ends: Manual entry from account.move form
- if not 'move_id' in fields: #we are not in manual entry
- return data
- # Compute the current move
- move_id = False
- partner_id = False
- if context.get('journal_id', False) and context.get('period_id', False):
- if 'move_id' in fields:
- cr.execute('SELECT move_id \
- FROM \
- account_move_line \
- WHERE \
- journal_id = %s and period_id = %s AND create_uid = %s AND state = %s \
- ORDER BY id DESC limit 1',
- (context['journal_id'], context['period_id'], uid, 'draft'))
+ if context.get('journal_id'):
+ total = 0.0
+ #in account.move form view, it is not possible to compute total debit and credit using
+ #a browse record. So we must use the context to pass the whole one2many field and compute the total
+ if context.get('line_id'):
+ for move_line_dict in move_obj.resolve_2many_commands(cr, uid, 'line_id', context.get('line_id'), context=context):
+ data['name'] = data.get('name') or move_line_dict.get('name')
+ data['partner_id'] = data.get('partner_id') or move_line_dict.get('partner_id')
+ total += move_line_dict.get('debit', 0.0) - move_line_dict.get('credit', 0.0)
+ elif context.get('period_id'):
+ #find the date and the ID of the last unbalanced account.move encoded by the current user in that journal and period
+ move_id = False
+ cr.execute('''SELECT move_id, date FROM account_move_line
+ WHERE journal_id = %s AND period_id = %s AND create_uid = %s AND state = %s
+ ORDER BY id DESC limit 1''', (context['journal_id'], context['period_id'], uid, 'draft'))
res = cr.fetchone()
- move_id = (res and res[0]) or False
- if not move_id:
- return data
- else:
- data['move_id'] = move_id
- if 'date' in fields:
- cr.execute('SELECT date \
- FROM \
- account_move_line \
- WHERE \
- journal_id = %s AND period_id = %s AND create_uid = %s \
- ORDER BY id DESC',
- (context['journal_id'], context['period_id'], uid))
- res = cr.fetchone()
- if res:
- data['date'] = res[0]
- else:
- period = period_obj.browse(cr, uid, context['period_id'],
- context=context)
- data['date'] = period.date_start
- if not move_id:
- return data
- total = 0
- ref_id = False
- move = move_obj.browse(cr, uid, move_id, context=context)
- if 'name' in fields:
- data.setdefault('name', move.line_id[-1].name)
- acc1 = False
- for l in move.line_id:
- acc1 = l.account_id
- partner_id = partner_id or l.partner_id.id
- ref_id = ref_id or l.ref
- total += (l.debit or 0.0) - (l.credit or 0.0)
+ move_id = res and res[0] or False
+ data['date'] = res and res[1] or period_obj.browse(cr, uid, context['period_id'], context=context).date_start
+ data['move_id'] = move_id
+ if move_id:
+ #if there exist some unbalanced accounting entries that match the journal and the period,
+ #we propose to continue the same move by copying the ref, the name, the partner...
+ move = move_obj.browse(cr, uid, move_id, context=context)
+ data.setdefault('name', move.line_id[-1].name)
+ for l in move.line_id:
+ data['partner_id'] = data.get('partner_id') or l.partner_id.id
+ data['ref'] = data.get('ref') or l.ref
+ total += (l.debit or 0.0) - (l.credit or 0.0)
- if 'ref' in fields:
- data['ref'] = ref_id
- if 'partner_id' in fields:
- data['partner_id'] = partner_id
-
- if move.journal_id.type == 'purchase':
- if total > 0:
- account = move.journal_id.default_credit_account_id
- else:
- account = move.journal_id.default_debit_account_id
- else:
- if total > 0:
- account = move.journal_id.default_credit_account_id
- else:
- account = move.journal_id.default_debit_account_id
- part = partner_id and partner_obj.browse(cr, uid, partner_id) or False
- # part = False is acceptable for fiscal position.
- account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
- if account:
- account = account_obj.browse(cr, uid, account, context=context)
-
- if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
- data['account_id'] = account.id
- # Propose the price Tax excluded, the Tax will be added when confirming line
- if account.tax_ids:
- taxes = fiscal_pos_obj.map_tax(cr, uid, part and part.property_account_position or False, account.tax_ids)
- tax = tax_obj.browse(cr, uid, taxes)
- for t in tax_obj.compute_inv(cr, uid, tax, total, 1):
- total -= t['amount']
-
- s = -total
- data['debit'] = s > 0 and s or 0.0
- data['credit'] = s < 0 and -s or 0.0
-
- if account and account.currency_id:
- data['currency_id'] = account.currency_id.id
- acc = account
- if s>0:
- acc = acc1
- compute_ctx = context.copy()
- compute_ctx.update({
- 'res.currency.compute.account': acc,
- 'res.currency.compute.account_invert': True,
- })
- v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, context=compute_ctx)
- data['amount_currency'] = v
+ #compute the total of current move
+ data['debit'] = total < 0 and -total or 0.0
+ data['credit'] = total > 0 and total or 0.0
+ #pick the good account on the journal accordingly if the next proposed line will be a debit or a credit
+ journal_data = journal_obj.browse(cr, uid, context['journal_id'], context=context)
+ account = total > 0 and journal_data.default_credit_account_id or journal_data.default_debit_account_id
+ #map the account using the fiscal position of the partner, if needed
+ part = data.get('partner_id') and partner_obj.browse(cr, uid, data['partner_id'], context=context) or False
+ if account and data.get('partner_id'):
+ account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
+ account = account_obj.browse(cr, uid, account, context=context)
+ data['account_id'] = account and account.id or False
+ #compute the amount in secondary currency of the account, if needed
+ if account and account.currency_id:
+ data['currency_id'] = account.currency_id.id
+ #set the context for the multi currency change
+ compute_ctx = context.copy()
+ compute_ctx.update({
+ #the following 2 parameters are used to choose the currency rate, in case where the account
+ #doesn't work with an outgoing currency rate method 'at date' but 'average'
+ 'res.currency.compute.account': account,
+ 'res.currency.compute.account_invert': True,
+ })
+ if data.get('date'):
+ compute_ctx.update({'date': data['date']})
+ data['amount_currency'] = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], -total, context=compute_ctx)
+ data = self._default_get_move_form_hook(cr, uid, data)
return data
def on_create_write(self, cr, uid, id, context=None):
@@ -484,6 +420,15 @@ class account_move_line(osv.osv):
result.append(line.id)
return result
+ def _get_reconcile(self, cr, uid, ids,name, unknow_none, context=None):
+ res = dict.fromkeys(ids, False)
+ for line in self.browse(cr, uid, ids, context=context):
+ if line.reconcile_id:
+ res[line.id] = str(line.reconcile_id.name)
+ elif line.reconcile_partial_id:
+ res[line.id] = str(line.reconcile_partial_id.name)
+ return res
+
_columns = {
'name': fields.char('Name', size=64, required=True),
'quantity': fields.float('Quantity', digits=(16,2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very useful for some reports."),
@@ -498,15 +443,16 @@ class account_move_line(osv.osv):
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2),
'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2),
+ 'reconcile': fields.function(_get_reconcile, type='char', string='Reconcile'),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')),
'amount_residual_currency': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."),
'amount_residual': fields.function(_amount_residual, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
- 'journal_id': fields.related('move_id', 'journal_id', string='Journal', type='many2one', relation='account.journal', required=True, select=True, readonly=True,
+ 'journal_id': fields.related('move_id', 'journal_id', string='Journal', type='many2one', relation='account.journal', required=True, select=True,
store = {
'account.move': (_get_move_lines, ['journal_id'], 20)
}),
- 'period_id': fields.related('move_id', 'period_id', string='Period', type='many2one', relation='account.period', required=True, select=True, readonly=True,
+ 'period_id': fields.related('move_id', 'period_id', string='Period', type='many2one', relation='account.period', required=True, select=True,
store = {
'account.move': (_get_move_lines, ['period_id'], 20)
}),
@@ -537,7 +483,7 @@ class account_move_line(osv.osv):
context or {}
period_obj = self.pool.get('account.period')
dt = time.strftime('%Y-%m-%d')
- if ('journal_id' in context) and ('period_id' in context):
+ if context.get('journal_id') and context.get('period_id'):
cr.execute('SELECT date FROM account_move_line ' \
'WHERE journal_id = %s AND period_id = %s ' \
'ORDER BY id DESC limit 1',
@@ -558,6 +504,38 @@ class account_move_line(osv.osv):
cur = self.pool.get('account.journal').browse(cr, uid, context['journal_id']).currency
return cur and cur.id or False
+ def _get_period(self, cr, uid, context=None):
+ """
+ Return default account period value
+ """
+ context = context or {}
+ if context.get('period_id', False):
+ return context['period_id']
+ account_period_obj = self.pool.get('account.period')
+ ids = account_period_obj.find(cr, uid, context=context)
+ period_id = False
+ if ids:
+ period_id = ids[0]
+ return period_id
+
+ def _get_journal(self, cr, uid, context=None):
+ """
+ Return journal based on the journal type
+ """
+ context = context or {}
+ if context.get('journal_id', False):
+ return context['journal_id']
+ 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'))])
+ if not jids:
+ raise osv.except_osv(_('Configuration Error!'), _('Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration/Journals/Journals.') % context.get('journal_type'))
+ journal_id = jids[0]
+ return journal_id
+
+
_defaults = {
'blocked': False,
'centralisation': 'normal',
@@ -565,12 +543,12 @@ class account_move_line(osv.osv):
'date_created': fields.date.context_today,
'state': 'draft',
'currency_id': _get_currency,
- 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False),
+ 'journal_id': _get_journal,
'credit': 0.0,
'debit': 0.0,
'amount_currency': 0.0,
'account_id': lambda self, cr, uid, c: c.get('account_id', False),
- 'period_id': lambda self, cr, uid, c: c.get('period_id', False),
+ 'period_id': _get_period,
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
}
_order = "date desc, id desc"
@@ -675,6 +653,12 @@ class account_move_line(osv.osv):
}
return result
+ def onchange_account_id(self, cr, uid, ids, account_id, context=None):
+ res = {'value': {}}
+ if account_id:
+ res['value']['account_tax_id'] = [x.id for x in self.pool.get('account.account').browse(cr, uid, account_id, context=context).tax_ids]
+ return res
+
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False):
partner_obj = self.pool.get('res.partner')
payment_term_obj = self.pool.get('account.payment.term')
@@ -999,127 +983,6 @@ class account_move_line(osv.osv):
'context':context,
}
- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
- journal_pool = self.pool.get('account.journal')
- if context is None:
- context = {}
- result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
- if (view_type != 'tree') or view_id:
- #Remove the toolbar from the form view
- if view_type == 'form':
- if result.get('toolbar', False):
- result['toolbar']['action'] = []
- #Restrict the list of journal view in search view
- if view_type == 'search' and result['fields'].get('journal_id', False):
- result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context)
- ctx = context.copy()
- #we add the refunds journal in the selection field of journal
- if context.get('journal_type', False) == 'sale':
- ctx.update({'journal_type': 'sale_refund'})
- result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
- elif context.get('journal_type', False) == 'purchase':
- ctx.update({'journal_type': 'purchase_refund'})
- result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
- return result
- if context.get('view_mode', False):
- return result
- fld = []
- flds = []
- title = _("Accounting Entries") # self.view_header_get(cr, uid, view_id, view_type, context)
-
- ids = journal_pool.search(cr, uid, [], context=context)
- journals = journal_pool.browse(cr, uid, ids, context=context)
- for journal in journals:
- for field in journal.view_id.columns_id:
- # sometimes, it's possible that a defined column is not loaded (the module containing
- # this field is not loaded) when we make an update.
- if field.field not in self._columns:
- continue
-
- if not field.field in flds:
- fld.append((field.field, field.sequence))
- flds.append(field.field)
-
- default_columns = {
- 'period_id': 3,
- 'journal_id': 10,
- 'state': sys.maxint,
- }
- for d in default_columns:
- if d not in flds:
- fld.append((d, default_columns[d]))
- flds.append(d)
-
- fld = sorted(fld, key=itemgetter(1))
- widths = {
- 'statement_id': 50,
- 'state': 60,
- 'tax_code_id': 50,
- 'move_id': 40,
- }
-
- document = etree.Element('tree', string=title, editable="top",
- on_write="on_create_write",
- colors="red:state=='draft';black:state=='valid'")
- fields_get = self.fields_get(cr, uid, flds, context)
- for field, _seq in fld:
- # TODO add string to element
- f = etree.SubElement(document, 'field', name=field)
-
- if field == 'debit':
- f.set('sum', _("Total debit"))
-
- elif field == 'credit':
- f.set('sum', _("Total credit"))
-
- elif field == 'move_id':
- f.set('required', 'False')
-
- elif field == 'account_tax_id':
- f.set('domain', "[('parent_id', '=' ,False)]")
- f.set('context', "{'journal_id': journal_id}")
-
- elif field == 'account_id' and journal.id:
- f.set('domain', "[('journal_id', '=', journal_id),('type','!=','view'), ('type','!=','closed')]")
- f.set('on_change', 'onchange_account_id(account_id, partner_id)')
-
- elif field == 'partner_id':
- f.set('on_change', 'onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)')
-
- elif field == 'journal_id':
- f.set('context', "{'journal_id': journal_id}")
-
- elif field == 'statement_id':
- f.set('domain', "[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]")
- f.set('invisible', 'True')
-
- elif field == 'date':
- f.set('on_change', 'onchange_date(date)')
-
- elif field == 'analytic_account_id':
- # Currently it is not working due to being executed by superclass's fields_view_get
- # f.set('groups', 'analytic.group_analytic_accounting')
- pass
-
- if field in ('amount_currency', 'currency_id'):
- f.set('on_change', 'onchange_currency(account_id, amount_currency, currency_id, date, journal_id)')
- f.set('attrs', "{'readonly': [('state', '=', 'valid')]}")
-
- if field in widths:
- f.set('width', str(widths[field]))
-
- if field in ('journal_id',):
- f.set("invisible", "context.get('journal_id', False)")
- elif field in ('period_id',):
- f.set("invisible", "context.get('period_id', False)")
-
- orm.setup_modifiers(f, fields_get[field], context=context,
- in_tree_view=True)
-
- result['arch'] = etree.tostring(document, pretty_print=True)
- result['fields'] = fields_get
- return result
-
def _check_moves(self, cr, uid, context=None):
# use the first move ever created for this journal and period
if context is None:
@@ -1414,6 +1277,19 @@ class account_move_line(osv.osv):
move_obj.button_validate(cr,uid, [vals['move_id']], context)
return result
+ def list_periods(self, cr, uid, context=None):
+ ids = self.pool.get('account.period').search(cr,uid,[])
+ return self.pool.get('account.period').name_get(cr, uid, ids, context=context)
+
+ def list_journals(self, cr, uid, context=None):
+ ng = dict(self.pool.get('account.journal').name_search(cr,uid,'',[]))
+ ids = ng.keys()
+ result = []
+ for journal in self.pool.get('account.journal').browse(cr, uid, ids, context=context):
+ result.append((journal.id,ng[journal.id],journal.type,
+ bool(journal.currency),bool(journal.analytic_journal_id)))
+ return result
+
account_move_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 7732d8d8cb0..e2c45af8cba 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -2,10 +2,7 @@
-
-
+
account.fiscalyear.formaccount.fiscalyear
@@ -70,7 +67,7 @@
-
+ Fiscal Yearsaccount.fiscalyearform
@@ -90,12 +87,9 @@
-
-
-
+
+
account.period.formaccount.period
@@ -142,7 +136,6 @@
-
account.period.searchaccount.period
@@ -153,8 +146,7 @@
-
-
+ Periodsaccount.periodform
@@ -169,12 +161,9 @@
- Click to specify lists of columns to display for a type of journal.
-
- Journal views determine the way you can record entries in
- your journal. Select the fields you want to appear in a journal
- and determine the sequence in which they will appear.
-
- On the journal definition form, you can select the view you
- want to use to display journal items related to this journal.
-