From e0799d38172f33258299ba2ec579643adb91edaf Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 31 Aug 2010 16:37:39 +0200 Subject: [PATCH 001/128] [IMP] account: usability (changed the order of buttons in group by) bzr revid: qdp-launchpad@tinyerp.com-20100831143739-2dzgwultqzt0aomu --- addons/account/account_invoice_view.xml | 6 +++--- addons/account/account_view.xml | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index ad48ea86c23..04a184bfe27 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -371,13 +371,13 @@ - - - + + + diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 4ae31b9b7f6..2cf03d11723 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -426,8 +426,9 @@ - + + @@ -469,8 +470,9 @@ - + + @@ -1066,11 +1068,11 @@ - - - + + + @@ -1078,7 +1080,6 @@ - @@ -1319,11 +1320,12 @@ - - - - + + + + + From 983258cfffdb6828e72515edd9c30c36ac14d401 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Wed, 1 Sep 2010 19:24:07 +0530 Subject: [PATCH 002/128] [FIX]: add on_change jourbal event, same as _get_taxid bzr revid: mga@tinyerp.com-20100901135407-tp8sw0sqc2hk1ds2 --- addons/account_voucher/voucher.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index c1ce3d4e690..daa4f99cc3d 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -361,7 +361,16 @@ class account_voucher(osv.osv): } def onchange_journal(self, cr, uid, ids, journal_id): - return {} + if not journal_id: + return False + journal_pool = self.pool.get('account.journal') + journal = journal_pool.browse(cr, uid, journal_id) + account_id = journal.default_credit_account_id or journal.default_debit_account_id + tax_id = False + if account_id and account_id.tax_ids: + tax_id = account_id.tax_ids[0].id + + return {'value':{'tax_id':tax_id}} def proforma_voucher(self, cr, uid, ids): self.action_move_line_create(cr, uid, ids) From b8cafd19a0141cf92362a0dc41851dcf3feac82d Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Wed, 1 Sep 2010 15:58:06 +0200 Subject: [PATCH 003/128] [IMP] analytic: removed the automatic code attribution on creation bzr revid: qdp-launchpad@tinyerp.com-20100901135806-vwwgwy6k41cl8vkm --- addons/analytic/analytic.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index e5dd9d52ce1..ae0c7e11d5c 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -186,9 +186,9 @@ class account_analytic_account(osv.osv): _columns = { 'name' : fields.char('Account Name', size=128, required=True), 'complete_name': fields.function(_complete_name_calc, method=True, type='char', string='Full Account Name'), - 'code' : fields.char('Account Code', size=24), + 'code': fields.char('Account Code', size=24), 'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type'), - 'description' : fields.text('Description'), + 'description': fields.text('Description'), 'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2), 'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'), 'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'), @@ -238,12 +238,6 @@ class account_analytic_account(osv.osv): (check_recursion, 'Error! You can not create recursive analytic accounts.', ['parent_id']) ] - def create(self, cr, uid, vals, context=None): - parent_id = vals.get('parent_id', 0) - if ('code' not in vals or not vals['code']) and not parent_id: - vals['code'] = self.pool.get('ir.sequence').get(cr, uid, 'account.analytic.account') - return super(account_analytic_account, self).create(cr, uid, vals, context=context) - def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} @@ -350,4 +344,4 @@ class account_analytic_line(osv.osv): account_analytic_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 17cf2b661387df38e189f59f456fcf13ff18ee7d Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Wed, 1 Sep 2010 21:48:05 +0530 Subject: [PATCH 004/128] [IMP]: improvement to the voucher module and some chanegs bzr revid: mga@tinyerp.com-20100901161805-2o4trndpj9ufzr0m --- addons/account/account_view.xml | 2 +- addons/account_voucher/voucher.py | 130 +++++++----------- .../voucher_payment_receipt_view.xml | 8 +- .../voucher_sales_purchase_view.xml | 10 +- 4 files changed, 62 insertions(+), 88 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 2e332ef4542..c68ecb51fec 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1120,7 +1120,7 @@ icon="STOCK_JUSTIFY_FILL" id="menu_action_account_moves_all" parent="account.menu_finance_entries" - sequence="16" + sequence="1" groups="group_account_user,group_account_manager,base.group_system" /> diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index daa4f99cc3d..e7f14555e80 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -132,7 +132,7 @@ class account_voucher(osv.osv): 'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}), 'pre_line':fields.boolean('Previous Payments ?', required=False), 'date_due': fields.date('Due Date'), - 'term_id':fields.many2one('account.payment.term', 'Term', required=False), +# 'term_id':fields.many2one('account.payment.term', 'Term', required=False), } _defaults = { 'period_id': _get_period, @@ -280,10 +280,6 @@ class account_voucher(osv.osv): if journal.type in ('sale','sale_refund'): account_id = partner.property_account_receivable.id elif journal.type in ('purchase', 'purchase_refund','expense'): - term_id = partner.property_payment_term.id - if term_id: - vals = self.onchange_term_id(cr, uid, ids, term_id, price) - default['value'].update(vals.get('value')) account_id = partner.property_account_payable.id else: account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id @@ -294,17 +290,20 @@ class account_voucher(osv.osv): if journal.type not in ('cash', 'bank'): return default + total_credit = 0.0 + total_debit = 0.0 account_type = 'receivable' if ttype == 'payment': account_type = 'payable' + total_debit = price or 0.0 else: + total_credit = price or 0.0 account_type = 'receivable' - + ids = move_line_pool.search(cr, uid, [('account_id.type','=', account_type), ('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) ids.reverse() moves = move_line_pool.browse(cr, uid, ids) - total_credit = price or 0.0 - total_debit = 0.0 + for line in moves: if line.credit and line.reconcile_partial_id: continue @@ -327,7 +326,7 @@ class account_voucher(osv.osv): rs['amount'] = min(line.amount_unreconciled, total_debit) total_debit -= rs['amount'] else: - rs['amount'] = min(line.debit, total_credit) + rs['amount'] = min(line.amount_unreconciled, total_credit) total_credit -= rs['amount'] default['value']['line_ids'].append(rs) @@ -384,9 +383,20 @@ class account_voucher(osv.osv): return True def cancel_voucher(self, cr, uid, ids, context={}): + reconcile_pool = self.pool.get('account.move.reconcile') move_pool = self.pool.get('account.move') voucher_line_pool = self.pool.get('account.voucher.line') + for voucher in self.browse(cr, uid, ids): + recs = [] + for line in voucher.move_ids: + if line.reconcile_id: + recs += [line.reconcile_id.id] + if line.reconcile_partial_id: + recs += [line.reconcile_partial_id.id] + + reconcile_pool.unlink(cr, uid, recs) + if voucher.move_id: move_pool.button_cancel(cr, uid, [voucher.move_id.id]) move_pool.unlink(cr, uid, [voucher.move_id.id]) @@ -475,54 +485,47 @@ class account_voucher(osv.osv): if credit < 0: debit = -credit credit = 0.0 - if inv.type == 'purchase' and inv.term_id and _get_payment_term_lines(inv.term_id.id, credit or debit): - terms = _get_payment_term_lines(inv.term_id.id, credit or debit) - for term in terms: - due_date = term[0] - amount = term[1] - move_line = { - 'name':inv.name or '/', - 'debit':0.0, - 'credit':amount, - 'date_maturity':due_date, - 'account_id':inv.account_id.id, - 'move_id':move_id , - 'journal_id':inv.journal_id.id, - 'period_id':inv.period_id.id, - 'partner_id':inv.partner_id.id, - 'currency_id':inv.currency_id.id, - 'date':inv.date - } - master_line = move_line_pool.create(cr, uid, move_line) - else: - move_line = { - 'name':inv.name or '/', - 'debit':debit, - 'credit':credit, - 'account_id':inv.account_id.id, - 'move_id':move_id , - 'journal_id':inv.journal_id.id, - 'period_id':inv.period_id.id, - 'partner_id':inv.partner_id.id, - 'currency_id':inv.currency_id.id, - 'date':inv.date - } - master_line = move_line_pool.create(cr, uid, move_line) + + move_line = { + 'name':inv.name or '/', + 'debit':debit, + 'credit':credit, + 'account_id':inv.account_id.id, + 'move_id':move_id , + 'journal_id':inv.journal_id.id, + 'period_id':inv.period_id.id, + 'partner_id':inv.partner_id.id, + 'currency_id':inv.currency_id.id, + 'date':inv.date, + 'date_maturity':inv.date_due + } + master_line = move_line_pool.create(cr, uid, move_line) rec_list_ids = [] line_total = debit - credit + + if inv.type == 'sale': + line_total = line_total - inv.tax_amount + elif inv.type == 'purchase': + line_total = line_total + inv.tax_amount + for line in inv.line_ids: if not line.amount: continue amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, line.amount) move_line = { + 'journal_id':inv.journal_id.id, + 'period_id':inv.period_id.id, 'name':line.name and line.name or '/', 'account_id':line.account_id.id, 'move_id':move_id, 'partner_id':inv.partner_id.id, 'currency_id':inv.currency_id.id, 'analytic_account_id':line.account_analytic_id and line.account_analytic_id.id or False, - 'quantity':1 + 'quantity':1, + 'credit':0.0, + 'debit':0.0, + 'date':inv.date } if amount < 0: amount = -amount @@ -530,7 +533,7 @@ class account_voucher(osv.osv): line.type = 'cr' else: line.type = 'dr' - + if (line.type=='dr'): line_total += amount move_line['debit'] = amount @@ -538,43 +541,16 @@ class account_voucher(osv.osv): line_total -= amount move_line['credit'] = amount + if inv.tax_id: + move_line.update({ + 'account_tax_id':inv.tax_id.id, + }) + master_line = move_line_pool.create(cr, uid, move_line) if line.move_line_id.id: rec_ids = [master_line, line.move_line_id.id] rec_list_ids.append(rec_ids) - if inv.tax_amount: - amount = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount) - name = inv.tax_id and inv.tax_id.name or '/' - move_line = { - 'name':name, - 'move_id':move_id , - 'journal_id':inv.journal_id.id, - 'period_id':inv.period_id.id, - 'partner_id':inv.partner_id.id, - 'currency_id':inv.currency_id.id, - } - if inv.journal_id.type in ('sale','purchase_refund') and amount > 0: - line_total -= amount - move_line['credit'] = amount - else: - if amount < 0: - amount = -amount - line_total += amount - move_line['debit'] = amount - - account_id = False - if inv.tax_id: - if inv.journal_id.type in ('sale_refund','purchase_refund'): - account_id = inv.tax_id.account_paid_id - else: - account_id = inv.tax_id.account_collected_id.id - if not account_id: - raise osv.except_osv(_('Invalid Error !'), _('No account defined on the related tax !')) - move_line['account_id'] = account_id - - move_line_id = move_line_pool.create(cr, uid, move_line) - if not self.pool.get('res.currency').is_zero(cr, uid, inv.currency_id, line_total): diff = line_total move_line = { @@ -682,7 +658,7 @@ class account_voucher_line(osv.osv): 'date_original': fields.related('move_line_id','date', type='date', relation='account.move.line', string='Date', readonly=1), 'date_due': fields.related('move_line_id','date_maturity', type='date', relation='account.move.line', string='Due Date', readonly=1), 'amount_original': fields.function(_compute_balance, method=True, type='float', string='Originial Amount', store=True), - 'amount_unreconciled': fields.related('move_line_id','amount_unreconciled', type='float', relation='account.move.line', string='Open Balance', readonly="1"), + 'amount_unreconciled': fields.related('move_line_id','amount_unreconciled', type='float', relation='account.move.line', string='Open Balance', store=True, readonly="1"), } _defaults = { 'name': lambda *a: '' diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 6f207f2b649..03ebcb1e67a 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -14,7 +14,7 @@ widget="selection" select="1" on_change="onchange_partner_id(partner_id, journal_id, amount)" string="Payment Method"/> - + - +