From 5128b93091c78c5adf10c57742136f4a5dfd993a Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Wed, 7 Mar 2012 18:13:01 +0530 Subject: [PATCH] [ADD] account: Added config files. bzr revid: uco@tinyerp.com-20120307124301-ey6qvcafb3uibuqy --- addons/account/__init__.py | 1 + addons/account/__openerp__.py | 3 +- addons/account/res_config.py | 126 +++++++++++++++++++ addons/account/res_config_view.xml | 110 ++++++++++++++++ addons/account/security/account_security.xml | 24 ++++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 addons/account/res_config.py create mode 100644 addons/account/res_config_view.xml diff --git a/addons/account/__init__.py b/addons/account/__init__.py index 98f7a7d5134..726eab3680c 100644 --- a/addons/account/__init__.py +++ b/addons/account/__init__.py @@ -37,4 +37,5 @@ import ir_sequence import company import res_currency import edi +import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 850a8f49842..0a5f4aeac5d 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -125,7 +125,8 @@ module named account_voucher. 'board_account_view.xml', "edi/invoice_action_data.xml", "account_bank_view.xml", - "account_pre_install.yml" + "account_pre_install.yml", + "res_config_view.xml", ], 'demo_xml': [ 'demo/account_demo.xml', diff --git a/addons/account/res_config.py b/addons/account/res_config.py new file mode 100644 index 00000000000..35a6802f1b1 --- /dev/null +++ b/addons/account/res_config.py @@ -0,0 +1,126 @@ +# -*- 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 . +# +############################################################################## + +from operator import itemgetter + +from osv import fields, osv +from tools.translate import _ + +class account_configuration(osv.osv_memory): + _inherit = 'res.config.settings' + + def _get_charts(self, cr, uid, context=None): + modules = self.pool.get('ir.module.module') + # Looking for the module with the 'Account Charts' category + category_name, category_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'module_category_localization_account_charts') + ids = modules.search(cr, uid, [('category_id', '=', category_id)], context=context) + charts = list( + sorted(((m.name, m.shortdesc) + for m in modules.browse(cr, uid, ids, context=context)), + key=itemgetter(1))) + charts.insert(0, ('configurable', 'Generic Chart Of Accounts')) + return charts + + _columns = { + 'company_id': fields.many2one('res.company', 'Company'), + 'currency_id': fields.many2one('res.currency','Main Currency'), + 'sale_tax': fields.float('Default Sale Tax'), + 'purchase_tax': fields.float('Default Purchase Tax'), + 'charts': fields.selection(_get_charts, 'Chart of Accounts', + required=True, + help="Installs localized accounting charts to match as closely as " + "possible the accounting needs of your company based on your " + "country."), + 'chart_template_id': fields.many2one('account.chart.template', 'Chart Template'), + 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year'), + 'paypal_account': fields.char("Your Paypal Account", size=128, help="Paypal username (usually email) for receiving online payments."), + 'company_footer': fields.char("Footer of Reports", size=128), + 'customer_invoice_sequence_prefix': fields.char('Invoice Sequence', size=64), + 'customer_invoice_sequence_padding': fields.integer('Invoice Sequence Padding'), + 'customer_refund_sequence_prefix': fields.char('Refund Sequence', size=64), + 'customer_refund_sequence_padding': fields.integer('Refund Sequence Padding'), + 'supplier_invoice_sequence_prefix': fields.char('Supplier Invoice Sequence', size=64), + 'supplier_invoice_sequence_padding': fields.integer('Supplier Invoice Sequence Padding'), + 'supplier_refund_sequence_prefix': fields.char('Supplier Refund Sequence', size=64), + 'supplier_refund_sequence_padding': fields.integer('Supplier Refund Sequence Padding'), + + 'module_account_check_writing': fields.boolean('Support check writings'), + 'module_account_accountant': fields.boolean('Accountant Features'), + 'module_account_asset': fields.boolean('Assets Management'), + 'module_account_budget': fields.boolean('Budgets Management'), + 'module_account_payment': fields.boolean('Supplier Payment Orders'), + 'module_account_voucher': fields.boolean('Manage Customer Payments'), + 'module_account_followup': fields.boolean('Customer Follow-Ups'), + 'module_account_analytic_plans': fields.boolean('Support Multiple Analytic Plans'), + 'module_account_analytic_default': fields.boolean('Rules for Analytic Assignation'), + 'module_account_invoice_layout': fields.boolean('Allow notes and subtotals'), + + 'group_analytic_account_for_sales': fields.boolean('Analytic Accounting for Sales'), + 'group_analytic_account_for_purchase': fields.boolean('Analytic Accounting for Purchase'), + 'group_dates_periods': fields.boolean('Allow dates/periods'), + 'group_proforma_invoices': fields.boolean('Allow Pro-forma Invoices'), + } + + _defaults = { + 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.account', context=c), + 'currency_id': lambda s, cr, uid, c: s.pool.get('res.currency').search(cr, uid, [])[0], + 'charts': 'configurable', + } + + def _check_default_tax(self, cr, uid, context=None): + ir_values_obj = self.pool.get('ir.values') + taxes = {} + for tax in ir_values_obj.get(cr, uid, 'default', False, ['product.product']): + if tax[1] == 'taxes_id': + taxes.update({'taxes_id': tax[2]}) + if tax[1] == 'supplier_taxes_id': + taxes.update({'supplier_taxes_id': tax[2]}) + return taxes + return False + + def default_get(self, cr, uid, fields_list, context=None): + ir_values_obj = self.pool.get('ir.values') + chart_template_obj = self.pool.get('account.chart.template') + res = super(account_configuration, self).default_get(cr, uid, fields_list, context=context) + res.update({'sale_tax': 15.0, 'purchase_tax': 15.0}) + taxes = self._check_default_tax(cr, uid, context) + chart_template_ids = chart_template_obj.search(cr, uid, [('visible', '=', True)], context=context) + if chart_template_ids: + res.update({'chart_template_id': chart_template_ids[0]}) + if taxes: + sale_tax_id = taxes.get('taxes_id') + res.update({'sale_tax': sale_tax_id and sale_tax_id[0]}) + purchase_tax_id = taxes.get('supplier_taxes_id') + res.update({'purchase_tax': purchase_tax_id and purchase_tax_id[0]}) + return res + + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + ir_values_obj = self.pool.get('ir.values') + res = super(account_configuration, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu) + if self._check_default_tax(cr, uid, context) and taxes: + if res['fields'].get('sale_tax') and res['fields'].get('purchase_tax'): + res['fields']['sale_tax'] = {'domain': [], 'views': {}, 'context': {}, 'selectable': True, 'type': 'many2one', 'relation': 'account.tax', 'string': 'Default Sale Tax'} + res['fields']['purchase_tax'] = {'domain': [], 'views': {}, 'context': {}, 'selectable': True, 'type': 'many2one', 'relation': 'account.tax', 'string': 'Default Purchase Tax'} + return res + +account_configuration() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/res_config_view.xml b/addons/account/res_config_view.xml new file mode 100644 index 00000000000..9ce69248d06 --- /dev/null +++ b/addons/account/res_config_view.xml @@ -0,0 +1,110 @@ + + + + + + Accounting Application + res.config.settings + form + + +
+ + + +