From 18bcd1c980f3618b744c72c7f6ab6267cd27aaf0 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Fri, 28 Jan 2011 16:28:18 +0530 Subject: [PATCH 01/14] [IMP, ADD] account:Improve the logic to create period so it can create one more period and add two journals for opening entries bzr revid: psi@tinyerp.co.in-20110128105818-ptd5vk4xsaowmnec --- addons/account/account.py | 45 ++++++++++++++++--- addons/account/account_view.xml | 2 + addons/account/configurable_account_chart.xml | 17 +++++++ addons/account/demo/account_minimal.xml | 9 ++++ addons/account/installer.py | 24 ++++++++++ 5 files changed, 90 insertions(+), 7 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 3abbe4cef2e..ada9a12cb4a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -805,19 +805,28 @@ class account_fiscalyear(osv.osv): (_check_fiscal_year, 'Error! You cannot define overlapping fiscal years',['date_start', 'date_stop']) ] - def create_period3(self,cr, uid, ids, context=None): + def create_period3(self, cr, uid, ids, context=None): return self.create_period(cr, uid, ids, context, 3) - def create_period(self,cr, uid, ids, context=None, interval=1): + def create_period(self, cr, uid, ids, context=None, interval=1): + period_obj = self.pool.get('account.period') for fy in self.browse(cr, uid, ids, context=context): ds = datetime.strptime(fy.date_start, '%Y-%m-%d') - while ds.strftime('%Y-%m-%d')fy.date_stop: + if de.strftime('%Y-%m-%d') > fy.date_stop: de = datetime.strptime(fy.date_stop, '%Y-%m-%d') - self.pool.get('account.period').create(cr, uid, { + period_obj.create(cr, uid, { 'name': ds.strftime('%m/%Y'), 'code': ds.strftime('%m/%Y'), 'date_start': ds.strftime('%Y-%m-%d'), @@ -2449,6 +2458,8 @@ class account_chart_template(osv.osv): 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Profit/Loss Account', domain=[('type', '=', 'payable')], help='This Account is used for transferring Profit/Loss(If It is Profit: Amount will be added, Loss: Amount will be deducted.), Which is calculated from Profilt & Loss Report'), + 'property_account_income_opening': fields.many2one('account.account.template','Opening Entries Income Account'), + 'property_account_expense_opening': fields.many2one('account.account.template','Opening Entries Expense Account'), } account_chart_template() @@ -2681,6 +2692,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') + obj_tax_code_template = self.pool.get('account.tax.code.template') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id @@ -2693,9 +2705,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): todo_dict = {} #create all the tax code - children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') + children_tax_code_template = obj_tax_code_template.search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') children_tax_code_template.sort() - for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template, context=context): + for tax_code_template in obj_tax_code_template.browse(cr, uid, children_tax_code_template, context=context): vals={ 'name': (tax_code_root_id == tax_code_template.id) and obj_multi.company_id.name or tax_code_template.name, 'code': tax_code_template.code, @@ -2806,11 +2818,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): seq_id_purchase_refund = obj_sequence.search(cr, uid, [('name','=','Purchase Refund Journal')]) if seq_id_purchase_refund: seq_id_purchase_refund = seq_id_purchase_refund[0] + seq_id_opening = obj_sequence.search(cr, uid, [('name','=','Opening Entries Journal')]) + if seq_id_opening: + seq_id_opening = seq_id_opening[0] else: seq_id_sale = seq_id seq_id_purchase = seq_id seq_id_sale_refund = seq_id seq_id_purchase_refund = seq_id + seq_id_opening = seq_id vals_journal['view_id'] = view_id @@ -2903,6 +2919,21 @@ class wizard_multi_charts_accounts(osv.osv_memory): # }) obj_journal.create(cr, uid, vals_journal, context=context) + # Opening Entries Journal + if obj_multi.chart_template_id.property_account_income_opening and obj_multi.chart_template_id.property_account_expense_opening: + vals_journal = { + 'view_id': view_id, + 'name': _('Opening Entries Journal'), + 'type': 'situation', + 'code': _('TOEJ'), + 'sequence_id': seq_id_opening, + 'analytic_journal_id': analitical_journal_purchase, + 'company_id': company_id, + 'default_credit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_income_opening.id], + 'default_debit_account_id': acc_template_ref[obj_multi.chart_template_id.property_account_expense_opening.id] + } + obj_journal.create(cr, uid, vals_journal, context=context) + # Bank Journals 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) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 1812e800880..cafc99b51de 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2150,6 +2150,8 @@ + + diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index dd9c01142c3..4734e030113 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -191,6 +191,14 @@ + + 1106 + Opening Income Account + + closed + + + 111 Current Liabilities @@ -225,6 +233,13 @@ + + 1114 + Opening Expense Account + + closed + + @@ -431,6 +446,8 @@ + + diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 65184b3d130..6ae6188ec62 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -421,6 +421,15 @@ + + Miscellaneous Journal - (test) + TMIS + general + + + + + @@ -430,7 +446,18 @@ - + + Opening Entries Journal - (test) + TOEJ + situation + + + + + + + + diff --git a/addons/account/installer.py b/addons/account/installer.py index 4a4d945f72b..65d8d7fa99f 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -424,13 +424,21 @@ class account_installer(osv.osv_memory): 'company_id': company_id.id } seq_id_opening = obj_sequence.create(cr, uid, seq_opening_journal, context=context) + seq_miscellaneous_journal = { + 'name': 'Miscellaneous Journal', + 'code': 'account.journal', + 'prefix': 'MISC/%(year)s/', + 'padding': 3, + 'company_id': company_id.id + } + seq_id_miscellaneous = obj_sequence.create(cr, uid, seq_opening_journal, context=context) else: seq_id_sale = seq_id seq_id_purchase = seq_id seq_id_sale_refund = seq_id seq_id_purchase_refund = seq_id seq_id_opening = seq_id - + seq_id_miscellaneous = seq_id vals_journal['view_id'] = view_id #Sales Journal @@ -517,16 +525,31 @@ class account_installer(osv.osv_memory): }) obj_journal.create(cr, uid, vals_journal, context=context) + # Miscellaneous Journal + vals_journal = { + 'view_id': view_id, + 'name': _('Miscellaneous Journal'), + 'type': 'general', + 'refund_journal': True, + 'code': _('MISC'), + 'sequence_id': seq_id_miscellaneous, + 'analytic_journal_id': analitical_journal_purchase, + 'company_id': company_id.id + } + + obj_journal.create(cr, uid, vals_journal, context=context) + # Opening Entries Journal if obj_multi.property_account_income_opening and obj_multi.property_account_expense_opening: vals_journal = { 'view_id': view_id, 'name': _('Opening Entries Journal'), 'type': 'situation', - 'code': _('TOEJ'), + 'code': _('OPEJ'), 'sequence_id': seq_id_opening, 'analytic_journal_id': analitical_journal_purchase, 'company_id': company_id.id, + 'centralisation': True, 'default_credit_account_id': acc_template_ref[obj_multi.property_account_income_opening.id], 'default_debit_account_id': acc_template_ref[obj_multi.property_account_expense_opening.id] } From 145c74b2709696f9964b4ecdda53768947368e09 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 1 Feb 2011 14:07:21 +0100 Subject: [PATCH 03/14] [REVERT] fields: revert previous fix, until tests and addons are checked for compatibility bzr revid: odo@openerp.com-20110201130721-q368qznven3vbmty --- bin/osv/fields.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bin/osv/fields.py b/bin/osv/fields.py index b7874cda8e6..72df0e925ad 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -339,20 +339,6 @@ class many2one(_column): result = {} for id in ids: result[id] = obj.datas[id].get(name, False) - - # build a dictionary of the form {'id_of_distant_resource': name_of_distant_resource} - # we use uid=1 because the visibility of a many2one field value (just id and name) - # must be the access right of the parent form and not the linked object itself. - obj = obj.pool.get(self._obj) - records = dict(obj.name_get(cr, 1, - list(set([x for x in result.values() if x and isinstance(x, (int,long))])), - context=context)) - for id in ids: - if result[id] in records: - result[id] = (result[id], records[result[id]]) - else: - result[id] = False - return result def get(self, cr, obj, ids, name, user=None, context=None, values=None): From daa1b729734666fefb0b615150184ff0bd698b97 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Tue, 1 Feb 2011 17:06:22 +0100 Subject: [PATCH 04/14] [FIX] widget selection replace by m2o because the domain is dynamic bzr revid: tfr@openerp.com-20110201160622-gc75h8fwp0c4vz7o --- addons/project_issue/project_issue_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 0c63698b209..23a361b0ff9 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -58,7 +58,7 @@ - +