diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index a6d2f0c9e69..5ba019b5621 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -39,11 +39,11 @@ The processes like maintaining of general ledger is done through the defined financial Journals (entry move line or grouping is maintained through journal) for a particular financial year and for preparation of vouchers there is a -module named account_vouchers +module named account_voucher. """, - "depends" : ["product", "analytic", "process","board"], 'website': 'http://www.openerp.com', 'init_xml': [], + "depends" : ["product", "analytic", "process","board"], 'update_xml': [ #'test/test_parent_structure.yml', 'security/account_security.xml', @@ -55,6 +55,7 @@ module named account_vouchers 'wizard/account_use_model_view.xml', 'account_view.xml', 'account_report.xml', + 'wizard/account_report_common_view.xml', 'wizard/account_invoice_refund_view.xml', 'wizard/account_period_close_view.xml', 'wizard/account_fiscalyear_close_state.xml', @@ -64,9 +65,9 @@ module named account_vouchers 'wizard/account_open_closed_fiscalyear_view.xml', 'wizard/account_move_line_unreconcile_select_view.xml', 'wizard/account_vat_view.xml', - 'wizard/account_print_journal_view.xml', - 'wizard/account_general_journal_view.xml', - 'wizard/account_central_journal_view.xml', + 'wizard/account_report_print_journal_view.xml', + 'wizard/account_report_general_journal_view.xml', + 'wizard/account_report_central_journal_view.xml', 'wizard/account_subscription_generate_view.xml', 'wizard/account_fiscalyear_close_view.xml', 'wizard/account_state_open_view.xml', @@ -75,14 +76,14 @@ module named account_vouchers 'wizard/account_validate_move_view.xml', 'wizard/account_pay_invoice_view.xml', 'wizard/account_unreconcile_view.xml', - 'wizard/account_general_ledger_report_view.xml', + 'wizard/account_report_general_ledger_view.xml', 'wizard/account_invoice_state_view.xml', - 'wizard/account_partner_balance_report_view.xml', - 'wizard/account_balance_report_view.xml', + 'wizard/account_report_partner_balance_view.xml', + 'wizard/account_report_account_balance_view.xml', # 'wizard/account_move_line_select_view.xml', - 'wizard/account_aged_trial_balance_view.xml', + 'wizard/account_report_aged_partner_balance_view.xml', 'wizard/account_compare_account_balance_report_view.xml', - 'wizard/account_third_party_ledger.xml', + 'wizard/account_report_partner_ledger_view.xml', 'wizard/account_reconcile_view.xml', 'wizard/account_reconcile_partner_process_view.xml', 'wizard/account_automatic_reconcile_view.xml', @@ -113,12 +114,15 @@ module named account_vouchers '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_pl_report_view.xml", - "wizard/account_bs_report_view.xml" + "wizard/account_report_profit_loss_view.xml", + "wizard/account_report_balance_sheet_view.xml" ], 'demo_xml': [ + #'demo/price_accuracy00.yml', 'account_demo.xml', 'project/project_demo.xml', 'project/analytic_account_demo.xml', diff --git a/addons/account/account.py b/addons/account/account.py index 2e7ce17196b..b050f43ad4e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -19,7 +19,7 @@ # ############################################################################## import time -from datetime import datetime +from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta from operator import itemgetter @@ -79,9 +79,19 @@ class account_payment_term(osv.osv): elif line.value == 'balance': amt = round(amount, prec) if amt: - next_date = datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days) + next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days)) if line.days2 < 0: - next_date += relativedelta(day=31) + nyear = next_date.strftime("%Y") + nmonth = str(int(next_date.strftime("%m"))% 12+1) + nday = "1" + + ndate = "%s-%s-%s" % (nyear, nmonth, nday) + nseconds = time.mktime(time.strptime(ndate, '%Y-%m-%d')) + next_month = datetime.fromtimestamp(nseconds) + + delta = timedelta(seconds=1) + next_date = next_month - delta + next_date = next_date + relativedelta(days=line.days2) if line.days2 > 0: next_date += relativedelta(day=line.days2, months=1) result.append( (next_date.strftime('%Y-%m-%d'), amt) ) @@ -372,7 +382,7 @@ class account_account(osv.osv): ('consolidation', 'Consolidation'), ('closed', 'Closed'), ], 'Internal Type', required=True, help="This type is used to differentiate types with "\ - "special effects in Open ERP: view can not have entries, consolidation are accounts that "\ + "special effects in OpenERP: view can not have entries, consolidation are accounts that "\ "can have children accounts for multi-company consolidations, payable/receivable are for "\ "partners accounts (for debit/credit computations), closed for depreciated accounts."), 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, @@ -617,7 +627,7 @@ class account_journal(osv.osv): 'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'), 'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]), 'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]), - 'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."), + 'view_id': fields.many2one('account.journal.view', 'Display Mode', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells OpenERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."), 'default_credit_account_id': fields.many2one('account.account', 'Default Credit Account', domain="[('type','!=','view')]", help="It acts as a default account for credit amount"), 'default_debit_account_id': fields.many2one('account.account', 'Default Debit Account', domain="[('type','!=','view')]", help="It acts as a default account for debit amount"), 'centralisation': fields.boolean('Centralised counterpart', help="Check this box to determine that each entry of this journal won't create a new counterpart but will share the same counterpart. This is used in fiscal year closing."), @@ -860,7 +870,7 @@ class account_period(osv.osv): 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True), 'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True, help='When monthly periods are created. The state is \'Draft\'. At the end of monthly period it is in \'Done\' state.'), - 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company'), + 'company_id': fields.related('fiscalyear_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True) } _defaults = { 'state': lambda *a: 'draft', @@ -1292,11 +1302,10 @@ class account_move(osv.osv): # # Validate a balanced move. If it is a centralised journal, create a move. # - def validate(self, cr, uid, ids, context={}): if context and ('__last_update' in context): del context['__last_update'] - + valid_moves = [] #Maintains a list of moves which can be responsible to create analytic entries for move in self.browse(cr, uid, ids, context): @@ -1332,7 +1341,7 @@ class account_move(osv.osv): valid_moves.append(move) # Check whether the move lines are confirmed - + if not len(line_draft_ids): continue # Update the move lines (set them as valid) @@ -1345,7 +1354,7 @@ class account_move(osv.osv): account = {} account2 = {} - + if journal.type in ('purchase','sale'): for line in move.line_id: code = amount = 0 @@ -1602,8 +1611,8 @@ class account_tax(osv.osv): # # Fields used for the VAT declaration # - 'base_code_id': fields.many2one('account.tax.code', 'Base Code', help="Use this code for the VAT declaration."), - 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="Use this code for the VAT declaration."), + 'base_code_id': fields.many2one('account.tax.code', 'Account Base Code', help="Use this code for the VAT declaration."), + 'tax_code_id': fields.many2one('account.tax.code', 'Account Tax Code', help="Use this code for the VAT declaration."), 'base_sign': fields.float('Base Code Sign', help="Usually 1 or -1."), 'tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), @@ -2146,7 +2155,7 @@ class account_account_template(osv.osv): ('other','Others'), ('closed','Closed'), ], 'Internal Type', required=True,help="This type is used to differentiate types with "\ - "special effects in Open ERP: view can not have entries, consolidation are accounts that "\ + "special effects in OpenERP: view can not have entries, consolidation are accounts that "\ "can have children accounts for multi-company consolidations, payable/receivable are for "\ "partners accounts (for debit/credit computations), closed for depreciated accounts."), 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, @@ -2196,6 +2205,7 @@ class account_add_tmpl_wizard(osv.osv_memory): def _get_def_cparent(self, cr, uid, context): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') + #print "Searching for ",context tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id']) if not tids or not tids[0]['parent_id']: return False @@ -2237,6 +2247,7 @@ class account_add_tmpl_wizard(osv.osv_memory): # 'tax_ids': [(6,0,tax_ids)], todo!! 'company_id': company_id, } + # print "Creating:", vals new_account = acc_obj.create(cr, uid, vals) return {'type':'state', 'state': 'end' } @@ -2257,7 +2268,7 @@ class account_tax_code_template(osv.osv): 'info': fields.text('Description'), 'parent_id': fields.many2one('account.tax.code.template', 'Parent Code', select=True), 'child_ids': fields.one2many('account.tax.code.template', 'parent_id', 'Child Codes'), - 'sign': fields.float('Sign for parent', required=True, help="Choose 1.00 to add the total to the parent account or -1.00 to subtract it"), + 'sign': fields.float('Sign for parent', required=True), 'notprintable':fields.boolean("Not Printable in Invoice", help="Check this box if you don't want any VAT related to this Tax Code to appear on invoices"), } @@ -2289,7 +2300,7 @@ class account_chart_template(osv.osv): _columns={ 'name': fields.char('Name', size=64, required=True), - 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)], help=""), + 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)]), 'tax_code_root_id': fields.many2one('account.tax.code.template','Root Tax Code',required=True,domain=[('parent_id','=',False)]), 'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'), 'bank_account_view_id': fields.many2one('account.account.template','Bank Account',required=True), diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index 2cd1b4d17bd..1792525a7f6 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -20,7 +20,6 @@ ############################################################################## import time -import decimal_precision as dp from osv import fields from osv import osv @@ -94,11 +93,12 @@ class account_analytic_line(osv.osv): # 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 - context['currency_id']=company_obj.browse(cr, uid, company_id).currency_id.id - amount_unit=prod.price_get(pricetype.field, context)[prod.id] - amount=amount_unit*unit_amount or 1.0 + amount_unit = prod.price_get(pricetype.field, context)[prod.id] + amount = amount_unit*unit_amount or 1.0 + prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') + amount = amount_unit*unit_amount or 1.0 return {'value': { - 'amount': - round(amount, 2), + 'amount': - round(amount, prec), 'general_account_id': a, }} return {} diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 58cc997a111..e5912a8b763 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -3,22 +3,22 @@ - - + + - + - - + + - + @@ -35,7 +35,7 @@ + groups="group_account_user,group_account_manager,base.group_system"/> @@ -43,15 +43,15 @@ - + - - diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index a29f32105a5..d3dd4f1ee78 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -20,6 +20,7 @@ ############################################################################## import time from datetime import datetime + import netsvc from osv import fields, osv from tools.translate import _ @@ -35,8 +36,10 @@ class account_move_line(osv.osv): fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] - if not context.get('fiscalyear', False): + if not context.get('fiscalyear', False) and not context.get('empty_fy_allow', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) + elif context.get('empty_fy_allow', False): + fiscalyear_ids = context['fiscalyear'] else: fiscalyear_ids = [context['fiscalyear']] @@ -53,13 +56,19 @@ class account_move_line(osv.osv): if state.lower() not in ['all']: where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')" - if context.get('periods', False): ids = ','.join([str(x) for x in context['periods']]) - query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date) + query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date) else: query = obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date) + if context.get('journal_ids', False): + query += ' AND '+obj+'.journal_id in (%s)' % ','.join(map(str, context['journal_ids'])) + + if context.get('chart_account_id', False): + child_ids = self.pool.get('account.account')._get_children_and_consol(cr, uid, [context['chart_account_id']], context=context) + query += ' AND '+obj+'.account_id in (%s)' % ','.join(map(str, child_ids)) + if context.get('period_manner','') == 'created': #the query have to be build with no reference to periods but thanks to the creation date if context.get('periods',False): @@ -452,7 +461,7 @@ class account_move_line(osv.osv): context=context) dt = period.date_start return dt - + def _get_currency(self, cr, uid, context={}): if not context.get('journal_id', False): return False @@ -506,7 +515,7 @@ class account_move_line(osv.osv): _constraints = [ (_check_no_view, 'You can not create move line on view account.', ['account_id']), (_check_no_closed, 'You can not create move line on closed account.', ['account_id']), - (_check_company_id, 'Company must be same for its related account and period.', ['company_id']), + (_check_company_id,'Company must be same for its related account and period.',['company_id'] ), ] #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id @@ -677,7 +686,7 @@ class account_move_line(osv.osv): account_id = line['account_id']['id'] partner_id = (line['partner_id'] and line['partner_id']['id']) or False writeoff = debit - credit - + # Ifdate_p in context => take this date if context.has_key('date_p') and context['date_p']: date=context['date_p'] @@ -815,7 +824,7 @@ class account_move_line(osv.osv): # } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): - result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) + result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if view_type != 'tree': return result @@ -1111,7 +1120,7 @@ class account_move_line(osv.osv): #if not 'currency_id' in vals: # vals['currency_id'] = account.company_id.currency_id.id - + result = super(osv.osv, self).create(cr, uid, vals, context) # CREATE Taxes if vals.get('account_tax_id', False): diff --git a/addons/account/account_report.xml b/addons/account/account_report.xml index 8b4aa147a95..8e26ee8553b 100644 --- a/addons/account/account_report.xml +++ b/addons/account/account_report.xml @@ -1,14 +1,14 @@ - - - + + + - - - - + + + +