diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 0816bbbf4a7..c432689de44 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -46,7 +46,6 @@ module named account_voucher. "depends" : ["product", "analytic", "process","board"], 'update_xml': [ 'security/account_security.xml', - 'security/analytic_security.xml', 'security/ir.model.access.csv', 'account_menuitem.xml', 'account_wizard.xml', diff --git a/addons/account/account.py b/addons/account/account.py index 7d5a63f92cc..b1c19476548 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -162,8 +162,8 @@ class account_account_type(osv.osv): 'note': fields.text('Description'), } _defaults = { - 'close_method': lambda *a: 'none', - 'sign': lambda *a: 1, + 'close_method': 'none', + 'sign': 1, } _order = "code" @@ -369,6 +369,7 @@ class account_account(osv.osv): ('other', 'Regular'), ('receivable', 'Receivable'), ('payable', 'Payable'), + ('liquidity','Liquidity'), ('consolidation', 'Consolidation'), ('closed', 'Closed'), ], 'Internal Type', required=True, help="This type is used to differentiate types with "\ @@ -750,19 +751,34 @@ class account_fiscalyear(osv.osv): 'state': fields.selection([('draft','Open'), ('done','Closed')], 'State', readonly=True), } _defaults = { - 'state': lambda *a: 'draft', + 'state': 'draft', 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } _order = "date_start" + def _check_fiscal_year(self, cr, uid, ids, context=None): + current_fiscal_yr = self.browse(cr, uid, ids, context=context)[0] + obj_fiscal_ids = self.search(cr, uid, [('company_id', '=', current_fiscal_yr.company_id.id)], context=context) + obj_fiscal_ids.remove(ids[0]) + data_fiscal_yr = self.browse(cr, uid, obj_fiscal_ids, context=context) + + for old_fy in data_fiscal_yr: + if old_fy.company_id.id == current_fiscal_yr['company_id'].id: + # Condition to check if the current fiscal year falls in between any previously defined fiscal year + if old_fy.date_start <= current_fiscal_yr['date_start'] <= old_fy.date_stop or \ + old_fy.date_start <= current_fiscal_yr['date_stop'] <= old_fy.date_stop: + return False + return True + def _check_duration(self,cr,uid,ids): - obj_fy=self.browse(cr,uid,ids[0]) + obj_fy = self.browse(cr,uid,ids[0]) if obj_fy.date_stop < obj_fy.date_start: return False return True _constraints = [ - (_check_duration, 'Error ! The duration of the Fiscal Year is invalid. ', ['date_stop']) + (_check_duration, 'Error! The duration of the Fiscal Year is invalid. ', ['date_stop']), + (_check_fiscal_year, 'Error! You cannot define overlapping fiscal years',['date_start', 'date_stop']) ] def create_period3(self,cr, uid, ids, context={}): @@ -954,8 +970,8 @@ class account_journal_period(osv.osv): return super(account_journal_period, self).unlink(cr, uid, ids, context) _defaults = { - 'state': lambda *a: 'draft', - 'active': lambda *a: True, + 'state': 'draft', + 'active': True, } _order = "period_id" @@ -1083,10 +1099,10 @@ class account_move(osv.osv): 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company',store=True), } _defaults = { - 'name': lambda *a: '/', - 'state': lambda *a: 'draft', + 'name': '/', + 'state': 'draft', 'period_id': _get_period, - 'date': lambda *a:time.strftime('%Y-%m-%d'), + 'date': time.strftime('%Y-%m-%d'), 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } @@ -1502,9 +1518,9 @@ class account_tax_code(osv.osv): if context is None: context = {} move_state = ('posted', ) - if 'state' in context and context['state'] == 'all': + if context.get('state', False) == 'all': move_state = ('draft', 'posted', ) - if 'fiscalyear_id' in context and context['fiscalyear_id']: + if context.get('fiscalyear_id', False): fiscalyear_id = context['fiscalyear_id'] else: fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) @@ -1522,9 +1538,9 @@ class account_tax_code(osv.osv): if context is None: context = {} move_state = ('posted', ) - if 'state' in context and context['state'] == 'all': + if context.get('state', False) == 'all': move_state = ('draft', 'posted', ) - if 'period_id' in context and context['period_id']: + if context.get('period_id', False): period_id = context['period_id'] else: period_id = self.pool.get('account.period').find(cr, uid) @@ -1577,8 +1593,8 @@ class account_tax_code(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { 'company_id': _default_company, - 'sign': lambda *args: 1.0, - 'notprintable': lambda *a: False, + 'sign': 1.0, + 'notprintable': False, } def copy(self, cr, uid, id, default=None, context=None): @@ -1972,16 +1988,15 @@ class account_model(osv.osv): 'company_id': fields.many2one('res.company', 'Company', required=True), 'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'), 'legend' :fields.text('Legend', readonly=True, size=100), - 'date': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Current Date', required=True, help="The date of the generated entries"), } _defaults = { 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s : To Specify Year \n%(month)s : To Specify Month \n%(date)s : Current Date\n\ne.g. My model on %(date)s'), 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, - 'date': 'today' } def generate(self, cr, uid, ids, datas={}, context={}): move_ids = [] + entry = {} account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') pt_obj = self.pool.get('account.payment.term') @@ -1995,8 +2010,9 @@ class account_model(osv.osv): period_id = period_id[0] for model in self.browse(cr, uid, ids, context): + entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%d')} move_id = account_move_obj.create(cr, uid, { - 'ref': model.name, + 'ref': entry['name'], 'period_id': period_id, 'journal_id': model.journal_id.id, 'date': context.get('date',time.strftime('%Y-%m-%d')) @@ -2091,11 +2107,11 @@ class account_subscription(osv.osv): 'lines_id': fields.one2many('account.subscription.line', 'subscription_id', 'Subscription Lines') } _defaults = { - 'date_start': lambda *a: time.strftime('%Y-%m-%d'), - 'period_type': lambda *a: 'month', - 'period_total': lambda *a: 12, - 'period_nbr': lambda *a: 1, - 'state': lambda *a: 'draft', + 'date_start': time.strftime('%Y-%m-%d'), + 'period_type': 'month', + 'period_total': 12, + 'period_nbr': 1, + 'state': 'draft', } def state_draft(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'draft'}) @@ -2193,6 +2209,7 @@ class account_account_template(osv.osv): ('payable','Payable'), ('view','View'), ('consolidation','Consolidation'), + ('liquidity','Liquidity'), ('other','Others'), ('closed','Closed'), ], 'Internal Type', required=True,help="This type is used to differentiate types with "\ @@ -2212,9 +2229,9 @@ class account_account_template(osv.osv): } _defaults = { - 'reconcile': lambda *a: False, - 'type' : lambda *a :'view', - 'nocreate': lambda *a: False, + 'reconcile': False, + 'type' : 'view', + 'nocreate': False, } _check_recursion = check_cycle @@ -2307,8 +2324,8 @@ class account_tax_code_template(osv.osv): } _defaults = { - 'sign': lambda *args: 1.0, - 'notprintable': lambda *a: False, + 'sign': 1.0, + 'notprintable': False, } def name_get(self, cr, uid, ids, context=None): @@ -2408,17 +2425,17 @@ class account_tax_template(osv.osv): _defaults = { 'python_compute': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''', 'python_compute_inv': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''', - 'applicable_type': lambda *a: 'true', - 'type': lambda *a: 'percent', - 'amount': lambda *a: 0, - 'sequence': lambda *a: 1, - 'tax_group': lambda *a: 'vat', - 'ref_tax_sign': lambda *a: 1, - 'ref_base_sign': lambda *a: 1, - 'tax_sign': lambda *a: 1, - 'base_sign': lambda *a: 1, - 'include_base_amount': lambda *a: False, - 'type_tax_use': lambda *a: 'all', + 'applicable_type': 'true', + 'type': 'percent', + 'amount': 0, + 'sequence': 1, + 'tax_group': 'vat', + 'ref_tax_sign': 1, + 'ref_base_sign': 1, + 'tax_sign': 1, + 'base_sign': 1, + 'include_base_amount': False, + 'type_tax_use': 'all', } _order = 'sequence' @@ -2499,7 +2516,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): _defaults = { 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, 'chart_template_id': _get_chart, - 'code_digits': lambda *a:6, + 'code_digits': 6, 'seq_journal': True } diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index 9126a610aea..5a8ee0d4e8c 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -46,7 +46,7 @@ class account_analytic_line(osv.osv): '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' + _order = 'date desc' def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: @@ -73,13 +73,16 @@ class account_analytic_line(osv.osv): # 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, - unit=False, context=None): + unit=False, journal_id=False, context=None): if context==None: context={} uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') company_obj=self.pool.get('res.company') + analytic_journal_obj=self.pool.get('account.analytic.journal') + product_price_type_obj = self.pool.get('product.price.type') if prod_id: + result = 0.0 prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id if not a: @@ -91,16 +94,27 @@ 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) - + flag = False # 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) + pricetype=product_price_type_obj.browse(cr, uid, company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) + if journal_id: + journal = analytic_journal_obj.browse(cr, uid, journal_id) + if journal.type == 'sale': + product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context) + if product_price_type_ids: + pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context)[0] # Take the company currency as the reference one + if pricetype.field == 'list_price': + flag = True 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 + result = round(amount, prec) + if not flag: + result *= -1 return {'value': { - 'amount': - round(amount, prec), + 'amount': result, 'general_account_id': a, }} return {} diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index bafeecd3066..b6c9a889476 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -645,7 +645,7 @@ class account_bank_statement_line(osv.osv): account_id = part.property_account_receivable.id res['value']['account_id'] = account_id - if account_id and (not line or (line and not line[0].amount)): + if account_id and (not line or (line and not line[0].amount)) and not context.get('amount', False): company_currency_id = res_users_obj.browse(cursor, user, user, context=context).company_id.currency_id.id if not currency_id: diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 4860f937966..feef0c8fa5e 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -20,7 +20,7 @@ - + @@ -28,8 +28,7 @@ - + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 04578cdd92b..463612e2177 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -159,7 +159,10 @@ class account_move_line(osv.osv): return context def _default_get(self, cr, uid, fields, context={}): - + + if not context.get('journal_id', False) and context.get('search_default_journal_id', False): + context['journal_id'] = context.get('search_default_journal_id') + period_obj = self.pool.get('account.period') context = self.convert_to_period(cr, uid, context) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 2fabc21d60f..2185599b741 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -540,7 +540,7 @@ - + @@ -1579,9 +1579,9 @@ - + @@ -1596,7 +1596,6 @@ - @@ -1771,13 +1770,38 @@ tree - + + + + + account.subscription.search + account.subscription + search + + + + + + + + + + + + + + + + + + + account.subscription.form account.subscription @@ -1820,6 +1844,7 @@ account.subscription form tree,form + diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index e4c4fe733d9..9a60eebced5 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -151,7 +151,7 @@ X11004 Bank Current Account - (test) - other + liquidity @@ -159,7 +159,7 @@ X11005 Cash - (test) - other + liquidity diff --git a/addons/account/installer.py b/addons/account/installer.py index a6376694175..72327cb79ca 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -469,7 +469,7 @@ class account_installer(osv.osv_memory): def execute(self, cr, uid, ids, context=None): if context is None: context = {} - res_obj = self.pool.get('account.fiscalyear') + fy_obj = self.pool.get('account.fiscalyear') data_pool = self.pool.get('ir.model.data') obj_acc = self.pool.get('account.account') super(account_installer, self).execute(cr, uid, ids, context=context) @@ -531,7 +531,7 @@ class account_installer(osv.osv_memory): 'company_id': company_id.id, 'sign': 1, 'parent_id':pur_tax_parent_id - } + } new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code) purchase_tax = obj_tax.create(cr, uid, {'name':'TAX%s%%'%(p_tax*100), @@ -556,21 +556,23 @@ class account_installer(osv.osv_memory): ir_values.set(cr, uid, key='default', key2=False, name=name, models =[('product.product',False)], value=[value]) if 'date_start' in res and 'date_stop' in res: - name = code = res['date_start'][:4] - if int(name) != int(res['date_stop'][:4]): - name = res['date_start'][:4] +'-'+ res['date_stop'][:4] - code = res['date_start'][2:4] +'-'+ res['date_stop'][2:4] - vals = {'name': name, - 'code': code, - 'date_start': res['date_start'], - 'date_stop': res['date_stop'], - 'company_id': res['company_id'] - } - period_id = res_obj.create(cr, uid, vals, context=context) - if res['period'] == 'month': - res_obj.create_period(cr, uid, [period_id]) - elif res['period'] == '3months': - res_obj.create_period3(cr, uid, [period_id]) + f_ids = fy_obj.search(cr, uid, [('date_start', '<=', res['date_start']), ('date_stop', '>=', res['date_stop']), ('company_id','=',res['company_id'])]) + if not f_ids: + name = code = res['date_start'][:4] + if int(name) != int(res['date_stop'][:4]): + name = res['date_start'][:4] +'-'+ res['date_stop'][:4] + code = res['date_start'][2:4] +'-'+ res['date_stop'][2:4] + vals = {'name': name, + 'code': code, + 'date_start': res['date_start'], + 'date_stop': res['date_stop'], + 'company_id': res['company_id'] + } + fiscal_id = fy_obj.create(cr, uid, vals, context=context) + if res['period'] == 'month': + fy_obj.create_period(cr, uid, [fiscal_id]) + elif res['period'] == '3months': + fy_obj.create_period3(cr, uid, [fiscal_id]) # #fially inactive the demo chart of accounts # data_id = data_pool.search(cr, uid, [('model','=','account.account'), ('name','=','chart0')]) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 88beaa0f963..28655d2a7a7 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -397,10 +397,10 @@ class account_invoice(osv.osv): rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) - rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value','res_id']) - pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value','res_id']) - rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False - pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False + rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id']) + pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id']) + rec_res_id = rec_line_data and int(rec_line_data[0]['value_reference'].split(',')[1]) or False + pay_res_id = pay_line_data and int(pay_line_data[0]['value_reference'].split(',')[1]) or False if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company, Please Create account.')) @@ -493,10 +493,10 @@ class account_invoice(osv.osv): rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) - rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) - pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value','res_id']) - rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False - pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False + rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value_reference','res_id']) + pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value_reference','res_id']) + rec_res_id = rec_line_data and int(rec_line_data[0]['value_reference'].split(',')[1]) or False + pay_res_id = pay_line_data and int(pay_line_data[0]['value_reference'].split(',')[1]) or False if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company, Please Create account.')) diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 36e09464f90..7e8f6875553 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -8,7 +8,7 @@ tree - + @@ -25,6 +25,7 @@ + @@ -51,7 +52,7 @@ tree child_ids - + @@ -105,7 +106,7 @@ - + Accounts to Renew @@ -119,16 +120,14 @@ Chart of Analytic Accounts - ir.actions.act_window account.analytic.account - [('parent_id','=',False)] tree - form,graph + [('parent_id','=',False)] Analytic Charts of Accounts allows you to access to reports by analytic accounts (or cost accounts) . From this menu you can access to analytic balance, a report that relates the analytic accounts to the general accounts. It is useful for analyzing the profitability of projects, giving you the profitability of a project for the different operations that you used to carry out the project. - + account.analytic.line.form @@ -174,7 +173,7 @@ - + @@ -259,7 +258,7 @@ - + @@ -334,7 +333,7 @@ tree,form,search - + # # Open journal entries @@ -346,7 +345,7 @@ form tree,form - + # # Reporting @@ -358,7 +357,7 @@ tree To print an analytics (or costs) journal for a given period. The report give code, move name, account number, general amount and analytic amount. - + # # Statistics diff --git a/addons/account/project/wizard/account_analytic_chart_view.xml b/addons/account/project/wizard/account_analytic_chart_view.xml index 9cc7a32633b..e4c13a07601 100644 --- a/addons/account/project/wizard/account_analytic_chart_view.xml +++ b/addons/account/project/wizard/account_analytic_chart_view.xml @@ -39,7 +39,7 @@ action="action_account_analytic_chart" id="menu_action_analytic_account_tree2" icon="STOCK_INDENT" - groups="base.group_extended"/> + groups="analytic.group_analytic_accounting"/> diff --git a/addons/account/report/account_analytic_entries_report_view.xml b/addons/account/report/account_analytic_entries_report_view.xml index bc40e6235d7..f7e543cb22c 100644 --- a/addons/account/report/account_analytic_entries_report_view.xml +++ b/addons/account/report/account_analytic_entries_report_view.xml @@ -107,7 +107,7 @@ A tool search lets you know statistics on your analytics records that match your needs. - + diff --git a/addons/account/report/account_profit_horizontal.rml b/addons/account/report/account_profit_horizontal.rml index 76d462aacf8..79bc6c5c731 100644 --- a/addons/account/report/account_profit_horizontal.rml +++ b/addons/account/report/account_profit_horizontal.rml @@ -328,13 +328,13 @@ Total:([[ get_currency(data['form']) ]]) - [[ sum_dr() and formatLang(abs(sum_dr())) or 0.0 ]] + [[ formatLang(abs(sum_dr())) or 0.0 ]] Total:([[ get_currency(data['form']) ]]) - [[ sum_cr() and formatLang(abs(sum_cr())) or 0.0 ]] + [[ formatLang(abs(sum_cr())) or 0.0 ]] diff --git a/addons/account/report/account_profit_loss.rml b/addons/account/report/account_profit_loss.rml index 7bf0704b8a0..acc9c51fc2f 100644 --- a/addons/account/report/account_profit_loss.rml +++ b/addons/account/report/account_profit_loss.rml @@ -297,7 +297,7 @@ Total:([[ get_currency(data) ]]) - [[ sum_dr() and formatLang(abs(sum_dr())) or 0.0 ]] + [[ formatLang(abs(sum_dr())) or 0.0 ]] @@ -352,7 +352,7 @@ Total:([[ get_currency(data) ]]) - [[ sum_cr() and formatLang(abs(sum_cr())) or 0.0 ]] + [[ formatLang(abs(sum_cr())) or 0.0 ]] diff --git a/addons/account/report/voucher_print.rml b/addons/account/report/voucher_print.rml index ac380c0a5a5..463aa80e65c 100644 --- a/addons/account/report/voucher_print.rml +++ b/addons/account/report/voucher_print.rml @@ -2,7 +2,7 @@ @@ -10,37 +10,80 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + @@ -50,35 +93,18 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - + @@ -130,72 +156,60 @@ + + - [[ repeatIn(objects,'voucher') ]] - [[ company.name ]] - [[ company.partner_id.address and company.partner_id.address[0].street ]] - [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]] - [[ company.partner_id.address and company.partner_id.address[0].phone ]] - [[ company.partner_id.address and company.partner_id.address[0].email ]] - - - - [[ voucher.journal_id.name ]] - - - - + [[ repeatIn(objects,'voucher') ]] + - Name: + Journal: - [[ voucher.name ]] + [[ voucher.journal_id.name ]] - - - + Number: - Dated : - - - [[ formatLang(voucher.date, date=True) or '' ]] - - - - - State : - - - PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] - Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] - Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] - Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] - - - - - - - - Ref. : - - - [[ voucher.ref]] + [[ voucher.name ]] - + + + + State: + + + PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] + Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] + Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] + Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] + + + Ref. : + + + [[ voucher.ref]] + + + Date: + + + [[ formatLang(voucher.date , date=True) or '' ]] + + + + - + - + Particulars @@ -213,7 +227,7 @@
[[ repeatIn(voucher.line_id,'line_id') ]] - + [[ (line_id.partner_id and line_id.partner_id.name) or 'Account']] @@ -242,7 +256,7 @@ - [[ line_id.name ]]-[[voucher.ref]] + [[ line_id.name ]]-[[voucher.ref]] @@ -260,13 +274,88 @@
- + - + - Through : + Through : + + + + + + + + + + + + + + + [[ voucher.narration or '']] + + + + + + + + + + + + + + + On Account of : + + + + + + + + + + + + + + + [[ voucher.line_id and voucher.line_id.name and voucher.line_id.name[1] or removeParentNode('para') ]] + + + + + + + + + + + + + + + Amount (in words) : + + + + + + + + + + + + + + + [[ convert(voucher.amount) ]] @@ -279,84 +368,14 @@ + + + + + - [[ voucher.narration or '']] - - - - - - - - - - - - - - - On Account of : - - - - - - - - - - - - - - - [[ voucher.line_id and voucher.line_id.name and voucher.line_id.name[1] or removeParentNode('para') ]] - - - - - - - - - - - - - - - Amount (in words) : - - - - - - - - - - - - - - - [[ convert(voucher.amount) ]] - - - - - - - - - - - - - - - + @@ -368,57 +387,57 @@ - + - + - + - + - + - + - + - + - + - Receiver's Signature + Receiver's Signature - + - + - Authorised Signatory + Authorised Signatory diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml index 43e3e32eefd..7344c40754e 100644 --- a/addons/account/security/account_security.xml +++ b/addons/account/security/account_security.xml @@ -13,7 +13,7 @@ Accounting / Manager - + Accounting / Accountant and Manager diff --git a/addons/account/security/analytic_security.xml b/addons/account/security/analytic_security.xml deleted file mode 100644 index b2543f5fa05..00000000000 --- a/addons/account/security/analytic_security.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/addons/account/test/account_use_model.yml b/addons/account/test/account_use_model.yml index 20487fa86f4..4eb03a13026 100644 --- a/addons/account/test/account_use_model.yml +++ b/addons/account/test/account_use_model.yml @@ -3,7 +3,6 @@ - !record {model: account.model, id: account_model_mymodelonyears0}: journal_id: account.expenses_journal - date: today lines_id: - account_id: account.a_recv credit: 0.0 diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index 436d320456e..e9a8ab04aac 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + import time import netsvc @@ -54,7 +55,7 @@ class account_automatic_reconcile(osv.osv_memory): 'date2': time.strftime('%Y-%m-%d'), 'reconciled': _get_reconciled, 'unreconciled': _get_unreconciled, - 'power':2 + 'power': 2 } #TODO: cleanup and comment this code... For now, it is awfulllll @@ -143,18 +144,21 @@ class account_automatic_reconcile(osv.osv_memory): form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', 0.0) power = form['power'] + allow_write_off = form['allow_write_off'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: - if not context.get('allow_write_off', False): + if not allow_write_off: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ - HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) + HAVING ABS(SUM(debit-credit)) = %s AND count(*)>0"%(account_id, 0.0) +# HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0) +# HAVING count(*)>0"%(account_id,) else: query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \ AND state <> 'draft' GROUP BY partner_id \ - HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0) + HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0"%(account_id, max_amount or 0.0) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query) partner_ids = [id for (id,) in cr.fetchall()] @@ -170,10 +174,12 @@ class account_automatic_reconcile(osv.osv_memory): line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) - if not context.get('allow_write_off', False): - move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) - else: + if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) +# move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) + else: + move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) +# move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) # get the list of partners who have more than one unreconciled transaction cr.execute( @@ -240,9 +246,8 @@ class account_automatic_reconcile(osv.osv_memory): 'type': 'ir.actions.act_window', 'target': 'new', 'context': context, - 'nodestroy':True, } account_automatic_reconcile() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py index 7f89e700b74..8b9cf48d48c 100644 --- a/addons/account/wizard/account_move_journal.py +++ b/addons/account/wizard/account_move_journal.py @@ -161,7 +161,7 @@ class account_move_journal(osv.osv_memory): 'view_mode': 'tree,graph,form', 'res_model': 'account.move.line', 'view_id': False, - 'context': "{'visible_id':%s, 'journal_id': %d, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (journal_id, journal_id, journal_id, period_id), + 'context': "{'visible_id':%s, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (journal_id, journal_id, period_id), 'type': 'ir.actions.act_window', 'search_view_id': res_id } diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py index 9d822b091d5..e18bd9f9555 100644 --- a/addons/account/wizard/account_reconcile.py +++ b/addons/account/wizard/account_reconcile.py @@ -49,38 +49,6 @@ class account_move_line_reconcile(osv.osv_memory): res.update({'writeoff':data['writeoff']}) return res - def partial_check(self, cr, uid, ids, context=None): - mod_obj = self.pool.get('ir.model.data') - data = self.trans_rec_get(cr, uid, ids, context) - if context is None: - context = {} - if data['writeoff'] == 0: - model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_move_line_reconcile_full')], context=context) - resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] - return { - 'name': _('Reconcile'), - 'context': context, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'account.move.line.reconcile', - 'views': [(resource_id,'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', - } - else : - model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_move_line_reconcile_partial')], context=context) - resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] - return { - 'name': _('Reconcile'), - 'context': context, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'account.move.line.reconcile', - 'views': [(resource_id,'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', - } - def trans_rec_get(self, cr, uid, ids, context=None): account_move_line_obj = self.pool.get('account.move.line') if context is None: @@ -117,6 +85,7 @@ class account_move_line_reconcile(osv.osv_memory): ids = self.pool.get('account.period').find(cr, uid, dt=date, context=context) if len(ids): period_id = ids[0] + context.update({'stop_reconcile': True}) account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id, period_id, journal_id, context=context) return {} @@ -183,6 +152,7 @@ class account_move_line_reconcile_writeoff(osv.osv_memory): if len(ids): period_id = ids[0] + context.update({'stop_reconcile': True}) account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id, period_id, journal_id, context=context) return {} diff --git a/addons/account/wizard/account_use_model.py b/addons/account/wizard/account_use_model.py index b1087cbbcdc..edac082f32e 100644 --- a/addons/account/wizard/account_use_model.py +++ b/addons/account/wizard/account_use_model.py @@ -55,21 +55,22 @@ class account_use_model(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') if context is None: context = {} - + move_ids = [] + entry = {} data = self.read(cr, uid, ids, context=context)[0] record_id = context and context.get('model_line', False) or False if record_id: data_model = account_model_obj.browse(cr, uid, data['model']) else: data_model = account_model_obj.browse(cr, uid, context['active_ids']) - move_ids = [] for model in data_model: + entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%d')} period_id = account_period_obj.find(cr, uid, context=context) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] move_id = account_move_obj.create(cr, uid, { - 'ref': model.name, + 'ref': entry['name'], 'period_id': period_id, 'journal_id': model.journal_id.id, }) diff --git a/addons/account/wizard/account_use_model_view.xml b/addons/account/wizard/account_use_model_view.xml index 232c1b8df88..f6ab3949abd 100644 --- a/addons/account/wizard/account_use_model_view.xml +++ b/addons/account/wizard/account_use_model_view.xml @@ -32,15 +32,7 @@ {'model_line':'model_line'} - - - - Manual Recurring - client_action_multi - - action - account.move.line - + account.use.model.create.entry.form diff --git a/addons/account_analytic_plans/account_analytic_plans_view.xml b/addons/account_analytic_plans/account_analytic_plans_view.xml index ae2b6612a64..e732b483730 100644 --- a/addons/account_analytic_plans/account_analytic_plans_view.xml +++ b/addons/account_analytic_plans/account_analytic_plans_view.xml @@ -196,7 +196,7 @@ parent="account.menu_analytic_accounting" name="Multi Plans" id="menu_account_analytic_multi_plan_action" - /> + groups="analytic.group_analytic_accounting"/> ). # @@ -15,13 +15,14 @@ # 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 . # ############################################################################## -from osv import fields, osv from mx import DateTime +from osv import fields, osv + class Invoice(osv.osv): _inherit = 'account.invoice' @@ -49,5 +50,4 @@ class Invoice(osv.osv): Invoice() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index 045e5f81627..718a81d5c77 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -133,6 +133,29 @@ class payment_order(osv.osv): }) return super(payment_order, self).copy(cr, uid, id, default, context=context) + def write(self, cr, uid, ids, vals, context=None): + if context is None: + context = {} + payment_line_obj = self.pool.get('payment.line') + payment_line_ids = [] + if (vals.get('date_prefered', False) == 'fixed' and not vals.get('date_scheduled', False)) or vals.get('date_scheduled', False): + for order in self.browse(cr, uid, ids, context=context): + for line in order.line_ids: + payment_line_ids.append(line.id) + payment_line_obj.write(cr, uid, payment_line_ids, {'date':vals.get('date_scheduled', False)}, context=context) + elif vals.get('date_prefered', False) == 'due': + vals.update({'date_scheduled':False}) + for order in self.browse(cr, uid, ids, context=context): + for line in order.line_ids: + payment_line_obj.write(cr, uid, [line.id], {'date':line.ml_maturity_date}, context=context) + elif vals.get('date_prefered', False) == 'now': + vals.update({'date_scheduled':False}) + for order in self.browse(cr, uid, ids, context=context): + for line in order.line_ids: + payment_line_ids.append(line.id) + payment_line_obj.write(cr, uid, payment_line_ids, {'date': False}, context=context) + return super(payment_order, self).write(cr, uid, ids, vals, context=context) + payment_order() class payment_line(osv.osv): @@ -238,19 +261,6 @@ class payment_line(osv.osv): line.amount_currency, context=ctx) return res - def _value_date(self, cursor, user, ids, name, args, context=None): - if not ids: - return {} - res = {} - for line in self.browse(cursor, user, ids, context=context): - if line.order_id.date_prefered == 'fixed': - res[line.id] = line.order_id.date_scheduled - elif line.order_id.date_prefered == 'due': - res[line.id] = line.due_date or time.strftime('%Y-%m-%d') - else: - res[line.id] = time.strftime('%Y-%m-%d') - return res - def _get_currency(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid) if user.company_id: @@ -359,7 +369,6 @@ class payment_line(osv.osv): data['date'] = line.date_maturity elif date_prefered == 'fixed': data['date'] = date_scheduled - return {'value': data} def onchange_amount(self, cr, uid, ids, amount, currency, cmpny_currency, context=None): diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py index 696160c35ef..97a66e937ca 100644 --- a/addons/account_payment/wizard/account_payment_order.py +++ b/addons/account_payment/wizard/account_payment_order.py @@ -66,7 +66,7 @@ class payment_order_create(osv.osv_memory): if not line_ids: return {} payment = order_obj.browse(cr, uid, context['active_id'], context=context) - t = payment.mode and payment.mode.type.id or None + t = None line2bank = line_obj.line2bank(cr, uid, line_ids, t, context) ## Finally populate the current payment with new lines: diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py index 4b41b0dfc89..49858151670 100644 --- a/addons/account_payment/wizard/account_payment_pay.py +++ b/addons/account_payment/wizard/account_payment_pay.py @@ -33,7 +33,8 @@ class account_payment_make_payment(osv.osv_memory): # obj_model = self.pool.get('ir.model.data') # obj_act = self.pool.get('ir.actions.act_window') # order = obj_payment_order.browse(cr, uid, context['active_id'], context) - return obj_payment_order.set_done(cr, uid, context['active_id'], context) + obj_payment_order.set_done(cr, uid, context['active_id'], context) + return {} # t = order.mode and order.mode.type.code or 'manual' # if t == 'manual' : # obj_payment_order.set_done(cr,uid,context['active_id'],context) diff --git a/addons/account_voucher/report/report_voucher.py b/addons/account_voucher/report/report_voucher.py index a3f3bb0380d..8c7b1ccbbea 100644 --- a/addons/account_voucher/report/report_voucher.py +++ b/addons/account_voucher/report/report_voucher.py @@ -61,5 +61,5 @@ report_sxw.report_sxw( 'report.voucher.cash_receipt.drcr', 'account.voucher', 'addons/account_voucher/report/report_voucher.rml', - parser=report_voucher,header=False + parser=report_voucher,header="external" ) diff --git a/addons/account_voucher/report/report_voucher.rml b/addons/account_voucher/report/report_voucher.rml index 23cab480414..130074bea60 100755 --- a/addons/account_voucher/report/report_voucher.rml +++ b/addons/account_voucher/report/report_voucher.rml @@ -2,7 +2,7 @@ @@ -10,11 +10,67 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + @@ -26,22 +82,6 @@ - - - - - - - - - - - - - - - - @@ -49,33 +89,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -92,13 +113,13 @@ - + - - + + @@ -133,81 +154,67 @@ - [[ repeatIn(objects,'voucher') ]] - [[ company.name ]] - [[ company.partner_id.address and company.partner_id.address[0].street ]] - [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]] - [[ company.partner_id.address and company.partner_id.address[0].phone ]] - [[ company.partner_id.address and company.partner_id.address[0].email ]] - + [[ repeatIn(objects,'voucher') ]] + - Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]] - Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]] - Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]] - Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]] - + - + - No. + Journal: - [[ voucher.number ]] + [[ voucher.type ]] - - - + Number: - Dated : - - - [[ formatLang(voucher.date, date=True) or '' ]] - - - - - State : - - - PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] - Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] - Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] - Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] - - - - - - - - Ref. : - - - [[ voucher.reference ]] + [[ voucher.number ]] - - - - - - - + - Particulars + State: - Debit + PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] + Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] + Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] + Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] - Credit + Ref. : + + + [[ voucher.reference or '' ]] + + + Date: + + + [[ formatLang(voucher.date , date=True) or '' ]] + + + + + + + + + + Particulars + + + Debit + + + Credit @@ -216,12 +223,10 @@
[[ repeatIn(voucher.move_ids,'move_ids') ]] - + - - [[ (move_ids.partner_id and move_ids.partner_id.name) or 'Account']] - + [[ (move_ids.partner_id and move_ids.partner_id.name) or 'Account']] [[ formatLang(move_ids.debit) ]] @@ -232,9 +237,7 @@ - - [[ move_ids.account_id.name ]] - + [[ move_ids.account_id.name ]] @@ -249,7 +252,7 @@ - [[ move_ids.name ]] - [[ voucher.reference ]] + [[ move_ids.name ]] - [[ get_ref(voucher.id,move_ids) ]] @@ -267,165 +270,167 @@
- + - + - Through : + Through : - + - + - [[ voucher.narration or '']] + [[ voucher.narration or '']] - + - + - On Account of : + On Account of : - + - + - [[ voucher.name ]] + [[ voucher.name ]] - + - + - Amount (in words) : + Amount (in words) : - + - + - [[ convert(voucher.amount,voucher.currency_id.name) ]] + [[ convert(voucher.amount,voucher.currency_id.name) ]] - + - + - - - - - - - - [[ debit(voucher.move_ids)]] - - - [[ credit(voucher.move_ids) ]] - - - + - + - - - - - - - - - - + - + [[ debit(voucher.move_ids)]] + + + [[ credit(voucher.move_ids) ]] + + + + + + + + + + + + + + + + - + - + + + + + + - Receiver's Signature + Receiver's Signature - + - + - Authorised Signatory + Authorised Signatory diff --git a/addons/account_voucher/report/report_voucher_amount.py b/addons/account_voucher/report/report_voucher_amount.py index 2cb113ae4ed..b691ca638f0 100644 --- a/addons/account_voucher/report/report_voucher_amount.py +++ b/addons/account_voucher/report/report_voucher_amount.py @@ -40,5 +40,5 @@ report_sxw.report_sxw( 'report.voucher.cash_amount', 'account.voucher', 'addons/account_voucher/report/report_voucher_amount.rml', - parser=report_voucher_amount,header=False + parser=report_voucher_amount,header="external" ) diff --git a/addons/account_voucher/report/report_voucher_amount.rml b/addons/account_voucher/report/report_voucher_amount.rml index 71e18a23a69..828ca6ebc13 100755 --- a/addons/account_voucher/report/report_voucher_amount.rml +++ b/addons/account_voucher/report/report_voucher_amount.rml @@ -2,7 +2,7 @@ @@ -10,9 +10,51 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -23,21 +65,21 @@ - - - - - + - + + + + + - - + + @@ -48,30 +90,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + @@ -79,7 +102,7 @@ - + @@ -126,98 +149,65 @@ + - [[ repeatIn(objects,'voucher') ]] - [[ company.name ]] - [[ company.partner_id.address and company.partner_id.address[0].street ]] - [[ company.partner_id.address and company.partner_id.address[0].zip ]] [[ company.partner_id.address and company.partner_id.address[0].city ]] - [[ company.partner_id.address and company.partner_id.address[0].country_id and company.partner_id.address[0].country_id.name ]] - [[ company.partner_id.address and company.partner_id.address[0].phone ]] - [[ company.partner_id.address and company.partner_id.address[0].email ]] - - - - Cash Receipt Voucher [[ (voucher.type == 'rec_voucher' or removeParentNode('para')) and '' ]] - Cash Payment Voucher [[ (voucher.type == 'pay_voucher' or removeParentNode('para')) and '' ]] - Bank Receipt Voucher [[ (voucher.type == 'bank_rec_voucher' or removeParentNode('para')) and '' ]] - Bank Payment Voucher [[ (voucher.type == 'bank_pay_voucher' or removeParentNode('para')) and '' ]] - - - - + [[ repeatIn(objects,'voucher') ]] + - No. + Type: - [[ voucher.number ]] + [[ voucher.journal_id.nme ]] - - - + Number: - Dated : + [[ voucher.number ]] - [[ formatLang(voucher.date, date=True) or '' ]] - - - - - State : + Date: - PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] - Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] - Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] - Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] - - - - - - - - Ref. : - - - [[ voucher.reference ]] - - - - - Account : - - - [[ voucher.account_id.name ]] - - - - - - - - - - - - - - - + [[ formatLang(voucher.date , date=True) or '' ]] - + + + + State: + + + PRO-FORMA [[ ((voucher.state == 'proforma') or removeParentNode('para')) and '' ]] + Draft[[ ((voucher.state == 'draft') or removeParentNode('para')) and '' ]] + Canceled [[ ((voucher.state == 'cancel') or removeParentNode('para')) and '' ]] + Posted [[ ((voucher.state == 'posted') or removeParentNode('para')) and '' ]] + + + Ref: + + + [[ voucher.reference ]] + + + Account: + + + [[ voucher.account_id.name ]] + + + + - + - + Particulars @@ -227,190 +217,183 @@ - - - - - - -
- [[ repeatIn(voucher.line_ids,'line_ids') ]] - - - - [[ line_ids.partner_id and line_ids.partner_id.name or '' ]] - - - [[ line_ids.amount ]] - - - - - [[ line_ids.account_id.name ]] - - - - - - - - - - [[ line_ids.ref ]] [[ line_ids.amount ]] - - - - - - - - - - [[ line_ids.type ]] - - - - - - - - - + + + +
+ [[ repeatIn(voucher.payment_ids,'payment_ids') ]] + + + + [[ payment_ids.partner_id and payment_ids.partner_id.name or '' ]] + + + [[ payment_ids.amount ]] + + + + + [[ payment_ids.account_id.name ]] + + + -
- + + + + + [[ payment_ids.ref ]] [[ payment_ids.amount ]] + + + + + + + + + + [[ payment_ids.type ]] + + + + + + + + + + + +
+ + + + + + + Through : + + + - + + + + + [[ voucher.narration or '' ]] + + + + + + + + + + On Account of : + + + + + + + + + + [[ voucher.name ]] + + + + + + + + + + Amount (in words) : + + + + + + + + + + [[ convert(voucher.amount,voucher.currency_id.name) ]] + + + - + + + + - - Through : - - - - - [[ voucher.narration or '' ]] - - - - - - - - - - On Account of : - - - - - - - - - - [[ voucher.name ]] - - - - - - - - - - Amount (in words) : - - - - - - - - - - [[ convert(voucher.amount,voucher.currency_id.name) ]] - - - - - - - - - - - - - [[ voucher.amount ]] - + - + - + - + - - - - + - + - + - + - Receiver's Signature + Receiver's Signature - + - + - Authorised Signatory + Authorised Signatory diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 012a386fa13..7d848242a1b 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -57,6 +57,9 @@ class account_voucher(osv.osv): journal_pool = self.pool.get('account.journal') if context.get('journal_id', False): return context.get('journal_id') + if not context.get('journal_id', False) and context.get('search_default_journal_id', False): + return context.get('search_default_journal_id') + ttype = context.get('type', 'bank') res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) return res and res[0] or False @@ -81,7 +84,7 @@ class account_voucher(osv.osv): def _get_partner(self, cr, uid, context={}): return context.get('partner_id', False) - + _name = 'account.voucher' _description = 'Accounting Voucher' _order = "date desc, id desc" @@ -427,23 +430,23 @@ class account_voucher(osv.osv): # TODO def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): + res = {} if not partner_id: - return {} - partner_pool = self.pool.get('res.partner') + return res res = {'account_id':False} + partner_pool = self.pool.get('res.partner') + journal_pool = self.pool.get('account.journal') if pay_now == 'pay_later': partner = partner_pool.browse(cr, uid, partner_id) - if ttype == 'sale': - res.update({ - 'account_id':partner.property_account_receivable.id, - }) - elif ttype == 'purchase': - res.update({ - 'account_id':partner.property_account_payable.id, - }) - return { - 'value':res - } + journal = journal_pool.browse(cr, uid, journal_id) + if journal.type in ('sale','sale_refund'): + account_id = partner.property_account_receivable.id + elif journal.type in ('purchase', 'purchase_refund','expense'): + account_id = partner.property_account_payable.id + else: + account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id + res['account_id'] = account_id + return {'value':res} def action_move_line_create(self, cr, uid, ids, *args): diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index b778272551a..1abf4ec1ea1 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -45,7 +45,7 @@ + domain="[('type','=','liquidity')]"/> +