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..04a0bb5da68 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={}): @@ -452,7 +477,7 @@ class account_account(osv.osv): def _check_moves(self, cr, uid, ids, method, context): line_obj = self.pool.get('account.move.line') account_ids = self.search(cr, uid, [('id', 'child_of', ids)]) - + if line_obj.search(cr, uid, [('account_id', 'in', account_ids)]): if method == 'write': raise osv.except_osv(_('Error !'), _('You cannot deactivate an account that contains account moves.')) @@ -486,7 +511,7 @@ class account_account(osv.osv): context = {} if 'active' in vals and not vals['active']: self._check_moves(cr, uid, ids, "write", context) - if 'type' in vals.keys(): + 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) @@ -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'), ('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."\ @@ -658,7 +683,7 @@ class account_fiscalyear(osv.osv): else: return False return ids[0] - + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): if args is None: args = [] @@ -670,7 +695,7 @@ class account_fiscalyear(osv.osv): if not ids: ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) return self.name_get(cr, user, ids, context=context) - + account_fiscalyear() class account_period(osv.osv): @@ -746,7 +771,7 @@ class account_period(osv.osv): cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) cr.execute('update account_period set state=%s where id=%s', (mode, id)) return True - + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): if args is None: args = [] @@ -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), } @@ -1350,7 +1375,7 @@ class account_tax_code(osv.osv): return False level -= 1 return True - + def copy(self, cr, uid, id, default=None, context=None): if default is None: @@ -1358,7 +1383,7 @@ class account_tax_code(osv.osv): default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context) - + _constraints = [ (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) ] 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
- + - + +