From 06e635e61ecb03a1aa4f80debe8ee708cb3a52c8 Mon Sep 17 00:00:00 2001
From: "PAP(OpenERP)" <>
Date: Mon, 16 Aug 2010 16:48:33 +0530
Subject: [PATCH] [IMP] Account: Generic Chart Of Account modify and misc
changes
bzr revid: mra@mra-laptop-20100816111833-n5eornoi3rhwks4f
---
addons/account/__openerp__.py | 2 -
addons/account/data/account_data2.xml | 25 ++++
addons/account/installer.py | 77 ++++++++++-
addons/account/report/__init__.py | 3 +-
.../account/report/account_account_report.py | 86 ------------
.../report/account_account_report_view.xml | 94 -------------
.../account/report/account_analytic_report.py | 94 -------------
.../report/account_analytic_report_view.xml | 128 ------------------
addons/account/security/ir.model.access.csv | 2 -
9 files changed, 96 insertions(+), 415 deletions(-)
delete mode 100644 addons/account/report/account_account_report.py
delete mode 100644 addons/account/report/account_account_report_view.xml
delete mode 100644 addons/account/report/account_analytic_report.py
delete mode 100644 addons/account/report/account_analytic_report_view.xml
diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py
index 5ba019b5621..f06123487e2 100644
--- a/addons/account/__openerp__.py
+++ b/addons/account/__openerp__.py
@@ -114,8 +114,6 @@ module named account_voucher.
'report/account_invoice_report_view.xml',
'report/account_entries_report_view.xml',
'report/account_report_view.xml',
- 'report/account_analytic_report_view.xml',
- 'report/account_account_report_view.xml',
'report/account_analytic_entries_report_view.xml',
'board_account_view.xml',
"wizard/account_report_profit_loss_view.xml",
diff --git a/addons/account/data/account_data2.xml b/addons/account/data/account_data2.xml
index 9a06727e021..af55e477b42 100644
--- a/addons/account/data/account_data2.xml
+++ b/addons/account/data/account_data2.xml
@@ -86,6 +86,12 @@
state
+
+
+ Reconcile
+ reconcile_id
+
+
Bank/Cash Journal (Multi-Currency) View
@@ -166,6 +172,12 @@
state
+
+
+ Reconcile
+ reconcile_id
+
+
@@ -328,6 +340,12 @@
state
+
+
+ Reconcile
+ reconcile_id
+
+
Sale/Purchase Refund Journal View
@@ -420,6 +438,13 @@
state
+
+
+ Reconcile
+ reconcile_id
+
+
+
diff --git a/addons/account/installer.py b/addons/account/installer.py
index c072375aa99..4843f54187c 100644
--- a/addons/account/installer.py
+++ b/addons/account/installer.py
@@ -219,10 +219,12 @@ class account_installer(osv.osv_memory):
vals_seq = {
'name': _('Bank Journal '),
'code': 'account.journal',
+ 'prefix': 'BAN/',
+ 'padding': 5
}
seq_id = obj_sequence.create(cr,uid,vals_seq)
- #create the bank journal
+ #create the bank journals
vals_journal = {}
vals_journal['name']= _('Bank Journal ')
vals_journal['code']= _('BNK')
@@ -238,9 +240,21 @@ class account_installer(osv.osv_memory):
obj_journal.create(cr,uid,vals_journal)
for val in record.bank_accounts_id:
- if val.account_type == 'cash':type = cash_type_id
- elif val.account_type == 'bank':type = bank_type_id
- else:type = check_type_id
+ seq_prefix = None
+ seq_padding = 5
+ if val.account_type == 'cash':
+ type = cash_type_id
+ seq_prefix = "CSH/"
+ elif val.account_type == 'bank':
+ type = bank_type_id
+ seq_prefix = "BAN/"
+ elif val.account_type == 'check':
+ type = check_type_id
+ seq_prefix = "CHK/"
+ else:
+ type = check_type_id
+ seq_padding = None
+
vals_bnk = {'name': val.acc_name or '',
'currency_id': val.currency_id.id or False,
'code': str(110400 + code_cnt),
@@ -252,6 +266,8 @@ class account_installer(osv.osv_memory):
vals_seq_child = {
'name': _(vals_bnk['name']),
'code': 'account.journal',
+ 'prefix': seq_prefix,
+ 'padding': seq_padding
}
seq_id = obj_sequence.create(cr, uid, vals_seq_child)
@@ -272,7 +288,7 @@ class account_installer(osv.osv_memory):
code_cnt += 1
- #reactivate the parent_store functionnality on account_account
+ #reactivate the parent_store functionality on account_account
self.pool._init = False
self.pool.get('account.account')._parent_store_compute(cr)
@@ -292,8 +308,20 @@ class account_installer(osv.osv_memory):
seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0]
if seq_journal:
- seq_id_sale = obj_sequence.search(cr,uid,[('name','=','Sale Journal')])[0]
- seq_id_purchase = obj_sequence.search(cr,uid,[('name','=','Purchase Journal')])[0]
+ seq_sale = {
+ 'name': 'Sale Journal',
+ 'code': 'account.journal',
+ 'prefix': 'INV/',
+ 'padding': 4
+ }
+ seq_id_sale = obj_sequence.create(cr, uid, seq_sale)
+ seq_purchase = {
+ 'name': 'Purchase Journal',
+ 'code': 'account.journal',
+ 'prefix': 'VEN/',
+ 'padding': 4
+ }
+ seq_id_purchase = obj_sequence.create(cr, uid, seq_purchase)
else:
seq_id_sale = seq_id
seq_id_purchase = seq_id
@@ -323,7 +351,42 @@ class account_installer(osv.osv_memory):
vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id]
obj_journal.create(cr,uid,vals_journal)
+
+ # Creating Journals Sales Refund and Purchase Refund
+ vals_journal={}
+ data_id = mod_obj.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_refund_journal_view')])
+ data = mod_obj.browse(cr, uid, data_id[0])
+ view_id = data.res_id
+ seq_id_sale_refund = seq_id_sale
+ seq_id_purchase_refund = seq_id_purchase
+
+ vals_journal['view_id'] = view_id
+
+ #Sales Refund Journal
+ vals_journal['name'] = _('Sales Refund Journal')
+ vals_journal['type'] = 'sale_refund'
+ vals_journal['code'] = _('SCNJ')
+ vals_journal['sequence_id'] = seq_id_sale_refund
+
+ if obj_multi.property_account_receivable:
+ vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id]
+ vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_income_categ.id]
+
+ obj_journal.create(cr,uid,vals_journal)
+
+ # Purchase Refund Journal
+ vals_journal['name'] = _('Purchase Refund Journal')
+ vals_journal['type'] = 'purchase_refund'
+ vals_journal['code'] = _('ECNJ')
+ vals_journal['sequence_id'] = seq_id_purchase_refund
+
+ if obj_multi.property_account_payable:
+ vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id]
+ vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.property_account_expense_categ.id]
+
+ obj_journal.create(cr,uid,vals_journal)
+
# Bank Journals
view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Bank/Cash Journal View')])[0] #TOFIX: Why put fixed name ?
view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Bank/Cash Journal (Multi-Currency) View')])[0] #TOFIX: why put fixed name?
diff --git a/addons/account/report/__init__.py b/addons/account/report/__init__.py
index 7c908570c2a..15569278e71 100644
--- a/addons/account/report/__init__.py
+++ b/addons/account/report/__init__.py
@@ -35,12 +35,11 @@ import account_balance_landscape
import compare_account_balance
import account_invoice_report
import account_report
-import account_analytic_report
-import account_account_report
import account_entries_report
import account_analytic_entries_report
import voucher_print
import account_balance_sheet
import account_profit_loss
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/report/account_account_report.py b/addons/account/report/account_account_report.py
deleted file mode 100644
index b396521e45c..00000000000
--- a/addons/account/report/account_account_report.py
+++ /dev/null
@@ -1,86 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import tools
-from osv import fields,osv
-
-class account_account_report(osv.osv):
- _name = "account.account.report"
- _description = "Account Report"
- _auto = False
- _columns = {
- 'name': fields.char('Name', size=128, readonly=True),
- 'code': fields.char('Code', size=64, readonly=True),
- 'type': fields.selection([
- ('receivable', 'Receivable'),
- ('payable', 'Payable'),
- ('view', 'View'),
- ('consolidation', 'Consolidation'),
- ('other', 'Others'),
- ('closed', 'Closed'),
- ], 'Internal Type', readonly=True),
- 'company_id': fields.many2one('res.company', 'Company', required=True),
- 'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate', readonly=True),
- 'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True),
- 'quantity': fields.float('Quantity', readonly=True),
- 'amount_total': fields.float('Total Amount', readonly=True),
- 'credit': fields.float('Credit', readonly=True),
- 'debit': fields.float('Debit', readonly=True),
- 'balance': fields.float('Balance', readonly=True),
- 'nbr': fields.integer('#Accounts', readonly=True),
- 'parent_account_id': fields.many2one('account.account', 'Parent Account', required=True),
- }
- def init(self, cr):
- tools.drop_view_if_exists(cr, 'account_account_report')
- cr.execute("""
- create or replace view account_account_report as (
- select
- min(a.id) as id,
- count(distinct a.id) as nbr,
- a.name,
- a.code,
- a.type as type,
- a.company_id as company_id,
- a.currency_mode as currency_mode,
- a.user_type as user_type,
- a.parent_id as parent_account_id,
- sum(ail.quantity) as quantity,
- sum(ail.price_subtotal) as amount_total,
- sum(m.credit) as credit,
- sum(m.debit) as debit,
- (sum(m.credit)-sum(m.debit)) as balance
- from
- account_account as a
- left join account_move_line as m on m.account_id=a.id
- left join account_invoice_line as ail on ail.account_id=a.id
- left join account_invoice as ai on ai.account_id=a.id
- group by
- a.name,
- a.code,
- a.type,
- a.company_id,
- a.currency_mode,
- a.user_type,
- m.account_id,
- a.parent_id
- )
- """)
-account_account_report()
diff --git a/addons/account/report/account_account_report_view.xml b/addons/account/report/account_account_report_view.xml
deleted file mode 100644
index 521fe37ff4b..00000000000
--- a/addons/account/report/account_account_report_view.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
- account.account.report.tree
- account.account.report
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.account.report.graph
- account.account.report
- graph
-
-
-
-
-
-
-
-
-
-
-
- account.account.report.search
- account.account.report
- search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Accounts Analysis
- account.account.report
- form
- tree,graph
- {"search_default_Account":1,"search_default_At Date":1,'group_by_no_leaf':1,'group_by':[]}
-
-
-
-
-
-
-
diff --git a/addons/account/report/account_analytic_report.py b/addons/account/report/account_analytic_report.py
deleted file mode 100644
index a740076ad09..00000000000
--- a/addons/account/report/account_analytic_report.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import tools
-from osv import fields,osv
-
-class analytic_report(osv.osv):
- _name = "analytic.report"
- _description = "Analytic Accounts Statistics"
- _auto = False
- _columns = {
- 'date_start': fields.date('Date Start', readonly=True),
- 'date_end': fields.date('Date End', readonly=True),
- 'name' : fields.char('Analytic Account', size=128, readonly=True),
- 'partner_id' : fields.many2one('res.partner', 'Associated Partner', readonly=True),
- 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', readonly=True),
- 'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', readonly=True),
- 'user_id' : fields.many2one('res.users', 'Account Manager', readonly=True),
- 'product_id' : fields.many2one('product.product', 'Product', readonly=True),
- 'total_quantity': fields.float('# Total Quantity', readonly=True),
- 'debit' : fields.float('Debit', readonly=True),
- 'credit' : fields.float('Credit', readonly=True),
- 'balance' : fields.float('Balance', readonly=True),
- 'year': fields.char('Year', size=4, readonly=True),
- 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
- ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
- ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
- 'day': fields.char('Day', size=128, readonly=True),
- 'nbr':fields.integer('# of Lines', readonly=True),
- 'company_id': fields.many2one('res.company', 'Company', readonly=True),
- 'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type'),
-
- 'state': fields.selection([('draft','Draft'),
- ('open','Open'),
- ('pending','Pending'),
- ('cancelled', 'Cancelled'),
- ('close','Close'),
- ('template', 'Template')],
- 'State', readonly=True),
-
- }
- _order = 'date_start desc'
- def init(self, cr):
- tools.drop_view_if_exists(cr, 'analytic_report')
- cr.execute("""
- create or replace view analytic_report as (
- select
- min(s.id) as id,
- to_char(s.create_date, 'YYYY') as year,
- to_char(s.create_date, 'MM') as month,
- to_char(s.create_date, 'YYYY-MM-DD') as day,
- l.journal_id,
- l.product_id,
- s.parent_id,
- s.date_start,
- s.date as date_end,
- s.user_id,
- s.company_id,
- s.type,
- s.name,
- s.partner_id,
- sum(s.quantity) as total_quantity,
- s.debit,
- s.credit,
- s.balance,
- count(*) as nbr,
- s.state
- from account_analytic_account s
- left join account_analytic_line l on (s.id=l.account_id)
- GROUP BY s.create_date,s.state,l.journal_id,s.name,
- s.partner_id,s.date_start,s.date,s.user_id,
- s.company_id,s.type,
- s.debit,s.credit,s.balance,s.parent_id,l.product_id
- )
- """)
-analytic_report()
diff --git a/addons/account/report/account_analytic_report_view.xml b/addons/account/report/account_analytic_report_view.xml
deleted file mode 100644
index cb7318fe3e4..00000000000
--- a/addons/account/report/account_analytic_report_view.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-
- analytic.report.tree
- analytic.report
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- analytic.report.search
- analytic.report
- search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.analytic.report.graph
- analytic.report
- graph
-
-
-
-
-
-
-
-
-
-
-
- Analytic Accounts Analysis
- analytic.report
- form
- tree,graph
- {'search_default_This Month':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}
-
-
-
-
-
-
diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv
index 890d4f505ea..0c949d00430 100644
--- a/addons/account/security/ir.model.access.csv
+++ b/addons/account/security/ir.model.access.csv
@@ -88,7 +88,6 @@
"access_report_account_type_sales","report.account_type.sales","model_report_account_type_sales","account.group_account_manager",1,0,0,0
"access_report_account_sales","report.account.sales","model_report_account_sales","account.group_account_manager",1,0,0,0
"access_account_invoice_report","account.invoice.report","model_account_invoice_report","account.group_account_manager",1,1,1,1
-"access_account_account_report_manager","account.account.report","model_account_account_report","account.group_account_manager",1,0,0,0
"access_res_partner_group_account_manager","res_partner group_account_manager","model_res_partner","account.group_account_manager",1,1,1,1
"access_account_invoice_accountant","account.invoice accountant","model_account_invoice","account.group_account_user",1,0,0,0
"access_account_tax_code_accountant","account.tax.code accountant","model_account_tax_code","account.group_account_user",1,1,1,1
@@ -149,7 +148,6 @@
"access_account_invoice_line_accountant","account.invoice.line accountant","model_account_invoice_line","account.group_account_user",1,0,0,0
"access_res_partner_address_accountant","res.partner.address accountant","base.model_res_partner_address","account.group_account_user",1,0,0,0
"access_account_invoice_line_manager","account.invoice.line manager","model_account_invoice_line","account.group_account_manager",1,0,0,0
-"access_analytic_report_manager","analytic.report manager","model_analytic_report","account.group_account_manager",1,1,1,1
"access_account_account_invoice","account.account invoice","model_account_account","account.group_account_invoice",1,1,1,1
"access_res_partner_address_invoice","res.partner.address invoice","base.model_res_partner_address","account.group_account_invoice",1,1,1,1
"access_account_invoice_line_system","account.invoice.line system","model_account_invoice_line","base.group_system",1,0,0,0