diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 9213183f7f1..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,6 +125,7 @@ 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', diff --git a/addons/account/account.py b/addons/account/account.py index cf50946d516..a6e3c09884a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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) @@ -557,42 +562,46 @@ class account_journal(osv.osv): _name = "account.journal" _description = "Journal" _columns = { - 'name': fields.char('Journal Name', size=64, required=True, translate=True), - 'code': fields.char('Code', size=16), - 'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, + 'name': fields.char('Journal Name', size=64, required=True, translate=True,help="Name of the journal"), + 'code': fields.char('Code', size=16,required=True,help="Code of the journal"), + 'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'),('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, help="Select 'Sale' for Sale journal to be used at the time of making invoice."\ " Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\ " Select 'Cash' to be used at the time of making payment."\ " Select 'General' to be used at the time of stock input/output."\ " Select 'Situation' to be used at the time of making vouchers."), 'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'), - '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')]), - - 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the journal without removing it."), - 'view_id': fields.many2one('account.journal.view', 'View', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP 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')]"), - 'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]"), + '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 Open ERP 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."), - 'update_posted': fields.boolean('Allow Cancelling Entries'), + 'update_posted': fields.boolean('Allow Cancelling Entries',help="Check this box if you want to cancel the entries related to this journal or want to cancel the invoice related to this journal"), 'group_invoice_lines': fields.boolean('Group invoice lines', help="If this box is checked, the system will try to group the accounting lines when generating them from invoices."), 'sequence_id': fields.many2one('ir.sequence', 'Entry Sequence', help="The sequence gives the display order for a list of journals", required=True), 'user_id': fields.many2one('res.users', 'User', help="The user responsible for this journal"), 'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'), 'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'), 'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'), - 'company_id': fields.many2one('res.company', 'Company', required=True,select=1), + 'company_id': fields.many2one('res.company', 'Company', required=True,select=1,help="Company associated with a journal"), 'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \ help="The sequence used for invoice numbers in this journal."), 'allow_date':fields.boolean('Check Date not in the Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'), } _defaults = { - 'active': lambda *a: 1, '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_journal, 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 @@ -618,6 +627,16 @@ class account_journal(osv.osv): ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context) return self.name_get(cr, user, ids, context=context) + def onchange_type(self, cr, uid, ids, type): + res={} + for line in self.browse(cr, uid, ids): + if type == 'situation': + res= {'value':{'centralisation': True}} + else: + res= {'value':{'centralisation': False}} + return res + + account_journal() class account_fiscalyear(osv.osv): @@ -711,7 +730,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 +803,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 +836,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 51a020b9b75..6c031955cc9 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -220,7 +220,8 @@ - + + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 7350596c4e3..84dd2c90e7c 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 company_list and not line.company_id.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.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 company_list and not line.company_id.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.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_view.xml b/addons/account/account_view.xml index f4afa62b2b3..94fd5c664ed 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -272,22 +272,19 @@ - - + - - + - + - @@ -296,7 +293,7 @@ - + @@ -307,15 +304,19 @@ + - - - + + + + + + - + @@ -957,7 +958,6 @@