diff --git a/addons/account/__init__.py b/addons/account/__init__.py index 9cbc57bbdc9..8e83d9aa7a7 100644 --- a/addons/account/__init__.py +++ b/addons/account/__init__.py @@ -32,5 +32,6 @@ import report import product import sequence import company + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index cea696f590f..51724f47d33 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -121,6 +121,10 @@ module named account_voucherss 'demo/account_minimal.xml', 'account_unit_test.xml', ], + 'test': [ + 'test/account_customer_invoice.yml', + 'test/account_supplier_invoice.yml', + ], 'installable': True, 'active': False, 'certificate': '0080331923549', diff --git a/addons/account/account.py b/addons/account/account.py index 5181028c17b..3fb74401946 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -124,10 +124,10 @@ class account_account_type(osv.osv): 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows you to change the sign of the balance amount displayed in the reports, so that you can see positive figures instead of negative ones in expenses accounts.'), 'report_type':fields.selection([ ('none','/'), - ('income','Profilt & Loss (Income Accounts)'), - ('expanse','Profilt & Loss (Expanse Accounts)'), + ('income','Profit & Loss (Income Accounts)'), + ('expense','Profit & Loss (Expense Accounts)'), ('asset','Balance Sheet (Assets Accounts)'), - ('liabilities','Balance Sheet (Liabilities Accounts)') + ('liability','Balance Sheet (Liability Accounts)') ],'Type Heads', select=True, readonly=False, help="According value related accounts will be display on respective reports (Balance Sheet Profit & Loss Account)"), 'parent_id':fields.many2one('account.account.type', 'Parent Type', required=False), 'child_ids':fields.one2many('account.account.type', 'parent_id', 'Child Types', required=False), @@ -171,6 +171,19 @@ class account_account(osv.osv): _description = "Account" _parent_store = True + def _get_children_and_consol(self, cr, uid, ids, context={}): + ids2=[] + temp=[] + read_data= self.read(cr, uid, ids,['id','child_id'], context) + for data in read_data: + ids2.append(data['id']) + if data['child_id']: + temp=[] + for x in data['child_id']: + temp.append(x) + ids2 += self._get_children_and_consol(cr, uid, temp, context) + return ids2 + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: @@ -297,6 +310,17 @@ class account_account(osv.osv): return result + def _get_level(self, cr, uid, ids, field_name, arg, context={}): + res={} + accounts = self.browse(cr, uid, ids) + for account in accounts: + level = 0 + if account.parent_id : + obj = self.browse(cr, uid, account.parent_id.id) + level = obj.level + 1 + res[account.id] = level + return res + _columns = { 'name': fields.char('Name', size=128, required=True, select=True), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."), @@ -343,6 +367,7 @@ class account_account(osv.osv): 'check_history': fields.boolean('Display History', help="Check this box if you want to print all entries when printing the General Ledger, "\ "otherwise it will only print its balance."), + 'level': fields.function(_get_level, string='Level', method=True, store=True, type='integer'), } def _default_company(self, cr, uid, context={}): @@ -534,7 +559,7 @@ class account_journal(osv.osv): _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'), ('cash', 'Cash'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, + 'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expanse', 'Expanse'), ('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."\ @@ -892,7 +917,7 @@ class account_move(osv.osv): 'to_check': fields.boolean('To Be Verified'), 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner"), 'amount': fields.function(_amount_compute, method=True, string='Amount', digits_compute=dp.get_precision('Account'), type='float', fnct_search=_search_amount), - 'date': fields.date('Date', required=True), + 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}), 'type': fields.selection([ ('pay_voucher','Cash Payment'), ('bank_pay_voucher','Bank Payment'), @@ -902,7 +927,7 @@ class account_move(osv.osv): ('journal_sale_vou','Journal Sale'), ('journal_pur_voucher','Journal Purchase'), ('journal_voucher','Journal Voucher'), - ],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}), + ],'Entry Type', select=True , size=128, readonly=True, states={'draft':[('readonly',False)]}), 'narration':fields.text('Narration', readonly=True, select=True, states={'draft':[('readonly',False)]}), 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company',store=True), } @@ -1416,7 +1441,6 @@ class account_tax(osv.osv): 'include_base_amount': fields.boolean('Included in base amount', help="Indicates if the amount of tax must be included in the base amount for the computation of the next taxes"), 'company_id': fields.many2one('res.company', 'Company', required=True), 'description': fields.char('Tax Code',size=32), - 'price_include': fields.boolean('Tax Included in Price', help="Check this if the price you use on the product and invoices includes this tax."), 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Application', required=True) } @@ -1449,7 +1473,6 @@ class account_tax(osv.osv): 'applicable_type': lambda *a: 'true', 'type': lambda *a: 'percent', 'amount': lambda *a: 0, - 'price_include': lambda *a: 0, 'active': lambda *a: 1, 'type_tax_use': lambda *a: 'all', 'sequence': lambda *a: 1, diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index ba33185119e..d02dec33af0 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # 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 . +# along with this program. If not, see . # ############################################################################## @@ -43,22 +43,22 @@ class account_analytic_line(osv.osv): _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d'), 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), - } + } _order = 'date' - + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: context = {} if context.get('from_date',False): args.append(['date', '>=',context['from_date']]) - + if context.get('to_date',False): args.append(['date','<=',context['to_date']]) - + return super(account_analytic_line, self).search(cr, uid, args, offset, limit, order, context=context, count=count) - + def _check_company(self, cr, uid, ids): lines = self.browse(cr, uid, ids) for l in lines: @@ -68,7 +68,7 @@ class account_analytic_line(osv.osv): _constraints = [ # (_check_company, 'You can not create analytic line that is not in the same company than the account line', ['account_id']) ] - + # Compute the cost based on the price type define into company # property_valuation_price_type property def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, @@ -90,7 +90,7 @@ class account_analytic_line(osv.osv): (prod.name, prod.id,)) if not company_id: company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) - + # Compute based on pricetype pricetype=self.pool.get('product.price.type').browse(cr,uid,company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) # Take the company currency as the reference one @@ -164,10 +164,10 @@ timesheet_invoice() class res_partner(osv.osv): """ Inherits partner and adds contract information in the partner form """ _inherit = 'res.partner' - + _columns = { 'contract_ids': fields.one2many('account.analytic.account', \ - 'partner_id', 'Contracts', readonly=True), + 'partner_id', 'Contracts', readonly=True), } res_partner() diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index ac11b019ec2..77369bdca25 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -141,11 +141,12 @@ 2
- + - + +