diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 315a09d3b56..662fdda69d5 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -29,6 +29,25 @@ import decimal_precision as dp class account_bank_statement(osv.osv): + def create(self, cr, uid, vals, context=None): + seq = 0 + if 'line_ids' in vals: + for line in vals['line_ids']: + seq += 1 + line[2]['sequence'] = seq + vals[seq - 1] = line + return super(account_bank_statement, self).create(cr, uid, vals, context=context) + + def write(self, cr, uid, ids, vals, context=None): + res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) + for statement in self.browse(cr, uid, ids, context): + seq = 0 + for line in statement.line_ids: + seq += 1 + if not line.sequence: + self.pool.get('account.bank.statement.line').write(cr, uid, [line.id], {'sequence': seq}, context=context) + return res + def button_import_invoice(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') if context is None: @@ -141,7 +160,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), + 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), 'line_ids': fields.one2many('account.bank.statement.line', 'statement_id', 'Statement lines', states={'confirm':[('readonly', True)]}), @@ -717,7 +736,6 @@ class account_bank_statement_line(osv.osv): 'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'), 'date': lambda *a: time.strftime('%Y-%m-%d'), 'type': lambda *a: 'general', - 'sequence': lambda *a: 10, } account_bank_statement_line() diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 01d292ce23e..daf2f9ba8f2 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -204,7 +204,6 @@ class account_cash_statement(osv.osv): return res _columns = { - 'company_id':fields.many2one('res.company', 'Company', required=True, states={'draft': [('readonly', False)]}, readonly=True,), 'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True, domain=[('type', '=', 'cash')]), 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox verifier"), 'state': fields.selection( @@ -224,22 +223,18 @@ class account_cash_statement(osv.osv): 'state': lambda *a: 'draft', 'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"), 'user_id': lambda self, cr, uid, context=None: uid, - 'company_id': _get_company, 'starting_details_ids':_get_cash_open_box_lines, 'ending_details_ids':_get_default_cash_close_box_lines } def create(self, cr, uid, vals, context=None): - company_id = vals and vals.get('company_id',False) - if company_id: - sql = [ - ('company_id', '=', vals['company_id']), + sql = [ ('journal_id', '=', vals['journal_id']), ('state', '=', 'open') - ] - open_jrnl = self.search(cr, uid, sql) - if open_jrnl: - raise osv.except_osv('Error', _('You can not have two open register for the same journal')) + ] + open_jrnl = self.search(cr, uid, sql) + if open_jrnl: + raise osv.except_osv('Error', _('You can not have two open register for the same journal')) if self.pool.get('account.journal').browse(cr, uid, vals['journal_id']).type == 'cash': lines = end_lines = self._get_cash_close_box_lines(cr, uid, [], context) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 2185599b741..5e4e7aa2ccb 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -524,15 +524,15 @@ - + + - @@ -546,7 +546,7 @@ - + diff --git a/addons/account_anglo_saxon/product_view.xml b/addons/account_anglo_saxon/product_view.xml index 71288ad5c3b..63c21407b69 100644 --- a/addons/account_anglo_saxon/product_view.xml +++ b/addons/account_anglo_saxon/product_view.xml @@ -7,7 +7,7 @@ form - + diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index 7cdd9ded9f2..fd77dce3f91 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -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, diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 52734ac4acb..3a9855e35f3 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -122,7 +122,7 @@ class account_voucher(osv.osv): \n* The \'Cancelled\' state is used when user cancel voucher.'), 'amount': fields.float('Total', digits=(16, 2), required=True, readonly=True, states={'draft':[('readonly',False)]}), 'tax_amount':fields.float('Tax Amount', digits=(14,2), readonly=True, states={'draft':[('readonly',False)]}), - 'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Transaction referance number."), + 'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Transaction reference number."), 'number': fields.related('move_id', 'name', type="char", readonly=True, string='Number'), 'move_id':fields.many2one('account.move', 'Account Entry'), 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Journal Items', readonly=True), @@ -177,7 +177,7 @@ class account_voucher(osv.osv): total_tax = 0.0 if not tax[0].price_include: - for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes'): + for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes',[]): total_tax += tax_line.get('amount') total += total_tax else: @@ -186,7 +186,7 @@ class account_voucher(osv.osv): line_total = 0.0 line_tax = 0.0 - for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes'): + for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes',[]): line_tax += tax_line.get('amount') line_total += tax_line.get('price_unit') total_tax += line_tax @@ -228,7 +228,7 @@ class account_voucher(osv.osv): 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'): + 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 @@ -661,49 +661,6 @@ 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','sale_refund'])], - 'purchase':[('type','in',['purchase','purchase_refund'])], - 'expense':[('type','in',['purchase'])], - 'sale_refund':[('type','in',['sale','sale_refund'])], - 'purchase_refund':[('type','in',['purchase','purchase_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 - account_voucher() class account_voucher_line(osv.osv): diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 62380cd08bb..a708f42e257 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -1,6 +1,86 @@ + + + account.voucher.customer.pay.select + account.voucher + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + account.voucher.purchase.pay.select + account.voucher + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + account.voucher.payment.form account.voucher @@ -85,13 +165,27 @@ Vendor Payment - account.voucher.open + account.voucher form [('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment')] - {'journal_type':'bank', 'type':'payment'} - - new + {'type':'payment'} + + + current + + + tree + + + + + form + + + + + @@ -177,13 +271,26 @@ Sales Payment - account.voucher.open + account.voucher form [('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')] - {'journal_type':'bank', 'type':'receipt'} - - new + {'type':'receipt'} + + + current + + + tree + + + + + form + + + + diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 8692cb3373d..9a55d5e4f83 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -1,16 +1,96 @@ + + account.voucher.purchase.select + account.voucher + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + account.voucher.sale.select + account.voucher + search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sales Payment account.voucher form [('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt'), ('partner_id','=',partner_id)] - {'journal_type':'bank', 'type':'receipt', 'partner_id': partner_id, 'referance':referance} + {'type':'receipt', 'partner_id': partner_id, 'default_reference':reference} new + account.voucher.sale.form account.voucher @@ -74,7 +154,7 @@