diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index c53e2030e7f..d4408d63bfe 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -23,7 +23,7 @@ { "name" : "Accounting and Financial Management", "version" : "1.1", - "depends" : ["product", "analytic", "process"], + "depends" : ["product", "analytic", "process","board"], "author" : "Tiny", "category": 'Generic Modules/Accounting', "description": """Financial and accounting module that covers: @@ -34,6 +34,10 @@ Budgets Customer and Supplier Invoices Bank statements + Creates a dashboards for accountants that includes: + * List of uninvoiced quotations + * Graph of aged receivables + * Graph of aged incomes The processes like maintaining of general ledger is done through the defined financial Journals (entry move line or grouping is maintained through journal) for a particular financial year and for preparation of vouchers there is a @@ -100,9 +104,9 @@ module named account_voucherss 'project/wizard/account_analytic_chart_view.xml', 'product_view.xml', 'account_assert_test.xml', -# 'process/statement_process.xml', -# 'process/customer_invoice_process.xml', -# 'process/supplier_invoice_process.xml', + 'process/statement_process.xml', + 'process/customer_invoice_process.xml', + 'process/supplier_invoice_process.xml', 'sequence_view.xml', 'company_view.xml', 'account_installer.xml', @@ -111,7 +115,8 @@ module named account_voucherss 'report/account_report_view.xml', 'report/account_analytic_report_view.xml', 'report/account_account_report_view.xml', - 'report/account_analytic_entries_report_view.xml' + 'report/account_analytic_entries_report_view.xml', + 'board_account_view.xml', ], 'demo_xml': [ #'demo/price_accuracy00.yml', @@ -120,10 +125,19 @@ module named account_voucherss 'project/analytic_account_demo.xml', 'demo/account_minimal.xml', 'account_unit_test.xml', + 'board_account_demo.xml', ], 'test': [ 'test/account_customer_invoice.yml', 'test/account_supplier_invoice.yml', + 'test/account_change_currency.yml', + 'test/chart_of_account.yml', + 'test/account_period_close.yml', + 'test/account_fiscalyear_close_state.yml', + 'test/account_invoice_state.yml', + 'test/account_use_model.yml', + 'test/account_validate_account_move.yml', +# 'test/account_fiscalyear_close.yml', ], 'installable': True, 'active': False, diff --git a/addons/account/account.py b/addons/account/account.py index e30912aa187..2efd561af23 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -62,7 +62,7 @@ class account_payment_term(osv.osv): elif line.value == 'balance': amt = round(amount, prec) if amt: - next_date = datetime.strptime(date_ref, '%y-%m-%d') + relativedelta(days=line.days) + next_date = datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days) if line.days2 < 0: next_date += relativedelta(day=line.days2) if line.days2 > 0: @@ -509,8 +509,13 @@ class account_account(osv.osv): def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} + + if 'company_id' in vals: + move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)]) + if move_lines: + raise osv.except_osv(_('Warning !'), _('You cannot modify Company of account as its related record exist in Entry Lines')) if 'active' in vals and not vals['active']: - self._check_moves(cr, uid, ids, "write", context) + self._check_moves(cr, uid, ids, "write", context=context) if 'type' in vals.keys(): self._check_allow_type_change(cr, uid, ids, vals['type'], context=context) return super(account_account, self).write(cr, uid, ids, vals, context=context) @@ -593,6 +598,14 @@ class account_journal(osv.osv): 'user_id': lambda self,cr,uid,context: uid, 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } + def write(self, cr, uid, ids, vals, context=None): + obj=[] + if 'company_id' in vals: + move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)]) + if move_lines: + raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines')) + return super(account_period, self).write(cr, uid, ids, vals, context=context) + def create(self, cr, uid, vals, context={}): journal_id = super(account_journal, self).create(cr, uid, vals, context) # journal_name = self.browse(cr, uid, [journal_id])[0].code @@ -711,7 +724,7 @@ class account_period(osv.osv): 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True), 'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True, help='When monthly periods are created. The state is \'Draft\'. At the end of monthly period it is in \'Done\' state.'), - 'company_id': fields.many2one('res.company', 'Company', required=True) + 'company_id': fields.related('fiscalyear_id','company_id',type='many2one',relation='res.company',string='Company',store=True) } _defaults = { 'state': lambda *a: 'draft', @@ -784,6 +797,14 @@ class account_period(osv.osv): ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) return self.name_get(cr, user, ids, context=context) + def write(self, cr, uid, ids, vals, context=None): + obj=[] + if 'company_id' in vals: + move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)]) + if move_lines: + raise osv.except_osv(_('Warning !'), _('You cannot modify company of this period as its related record exist in Entry Lines')) + return super(account_period, self).write(cr, uid, ids, vals, context=context) + account_period() class account_journal_period(osv.osv): @@ -809,7 +830,7 @@ class account_journal_period(osv.osv): 'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'State', required=True, readonly=True, help='When journal period is created. The state is \'Draft\'. If a report is printed it comes to \'Printed\' state. When all transactions are done, it comes in \'Done\' state.'), 'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'), - 'company_id' : fields.many2one('res.company', 'Company') + 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company') } def _check(self, cr, uid, ids, context={}): diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 54c1082a2c1..51a020b9b75 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -53,7 +53,7 @@ - + @@ -346,9 +346,9 @@ - - - + + + @@ -357,16 +357,16 @@ - - - + + + - - - + + + - - + + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 7350596c4e3..086db98b211 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -498,9 +498,17 @@ class account_move_line(osv.osv): return False return True + def _check_company_id(self, cr, uid, ids): + lines = self.browse(cr, uid, ids) + for l in lines: + if l.company_id != l.account_id.company_id or l.company_id != l.period_id.company_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'] ), ] #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id @@ -574,6 +582,13 @@ class account_move_line(osv.osv): unmerge = [] total = 0.0 merges_rec = [] + + company_list = [] + for line in self.browse(cr, uid, ids, context=context): + if not line.company_id in company_list: + raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries')) + company_list.append(line.company_id) + for line in self.browse(cr, uid, ids, context): if line.reconcile_id: raise osv.except_osv(_('Warning'), _('Already Reconciled!')) @@ -587,6 +602,7 @@ class account_move_line(osv.osv): else: unmerge.append(line.id) total += (line.debit or 0.0) - (line.credit or 0.0) + if not total: res = self.reconcile(cr, uid, merges+unmerge, context=context) return res @@ -604,6 +620,13 @@ class account_move_line(osv.osv): currency = 0.0 account_id = False partner_id = False + + company_list = [] + for line in self.browse(cr, uid, ids, context=context): + if not line.company_id in company_list: + raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries')) + company_list.append(line.company_id) + for line in unrec_lines: if line.state <> 'valid': raise osv.except_osv(_('Error'), @@ -836,7 +859,7 @@ class account_move_line(osv.osv): if vals.get('date', False): todo_date = vals['date'] del vals['date'] - + for line in self.browse(cr, uid, ids,context=context): ctx = context.copy() if ('journal_id' not in ctx): @@ -848,8 +871,8 @@ class account_move_line(osv.osv): if line.move_id: ctx['period_id'] = line.move_id.period_id.id else: - ctx['period_id'] = line.period_id.id - #Check for centralisation + ctx['period_id'] = line.period_id.id + #Check for centralisation journal = self.pool.get('account.journal').browse(cr, uid, ctx['journal_id'], context=ctx) if journal.centralisation: self._check_moves(cr, uid, context=ctx) diff --git a/addons/account/account_report.xml b/addons/account/account_report.xml index 656d9d2f595..6480178d1ae 100644 --- a/addons/account/account_report.xml +++ b/addons/account/account_report.xml @@ -23,7 +23,7 @@ - + - + - + - + - + + Journal Entries @@ -1030,7 +1030,7 @@ - + Journal Items account.move @@ -1042,7 +1042,7 @@ - + Transaction Journals account.move @@ -1097,8 +1097,8 @@ - - + + + string="Budget"/> diff --git a/addons/account_budget/crossovered_budget_view.xml b/addons/account_budget/crossovered_budget_view.xml index b48ccc55daa..e7a0faf069d 100644 --- a/addons/account_budget/crossovered_budget_view.xml +++ b/addons/account_budget/crossovered_budget_view.xml @@ -185,8 +185,8 @@ - - + + diff --git a/addons/account_budget/test/account_budget.yml b/addons/account_budget/test/account_budget.yml new file mode 100644 index 00000000000..f77efa23b15 --- /dev/null +++ b/addons/account_budget/test/account_budget.yml @@ -0,0 +1,71 @@ +- + In order to check account budget module in OpenERP I created a budget with few budget position +- + Creating a crossovered.budget record +- + !record {model: crossovered.budget, id: crossovered_budget_budget0}: + code: B2011 + date_from: '2011-01-01' + date_to: '2011-12-31' + name: Budget 2011 + state: draft +- + I created two different budget lines +- + Modifying a crossovered.budget record +- + !record {model: crossovered.budget, id: crossovered_budget_budget0}: + crossovered_budget_line: + - analytic_account_id: account.analytic_consultancy + date_from: '2011-01-01' + date_to: '2011-12-31' + general_budget_id: account_budget.account_budget_post_purchase0 + planned_amount: 10000.0 + - analytic_account_id: account.analytic_super_product_trainings + date_from: '2011-09-01' + date_to: '2011-09-30' + general_budget_id: account_budget.account_budget_post_sales0 + planned_amount: 400000.0 + +- + I check that Initially Budget is in "draft" state +- + !assert {model: crossovered.budget, id: crossovered_budget_budget0}: + - state == 'draft' + +- + I pressed the confirm button to confirm the Budget +- + Performing a workflow action confirm on module crossovered.budget +- + !workflow {model: crossovered.budget, action: confirm, ref: crossovered_budget_budget0} +- + I check that budget is in "Confirmed" state +- + !assert {model: crossovered.budget, id: crossovered_budget_budget0}: + - state == 'confirm' + +- + I pressed the validate button to validate the Budget +- + Performing a workflow action validate on module crossovered.budget +- + !workflow {model: crossovered.budget, action: validate, ref: crossovered_budget_budget0} +- + I check that budget is in "Validated" state +- + !assert {model: crossovered.budget, id: crossovered_budget_budget0}: + - state == 'validate' + +- + I pressed the done button to done the Budget +- + Performing a workflow action done on module crossovered.budget +- + !workflow {model: crossovered.budget, action: done, ref: crossovered_budget_budget0} +- + I check that budget is in "done" state +- + !assert {model: crossovered.budget, id: crossovered_budget_budget0}: + - state == 'done' + diff --git a/addons/account_budget/test/account_budget_spread.yml b/addons/account_budget/test/account_budget_spread.yml new file mode 100644 index 00000000000..98d85222859 --- /dev/null +++ b/addons/account_budget/test/account_budget_spread.yml @@ -0,0 +1,19 @@ +- + In order to test Spread Wizard of account module I spread record with amount=1000 +- + Creating a account.budget.spread record +- + !record {model: account.budget.spread, id: account_budget_spread_0}: + amount: 1000.0 + fiscalyear: account.data_fiscalyear + + +- + Performing an osv_memory action check_spread on module account.budget.spread +- + !python {model: account.budget.spread}: | + self.check_spread(cr, uid, [ref("account_budget_spread_0")], {"lang": 'en_US', + "active_model": "account.budget.post", "active_ids": [ref("account_budget.account_budget_post_sales0")], + "tz": False, "active_id": ref("account_budget.account_budget_post_sales0"), + }) + diff --git a/addons/account_budget/wizard/account_budget_spread_view.xml b/addons/account_budget/wizard/account_budget_spread_view.xml index 10ac28566f7..21cf6551452 100644 --- a/addons/account_budget/wizard/account_budget_spread_view.xml +++ b/addons/account_budget/wizard/account_budget_spread_view.xml @@ -10,6 +10,7 @@
+