# Starts: Manual entry from account.move form
if context.get('lines',[]):
total_new = 0.00
- for i in context['lines']:
- if i[2]:
- total_new += (i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00)
- for item in i[2]:
- data[item] = i[2][item]
+ for line_record in context['lines']:
+ if not isinstance(line_record, (tuple, list)):
+ line_record_detail = self.read(cr, uid, line_record, ['analytic_account_id','debit','credit','name','reconcile_id','tax_code_id','tax_amount','account_id','ref','currency_id','date_maturity','amount_currency','partner_id', 'reconcile_partial_id'])
+ else:
+ line_record_detail = line_record[2]
+ total_new += (line_record_detail['debit'] or 0.00)- (line_record_detail['credit'] or 0.00)
+ for item in line_record_detail.keys():
+ data[item] = line_record_detail[item]
if context['journal']:
journal_data = journal_obj.browse(cr, uid, context['journal'], context=context)
if journal_data.type == 'purchase':
}),
'date_created': fields.date('Creation date', select=True),
'analytic_lines': fields.one2many('account.analytic.line', 'move_id', 'Analytic lines'),
- 'centralisation': fields.selection([('normal','Normal'),('credit','Credit Centralisation'),('debit','Debit Centralisation')], 'Centralisation', size=6),
+ 'centralisation': fields.selection([('normal','Normal'),('credit','Credit Centralisation'),('debit','Debit Centralisation'),('currency','Currency Adjustment')], 'Centralisation', size=8),
'balance': fields.function(_balance, fnct_search=_balance_search, method=True, string='Balance'),
'state': fields.selection([('draft','Unbalanced'), ('valid','Valid')], 'State', readonly=True,
help='When new move line is created the state will be \'Draft\'.\n* When all the payments are done it will be in \'Valid\' state.'),
'date_created': lambda *a: time.strftime('%Y-%m-%d'),
'state': 'draft',
'currency_id': _get_currency,
- 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False),
+ 'journal_id': lambda self, cr, uid, c: c.get('journal_id', c.get('journal',False)),
'account_id': lambda self, cr, uid, c: c.get('account_id', False),
'period_id': lambda self, cr, uid, c: c.get('period_id', False),
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c)
return False
return True
- def _check_partner_id(self, cr, uid, ids, context=None):
- lines = self.browse(cr, uid, ids, context=context)
- for l in lines:
- if l.account_id.type in ('receivable', 'payable') and not l.partner_id:
- return False
- return True
-
_constraints = [
(_check_no_view, 'You can not create move line on view account.', ['account_id']),
(_check_no_closed, 'You can not create move line on closed account.', ['account_id']),
(_check_company_id, 'Company must be same for its related account and period.',['company_id'] ),
- (_check_partner_id, 'You can not create move line on receivable/payable account without partner', ['account_id'] )
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
journal_pool = self.pool.get('account.journal')
if context is None:
context = {}
- result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
+ 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':
#Remove the toolbar from the form view
if view_type == 'form':
if field in widths:
attrs.append('width="'+str(widths[field])+'"')
- attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field)))
+
+ if field in ('journal_id',):
+ attrs.append("invisible=\"context.get('journal_id', False)\"")
+ elif field in ('period_id',):
+ attrs.append("invisible=\"context.get('period_id', False)\"")
+ else:
+ attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field)))
xml += '''<field name="%s" %s/>\n''' % (field,' '.join(attrs))
xml += '''</tree>'''
context['period_id'] = line.period_id.id
result = super(account_move_line, self).unlink(cr, uid, [line.id], context=context)
if check:
+ context.update({'lines_cancel': 'cancel'})
move_obj.validate(cr, uid, [line.move_id.id], context=context)
return result