From 237c2a72407659ec3909127a8df59fb6f0d5c2ab Mon Sep 17 00:00:00 2001 From: vra Date: Fri, 13 Aug 2010 19:44:06 +0530 Subject: [PATCH 01/33] [ADD][FIX][IMP] account: added property field for reserve & surplus account reference to company object, fixed type head problem in uk minimum chart, configuration chart, account minimum chart. bzr revid: vra@tinyerp.com-20100813141406-4a5m4jty2g873r7o --- addons/account/account.py | 5 +- addons/account/account_view.xml | 1 + addons/account/company.py | 9 + addons/account/company_view.xml | 16 + addons/account/configurable_account_chart.xml | 609 ++++++++++-------- addons/account/demo/account_minimal.xml | 449 ++++++------- addons/account/installer.py | 5 +- .../wizard/account_report_balance_sheet.py | 7 +- .../account_report_balance_sheet_view.xml | 4 +- .../l10n_chart_uk_minimal/account_chart.xml | 442 ++++++------- addons/l10n_chart_uk_minimal/account_tax.xml | 1 + .../l10n_chart_uk_minimal/account_types.xml | 56 +- addons/l10n_in/account_chart.xml | 1 + 13 files changed, 865 insertions(+), 740 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 52bee770bef..8b7d286cb6b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2342,6 +2342,7 @@ class account_chart_template(osv.osv): 'property_account_income_categ': fields.many2one('account.account.template','Income Category Account'), 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), + 'property_reserve_and_surplus_account': fields.many2one('account.account.template', 'Reserve and Surplus Account', domain=[('type', '=', 'payable')] , help='This Account is used for trasfering Profit/Loss(If It is Profit : Amount will be added, Loss : Amount will be duducted.), Which is calculated from Profilt & Loss Report'), } account_chart_template() @@ -2725,7 +2726,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): ('property_account_expense_categ','product.category','account.account'), ('property_account_income_categ','product.category','account.account'), ('property_account_expense','product.template','account.account'), - ('property_account_income','product.template','account.account') + ('property_account_income','product.template','account.account'), + ('property_reserve_and_surplus_account','res.company','account.account') ] for record in todo_list: r = [] @@ -2738,6 +2740,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'fields_id': field[0], 'value': account and 'account.account,'+str(acc_template_ref[account.id]) or False, } + if r: #the property exist: modify it property_obj.write(cr, uid, r, vals) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 31d4b39e5b1..ae458a0aac4 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2080,6 +2080,7 @@ + diff --git a/addons/account/company.py b/addons/account/company.py index 613c702a46e..ec106616c0d 100644 --- a/addons/account/company.py +++ b/addons/account/company.py @@ -25,6 +25,15 @@ class res_company(osv.osv): _inherit = "res.company" _columns = { 'overdue_msg' : fields.text('Overdue Payments Message', translate=True), + 'property_reserve_and_surplus_account': fields.property( + 'account.account', + type='many2one', + relation='account.account', + string="Reserve and Surplus Account", + method=True, + view_load=True, + domain="[('type', '=', 'payable')]", + help="This Account is used for trasfering Profit/Loss(If It is Profit : Amount will be added, Loss : Amount will be duducted.), Which is calculated from Profilt & Loss Report"), } _defaults = { diff --git a/addons/account/company_view.xml b/addons/account/company_view.xml index 7892fceee91..a3a1ec0080a 100644 --- a/addons/account/company_view.xml +++ b/addons/account/company_view.xml @@ -15,5 +15,21 @@ + + + res.company.form.inherit + + res.company + form + + + + + + + + + + diff --git a/addons/account/configurable_account_chart.xml b/addons/account/configurable_account_chart.xml index b9e063dc509..053b8429c0f 100644 --- a/addons/account/configurable_account_chart.xml +++ b/addons/account/configurable_account_chart.xml @@ -2,16 +2,18 @@ - - + + Receivable receivable + income unreconciled Payable payable + expense unreconciled @@ -21,50 +23,86 @@ none + + Income View + view + income + + + Expense View + expense + expense + + + Asset View + asset + asset + + + Liability View + liability + liability + + Income income + income none Expense expense + expense none Tax tax + expense unreconciled Cash cash + asset balance + + Liability + liability + liability + balance + + Asset asset + asset balance Equity equity + asset balance Bank bank + asset balance Check check + asset balance @@ -79,183 +117,193 @@ - + - - 1 - Balance Sheet - - view - - - - - 10 - Fixed Assets - - view - - - - - 100 - Fixed Asset Account - - other - - - - - 11 - Net Current Assets - - view - - - - - 110 - Current Assets - - view - - - - - 1101 - Purchased Stocks - - other - - - - - 1102 - Debtors - - receivable - - - - - - - - 1103 - Output VAT - - other - - - - - 1104 - Bank Current Account - - view - - - - - 1105 - Cash - - view - - - - - 111 - Current Liabilities - - view - - - - - 1111 - Creditors - - payable - - - - - - - - 1112 - Input VAT - - other - - - - - - - 2 - Profit and Loss - - view - - - - - 20 - Revenue - - view - - - - - 200 - Product Sales - - other - - - - - - - 21 - Cost of Sales - - view - - - - - 210 - Cost of Goods Sold - - other - - - - - 22 - Overheads - - view - - - - - 220 - Expenses - - other - - + + 1 + Balance Sheet + + view + + + + + 10 + Fixed Assets + + view + + + + + 100 + Fixed Asset Account + + other + + + + + 11 + Net Current Assets + + view + + + + + 110 + Current Assets + + view + + + + + 1101 + Purchased Stocks + + other + + + + + 1102 + Debtors + + receivable + + + + + + + + 1103 + Output VAT + + other + + + + + 1104 + Bank Current Account + + view + + + + + + + + + + + + + 111 + Current Liabilities + + view + + + + + 1111 + Creditors + + payable + + + + + + + + 1112 + Input VAT + + other + + + + + 1113 + Reserve and Surplus Account + + payable + + + + + + + + + 2 + Profit and Loss + + view + + + + + 20 + Revenue + + view + + + + + 200 + Product Sales + + other + + + + + + + 21 + Cost of Sales + + view + + + + + 210 + Cost of Goods Sold + + other + + + + + 22 + Overheads + + view + + + + + 220 + Expenses + + other + + - - Plan Fees - - VAT Balance to Pay - - + + VAT Balance to Pay + + - - Input VAT - - - + + + Input VAT + + + - - Input VAT Rate S (15%) - - + + Input VAT Rate S (15%) + + + + + Input VAT Rate R (5%) + + - - Input VAT Rate R (5%) - - + + + + Output VAT + + - + + Output VAT Rate S (15%) + + + + + Output VAT Rate R (5%) + + - - Output VAT - - - - Output VAT Rate S (15%) - - + + + + + + Tax Bases + + - - Output VAT Rate R (5%) - - + + Taxable Purchases Base + + - + + Taxable Purchases Rated S (15%) + + + + + Taxable Purchases Rated R (5%) + + + + + Taxable Purchases Rated Z (0%) + + - + + Taxable Purchases Type X (Exempt) + + + + + Taxable Purchases Type O (Out of scope) + + - - Tax Bases - - + + + + Base of Taxable Sales + + - - Taxable Purchases Base - - + + Taxable Sales Rated S (15%) + + + + + Taxable Sales Rated R (5%) + + + + + Taxable Sales Rated Z (0%) + + - - Taxable Purchases Rated S (15%) - - - - - Taxable Purchases Rated R (5%) - - - - - Taxable Purchases Rated Z (0%) - - - - - Taxable Purchases Type X (Exempt) - - - - - Taxable Purchases Type O (Out of scope) - - - - - - - Base of Taxable Sales - - - - - Taxable Sales Rated S (15%) - - - - - Taxable Sales Rated R (5%) - - - - - Taxable Sales Rated Z (0%) - - - - - Taxable Sales Type X (Exempt) - - - - - Taxable Sales Type O (Out of scope) - - + + Taxable Sales Type X (Exempt) + + + + + Taxable Sales Type O (Out of scope) + + Configurable Account Chart Template - + + - + - + IVAT S percent @@ -410,7 +459,7 @@ - + IVAT R percent diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index d7a85753ab1..df43c81b3b7 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -4,6 +4,7 @@ + View view @@ -70,225 +71,234 @@ - + + + + X1 + Balance Sheet - (test) + + view + + + + + Assets - (test) + X10 + view + + + + - - X1 - Balance Sheet - (test) - - view - - + + X100 + Fixed Assets - (test) + + view + + + + + X1000 + Fixed Asset Account - (test) + + other + + + + + X101 + Net Current Assets - (test) + + view + + + + + X1100 + Current Assets - (test) + + view + + + + + X11001 + Purchased Stocks - (test) + + other + + + + + X11002 + Debtors - (test) + + receivable + + + + + + X11003 + Output VAT - (test) + + other + + + + + X11004 + Bank Current Account - (test) + + other + + + + + X11005 + Cash - (test) + + other + + + + + Liabilities - (test) + X11 + view + + + + + + + X110 + Current Liabilities - (test) + + view + + + + + X1111 + Creditors - (test) + + payable + + + + + + X1112 + Input VAT - (test) + + other + + + + + X1113 + Reserve and Surplus - (test) + + payable + + + + + + + X2 + Profit and Loss - (test) + + view + + + + + Income - (test) + X20 + view + + + + + + + Foreign Exchange Gain - (test) + X201 + other + + + + - - Assets - (test) - X10 - view - - - - + + X200 + Revenue - (test) + + view + + + + + X2001 + Product Sales - (test) + + other + + - - Liabilities - (test) - X11 - view - - - - - - - X100 - Fixed Assets - (test) - - view - - - - - X1000 - Fixed Asset Account - (test) - - other - - - - - X101 - Net Current Assets - (test) - - view - - - - - X1100 - Current Assets - (test) - - view - - - - - X11001 - Purchased Stocks - (test) - - other - - - - - X11002 - Debtors - (test) - - receivable - - - - - - X11003 - Output VAT - (test) - - other - - - - - X11004 - Bank Current Account - (test) - - other - - - - - X11005 - Cash - (test) - - other - - - - - X110 - Current Liabilities - (test) - - view - - - - - X1111 - Creditors - (test) - - payable - - - - - - X1112 - Input VAT - (test) - - other - - - - - - - X2 - Profit and Loss - (test) - - view - - - - - Income - (test) - X20 - view - - - - - - - Foreign Exchange Gain - (test) - X201 - other - - - - - - - Expense - (test) - X21 - view - - - - - - - X200 - Revenue - (test) - - view - - - - - X2001 - Product Sales - (test) - - other - - - - - X210 - Cost of Sales - (test) - - view - - - - - X2100 - Cost of Goods Sold - (test) - - other - - - - - X211 - Overheads - (test) - - view - - - - - X2110 - Expenses - (test) - - other - - - - - Foreign Exchange Loss - (test) - X2111 - other - - - - + + Expense - (test) + X21 + view + + + + + + + + X210 + Cost of Sales - (test) + + view + + + + + X2100 + Cost of Goods Sold - (test) + + other + + + + + X211 + Overheads - (test) + + view + + + + + X2110 + Expenses - (test) + + other + + + + + Foreign Exchange Loss - (test) + X2111 + other + + + + @@ -310,6 +320,13 @@ + + property_account_receivable + + + + + + diff --git a/addons/l10n_chart_uk_minimal/account_chart.xml b/addons/l10n_chart_uk_minimal/account_chart.xml index 17eae399ef8..2dba2a46acb 100644 --- a/addons/l10n_chart_uk_minimal/account_chart.xml +++ b/addons/l10n_chart_uk_minimal/account_chart.xml @@ -11,241 +11,249 @@ - + + + + 1 + Balance Sheet + + view + + - - 1 - Balance Sheet - - view - - - - - Assets - 10 - view - - - - - - - Liabilities - 11 - view - - - - + + Liabilities + 11 + view + + + + + + + 110 + Current Liabilities + + view + + + + + 1111 + Creditors + + payable + + + + + + 1112 + Input VAT + + other + + + + + 1113 + Reserve and Surplus Account + + payable + + + + + + + Assets + 10 + view + + + + - - 100 - Fixed Assets - - view - - + + 100 + Fixed Assets + + view + + - - 1000 - Fixed Asset Account - - other - - + + 1000 + Fixed Asset Account + + other + + + + + 101 + Net Current Assets + + view + + - - 101 - Net Current Assets - - view - - + + 1100 + Current Assets + + view + + - - 1100 - Current Assets - - view - - + + 11001 + Purchased Stocks + + other + + - - 11001 - Purchased Stocks - - other - - + + 11002 + Debtors + + receivable + + + - - 11002 - Debtors - - receivable - - - + - + + 11003 + Output VAT + + other + + - - 11003 - Output VAT - - other - - + + 11004 + Bank Current Account + + other + + - - 11004 - Bank Current Account - - other - - + + 11005 + Cash + + other + + - - 11005 - Cash - - other - - - - 110 - Current Liabilities - - view - - - - - 1111 - Creditors - - payable - - - - - - - - 1112 - Input VAT - - other - - - - - - - 2 - Profit and Loss - - view - - + + + + 2 + Profit and Loss + + view + + - - Income - 20 - view - - - - + + Income + 20 + view + + + + - - Foreign Exchange Gain - X201 - other - - - - - - - Expense - 21 - view - - - - + + Foreign Exchange Gain + X201 + other + + + + + + + 200 + Revenue + + view + + + + + 2001 + Product Sales + + other + + + + + Expense + 21 + view + + + + - - 200 - Revenue - - view - - + + + + 210 + Cost of Sales + + view + + - - 2001 - Product Sales - - other - - + + 2100 + Cost of Goods Sold + + other + + - + + 211 + Overheads + + view + + - - 210 - Cost of Sales - - view - - - - - 2100 - Cost of Goods Sold - - other - - - - - 211 - Overheads - - view - - - - - 2110 - Expenses - - other - - - - - Foreign Exchange Loss - (test) - X2111 - other - - - - - - + + 2110 + Expenses + + other + + + + Foreign Exchange Loss - (test) + X2111 + other + + + + + + diff --git a/addons/l10n_chart_uk_minimal/account_tax.xml b/addons/l10n_chart_uk_minimal/account_tax.xml index 502cea9b0d2..64375db5302 100644 --- a/addons/l10n_chart_uk_minimal/account_tax.xml +++ b/addons/l10n_chart_uk_minimal/account_tax.xml @@ -132,6 +132,7 @@ + diff --git a/addons/l10n_chart_uk_minimal/account_types.xml b/addons/l10n_chart_uk_minimal/account_types.xml index 180cf3a9b4a..d9bfb5344ad 100644 --- a/addons/l10n_chart_uk_minimal/account_types.xml +++ b/addons/l10n_chart_uk_minimal/account_types.xml @@ -5,14 +5,14 @@ Receivable receivable - asset + income unreconciled Payable payable - liability + expense unreconciled @@ -22,26 +22,30 @@ none - - Income View - view - income - - - Expense View - expense - expense - - - Asset View - asset - asset - - - Liability View - liability - liability - + + Income View + view + income + + + + Expense View + expense + expense + + + + Asset View + asset + asset + + + + Liability View + liability + liability + + Income income @@ -59,6 +63,7 @@ Tax tax + liability unreconciled @@ -69,6 +74,13 @@ balance + + Liability + liability + balance + liability + + Asset asset diff --git a/addons/l10n_in/account_chart.xml b/addons/l10n_in/account_chart.xml index 5bdc5df3c50..98817045dc4 100644 --- a/addons/l10n_in/account_chart.xml +++ b/addons/l10n_in/account_chart.xml @@ -580,6 +580,7 @@ + From 2eb60e24babd20c86f98b3b6c66f9a79a742b4c3 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Sat, 14 Aug 2010 02:30:41 +0530 Subject: [PATCH 02/33] [FIX]: make inactive complete demo chart of account bzr revid: mga@tinyerp.com-20100813210041-a5lbu9rj733if5sk --- addons/account/account.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 8b7d286cb6b..855cd42cd25 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -138,7 +138,6 @@ class account_payment_term_line(osv.osv): account_payment_term_line() - class account_account_type(osv.osv): _name = "account.account.type" _description = "Account Type" @@ -2783,9 +2782,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): if data_id: data = data_pool.browse(cr, uid, data_id[0]) account_id = data.res_id + acc_ids = obj_acc._get_children_and_consol(cr, uid, [account_id]) if account_id: - cr.execute("update account_account set active='f' where id=%s" % (account_id)) - + cr.execute("update account_account set active='f' where id in " + str(tuple(acc_ids))) wizard_multi_charts_accounts() class account_bank_accounts_wizard(osv.osv_memory): From da8e7a018f9884c9056175639ba8c2e73d973831 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Sat, 14 Aug 2010 02:32:45 +0530 Subject: [PATCH 03/33] [IMP]: improvement to the account voucher and voucher payment module suggested by fp@tinyerp.com bzr revid: mga@tinyerp.com-20100813210245-6p4b41ef3we132ua --- addons/account_voucher/voucher.py | 352 ++++++++++++------ addons/account_voucher/voucher_view.xml | 36 +- .../account_voucher_payment.py | 35 +- .../account_voucher_payment_view.xml | 4 +- 4 files changed, 273 insertions(+), 154 deletions(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 4a1d62c4d92..751a2528439 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -25,12 +25,10 @@ from osv import osv from tools.translate import _ journal2type = { - 'cash':'rec_voucher', - 'bank':'bank_rec_voucher', - 'cash':'pay_voucher', - 'sale':'journal_sale_vou', - 'purchase':'journal_pur_voucher', - 'general':'journal_voucher' + 'bank':'receipt', + 'cash':'receipt', + 'sale':'sale', + 'purchase':'purchase' } type2journal = { @@ -85,9 +83,7 @@ class account_voucher(osv.osv): if context.get('journal_id', False): return context.get('journal_id') - type_inv = context.get('type', 'rec_voucher') - - ttype = type2journal.get(type_inv, type_inv) + ttype = context.get('type', 'bank') res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) if res: @@ -108,19 +104,16 @@ class account_voucher(osv.osv): _columns = { 'name':fields.char('Name', size=256, required=True, readonly=True, states={'draft':[('readonly',False)]}), 'type': fields.selection([ - ('pay_voucher','Cash Payment'), - ('bank_pay_voucher','Bank Payment'), - ('rec_voucher','Cash Receipt'), - ('bank_rec_voucher','Bank Receipt'), - ('journal_sale_vou','Journal Sale'), - ('journal_pur_voucher','Journal Purchase'), - ('journal_voucher','Journal Voucher'), - ],'Entry Type', select=True , size=128, readonly=True, states={'draft':[('readonly',False)]}), + ('payment', 'Payment'), + ('receipt', 'Receipt'), + ('sale', 'Sales'), + ('purchase', 'Purchase')], + 'Default Type', select=True , size=128, readonly=True, states={'draft':[('readonly',False)]}), 'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"), 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}, domain=[('type','<>','view')]), 'payment_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}), - 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'posted':[('readonly',False)]}), + 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}), 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'company_id': fields.many2one('res.company', 'Company', required=True), @@ -141,7 +134,8 @@ class account_voucher(osv.osv): 'reference_type': fields.selection(_get_reference_type, 'Reference Type', required=True), 'number': fields.related('move_id', 'name', type="char", readonly=True, string='Number'), 'move_id':fields.many2one('account.move', 'Account Entry'), - 'move_ids':fields.many2many('account.move.line', 'voucher_id', 'account_id', 'rel_account_move', 'Real Entry'), + 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Real Entry'), + #'move_ids':fields.many2many('account.move.line', 'voucher_id', 'account_id', 'rel_account_move', 'Real Entry', readonly=True, states={'draft':[('readonly',False)]}), 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, states={'draft':[('readonly',False)]}) } @@ -167,43 +161,116 @@ class account_voucher(osv.osv): 'value':{'amount':balance} } - def onchange_journal(self, cr, uid, ids, journal_id, type): + def onchange_journal(self, cr, uid, ids, journal_id, ttype): + res = {'account_id':False} + if not journal_id: return { - 'value':{'account_id':False} + 'value':res } - journal = self.pool.get('account.journal') - - if journal_id and (type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher','journal_voucher')): - account_id = journal.browse(cr, uid, journal_id).default_debit_account_id - return { - 'value':{'account_id':account_id.id} - } - elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_vou')) : - account_id = journal.browse(cr, uid, journal_id).default_credit_account_id - return { - 'value':{'account_id':account_id.id} - } + journal_pool = self.pool.get('account.journal') + journal = journal_pool.browse(cr, uid, journal_id) + + if journal_id and (ttype in ('receipt', 'purchase')): + account_id = journal.default_debit_account_id + res.update({ + 'account_id':account_id.id + }) + elif journal_id and (ttype in ('payment','sale')) : + account_id = journal.default_credit_account_id + res.update({ + 'account_id':account_id.id + }) else: - account_id = journal.browse(cr, uid, journal_id).default_credit_account_id - return { - 'value':{'account_id':account_id.id} - } + account_id = journal.default_credit_account_id + res.update({ + 'account_id':account_id.id + }) - def open_voucher(self, cr, uid, ids, context={}): - voucher = self.pool.get('account.voucher').browse(cr, uid, ids)[0] - total = 0 + if journal.type in ('sale', 'purchase') and not ttype: + res.update({ + 'type':journal.type + }) + + return { + 'value':res + } + + def open_voucher(self, dbcr, uid, ids, context={}): + cr = 0.0 + dr = 0.0 + total = 0.0 + new_line = [] + + position_pool = self.pool.get('account.fiscal.position') + voucher_pool = self.pool.get('account.voucher') + voucher_line_pool = self.pool.get('account.voucher.line') + partner_pool = self.pool.get('res.partner') + tax_pool = self.pool.get('account.tax') + + line_ids = voucher_line_pool.search(dbcr, uid, [('voucher_id','=',ids[0]), ('is_tax','=',True)]) + if line_ids: + voucher_line_pool.unlink(dbcr, uid, line_ids) + + voucher = voucher_pool.browse(dbcr, uid, ids[0]) + if voucher.account_id.tax_ids: + if voucher.account_id.tax_ids: + for line in voucher.payment_ids: + + if line.amount <= 0: + raise osv.except_osv(_('Invalid amount !'), _('You can not create Pro-Forma voucher with Total amount <= 0 !')) + + part = line.partner_id and partner_pool.browse(dbcr, uid, line.partner_id.id) or False + taxes = position_pool.map_tax(dbcr, uid, part and part.property_account_position or False, voucher.account_id.tax_ids) + taxes = tax_pool.browse(dbcr, uid, taxes) + new_price = line.amount + for tax in tax_pool.compute_all(dbcr, uid, taxes, line.amount, 1).get('taxes'): + tax_line = { + 'name':"%s / %s" % (line.name, tax.get('name')), + 'amount':tax.get('amount'), + 'voucher_id': voucher.id, + 'is_tax':True + } + crdr = False + account = False + if voucher.type == 'purchase': + crdr = 'dr' + account = tax.get('account_paid_id') + elif voucher.type == 'sale': + crdr = 'cr' + account = tax.get('account_collected_id', account) + + tax_line.update({ + 'account_id':account or voucher.account_id.id, + 'type':crdr + }) + new_line += [tax_line] + + + if new_line: + for line in new_line: + voucher_line_pool.create(dbcr, uid, line) + + voucher = voucher_pool.browse(dbcr, uid, ids[0]) for line in voucher.payment_ids: - total += line.amount + if line.type == 'cr': + cr += line.amount + else: + dr += line.amount + + if cr > dr: + total = cr - dr + else: + total = dr - cr if total != 0: res = { 'amount':total, 'state':'proforma' } - self.write(cr, uid, ids, res) + self.write(dbcr, uid, ids, res) else: - raise osv.except_osv(_('Invalid action !'), _('You can not post to Pro-Forma a voucher with Total amount = 0 !')) + raise osv.except_osv(_('Invalid amount !'), _('You can not create Pro-Forma voucher with Total amount <= 0 !')) return True def proforma_voucher(self, cr, uid, ids, context={}): @@ -229,16 +296,20 @@ class account_voucher(osv.osv): def cancel_voucher(self, cr, uid, ids, context={}): move_pool = self.pool.get('account.move') + voucher_line_pool = self.pool.get('account.voucher.line') for voucher in self.browse(cr, uid, ids): if voucher.move_id: move_pool.button_cancel(cr, uid, [voucher.move_id.id]) move_pool.unlink(cr, uid, [voucher.move_id.id]) - + + line_ids = voucher_line_pool.search(cr, uid, [('voucher_id','=',voucher.id), ('is_tax','=',True)]) + if line_ids: + voucher_line_pool.unlink(cr, uid, line_ids) + res = { 'state':'cancel', 'move_id':False, - 'move_ids':[(6, 0,[])] } self.write(cr, uid, ids, res) return True @@ -267,33 +338,27 @@ class account_voucher(osv.osv): if inv.move_id: continue - + journal = journal_pool.browse(cr, uid, inv.journal_id.id) - if inv.type in ('journal_pur_voucher', 'journal_sale_vou'): - if journal.invoice_sequence_id: - name = sequence_pool.get_id(cr, uid, journal.invoice_sequence_id.id) - else: - raise osv.except_osv(_('Error !'), _('Please define invoice sequence on %s journal !' % (journal.name))) + if journal.sequence_id: + name = sequence_pool.get_id(cr, uid, journal.sequence_id.id) else: - if journal.sequence_id: - name = sequence_pool.get_id(cr, uid, journal.sequence_id.id) - else: - raise osv.except_osv(_('Error !'), _('Please define sequence on journal !')) + raise osv.except_osv(_('Error !'), _('Please define sequence on journal !')) ref = False - if inv.type in ('journal_pur_voucher', 'bank_rec_voucher', 'rec_voucher'): + if inv.type in ('purchase', 'receipt'): ref = inv.reference else: ref = invoice_pool._convert_ref(cr, uid, name) company_currency = inv.company_id.currency_id.id diff_currency_p = inv.currency_id.id <> company_currency - + move = { - 'name':name, - 'journal_id':journal.id, - 'type':inv.type, - 'narration':inv.narration and inv.narration or inv.name, + 'name' : name, + 'journal_id': journal.id, + 'type' : inv.type, + 'narration' : inv.narration and inv.narration or inv.name, 'date':inv.date, 'ref':ref } @@ -307,16 +372,16 @@ class account_voucher(osv.osv): #create the first line manually move_line = { - 'name': inv.name, - 'debit': False, + 'name':inv.name, + 'debit':False, 'credit':False, - 'account_id': inv.account_id.id or False, - 'move_id': move_id , - 'journal_id': inv.journal_id.id, - 'period_id': inv.period_id.id, - 'partner_id': False, + 'account_id':inv.account_id.id or False, + 'move_id':move_id , + 'journal_id':inv.journal_id.id, + 'period_id':inv.period_id.id, + 'partner_id':False, 'ref':ref, - 'date': inv.date + 'date':inv.date } if diff_currency_p: amount_currency = currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.amount) @@ -326,19 +391,21 @@ class account_voucher(osv.osv): 'currency_id':inv.currency_id.id }) - if inv.type in ('rec_voucher', 'bank_rec_voucher', 'journal_pur_voucher', 'journal_voucher'): + if inv.type in ('receipt', 'purchase'): move_line['debit'] = inv.amount else: move_line['credit'] = inv.amount line_ids = [] line_ids += [move_line_pool.create(cr, uid, move_line)] + rec_ids = [] + for line in inv.payment_ids: amount=0.0 - - if inv.type in ('bank_pay_voucher', 'pay_voucher', 'journal_voucher'): + + if inv.type in ('payment'): ref = line.ref - + move_line = { 'name':line.name, 'debit':False, @@ -371,13 +438,13 @@ class account_voucher(osv.osv): 'debit': line.amount or False }) amount = line.amount - + elif line.type == 'cr': move_line.update({ 'credit': line.amount or False }) - amount = line.amount * (-1) - + amount = line.amount + move_line_id = move_line_pool.create(cr, uid, move_line) line_ids += [move_line_id] @@ -396,38 +463,41 @@ class account_voucher(osv.osv): def _convert_ref(self, cr, uid, ref): return (ref or '').replace('/','') - def name_get(self, cr, uid, ids, context={}): - if not len(ids): - return [] - types = { - 'pay_voucher': 'CPV: ', - 'rec_voucher': 'CRV: ', - 'cont_voucher': 'CV: ', - 'bank_pay_voucher': 'BPV: ', - 'bank_rec_voucher': 'BRV: ', - 'journal_sale_vou': 'JSV: ', - 'journal_pur_voucher': 'JPV: ', - 'journal_voucher':'JV' +# def name_get(self, cr, uid, ids, context={}): +# if not len(ids): +# return [] +# types = { +# 'pay_voucher': 'CPV: ', +# 'rec_voucher': 'CRV: ', +# 'cont_voucher': 'CV: ', +# 'bank_pay_voucher': 'BPV: ', +# 'bank_rec_voucher': 'BRV: ', +# 'journal_sale_vou': 'JSV: ', +# 'journal_pur_voucher': 'JPV: ', +# 'journal_voucher':'JV' +# } +# return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')] + +# def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): +# if not args: +# args=[] +# if not context: +# context={} +# ids = [] +# if name: +# ids = self.search(cr, user, [('number','=',name)]+args, limit=limit, context=context) +# if not ids: +# ids = self.search(cr, user, [('name',operator,name)]+args, limit=limit, context=context) +# return self.name_get(cr, user, ids, context) + + def copy(self, cr, uid, id, default={}, context=None): + res = { + 'state':'draft', + 'number':False, + 'move_id':False, + 'payment_ids':False } - return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')] - - def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): - if not args: - args=[] - if not context: - context={} - ids = [] - if name: - ids = self.search(cr, user, [('number','=',name)]+args, limit=limit, context=context) - if not ids: - ids = self.search(cr, user, [('name',operator,name)]+args, limit=limit, context=context) - return self.name_get(cr, user, ids, context) - - def copy(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - default = default.copy() - default.update({'state':'draft', 'number':False, 'move_id':False, 'move_ids':False, 'payment_ids':False}) + default.update(res) if 'date' not in default: default['date'] = time.strftime('%Y-%m-%d') return super(account_voucher, self).copy(cr, uid, id, default, context) @@ -445,12 +515,64 @@ class account_voucher_line(osv.osv): 'amount':fields.float('Amount'), 'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Type'), 'ref':fields.char('Reference', size=32), - 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account') + 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), + 'is_tax':fields.boolean('Tax ?', required=False), } _defaults = { 'type': lambda *a: 'cr' } + def onchange_type(self, cr, uid, ids, partner_id, ttype ,type1, currency): + currency_pool = self.pool.get('res.currency') + company = self.pool.get('res.users').browse(cr, uid, uid).company_id + + vals = { + 'account_id': False, + 'type': False , + 'amount': False + } + + if not partner_id: + return { + 'value':vals + } + + partner_pool = self.pool.get('res.partner') + account_id = False + + partner = partner_pool.browse(cr, uid, partner_id) + balance = 0.0 + + if ttype == 'cr' and type1 in ('receipt'): + account_id = partner.property_account_receivable.id + balance = partner.credit + + elif ttype == 'dr' and type1 in ('payment'): + account_id = partner.property_account_payable.id + balance = partner.debit + + elif ttype == 'dr' and type1 in ('sale'): + account_id = partner.property_account_receivable.id + + elif ttype == 'cr' and type1 in ('purchase'): + account_id = partner.property_account_payable.id + + else: + raise osv.except_osv(_('Invalid Configuration !'), _('You can not encode unbalanced entry !')) + + if company.currency_id != currency: + balance = currency_pool.compute(cr, uid, company.currency_id.id, currency, balance) + + vals.update({ + 'account_id': account_id, + 'type': ttype, + 'amount':balance + }) + + return { + 'value':vals + } + def onchange_partner(self, cr, uid, ids, partner_id, ttype ,type1, currency): currency_pool = self.pool.get('res.currency') company = self.pool.get('res.users').browse(cr, uid, uid).company_id @@ -463,7 +585,7 @@ class account_voucher_line(osv.osv): if not partner_id: return { - 'value' : vals + 'value':vals } partner_pool = self.pool.get('res.partner') @@ -472,24 +594,24 @@ class account_voucher_line(osv.osv): partner = partner_pool.browse(cr, uid, partner_id) balance = 0.0 - if type1 in ('rec_voucher', 'bank_rec_voucher', 'journal_voucher'): + if type1 in ('receipt'): account_id = partner.property_account_receivable.id balance = partner.credit ttype = 'cr' - elif type1 in ('pay_voucher', 'bank_pay_voucher', 'journal_voucher') : + elif type1 in ('payment'): account_id = partner.property_account_payable.id balance = partner.debit ttype = 'dr' - elif type1 in ('journal_sale_vou') : + elif type1 in ('sale'): account_id = partner.property_account_receivable.id ttype = 'dr' - elif type1 in ('journal_pur_voucher') : + elif type1 in ('purchase'): account_id = partner.property_account_payable.id ttype = 'cr' - + if company.currency_id != currency: balance = currency_pool.compute(cr, uid, company.currency_id.id, currency, balance) @@ -500,7 +622,7 @@ class account_voucher_line(osv.osv): }) return { - 'value' : vals + 'value':vals } account_voucher_line() diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index de708c671e0..8d44df40ee7 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -36,12 +36,12 @@ - + - + @@ -92,26 +92,28 @@ - - - - - + - + + + + + + - - - + + + + @@ -130,19 +132,15 @@ - - - - - + @@ -151,6 +149,12 @@ + + + + + + diff --git a/addons/account_voucher_payment/account_voucher_payment.py b/addons/account_voucher_payment/account_voucher_payment.py index 8c4e3984da4..4af9b1dd5ef 100755 --- a/addons/account_voucher_payment/account_voucher_payment.py +++ b/addons/account_voucher_payment/account_voucher_payment.py @@ -43,11 +43,11 @@ class account_invoice(osv.osv): if not context: context = {} ttype = context.get('ttype', False) - if ttype and ttype in ('rec_voucher', 'bank_rec_voucher'): + if ttype and ttype in ('receipt'): args += [('type','in', ['out_invoice', 'in_refund'])] - elif ttype and ttype in ('pay_voucher', 'bank_pay_voucher'): + elif ttype and ttype in ('payment'): args += [('type','in', ['in_invoice', 'out_refund'])] - elif ttype and ttype in('journal_sale_vou', 'journal_pur_voucher', 'journal_voucher'): + elif ttype and ttype in('sale', 'purchase'): raise osv.except_osv(_('Invalid action !'), _('You can not reconcile sales, purchase, or journal voucher with invoice !')) args += [('type','=', 'do_not_allow_search')] @@ -86,19 +86,13 @@ class account_voucher(osv.osv): continue journal = journal_pool.browse(cr, uid, inv.journal_id.id) - if inv.type in ('journal_pur_voucher', 'journal_sale_vou'): - if journal.invoice_sequence_id: - name = sequence_pool.get_id(cr, uid, journal.invoice_sequence_id.id) - else: - raise osv.except_osv(_('Error !'), _('Please define invoice sequence on %s journal !' % (journal.name))) + if journal.sequence_id: + name = sequence_pool.get_id(cr, uid, journal.sequence_id.id) else: - if journal.sequence_id: - name = sequence_pool.get_id(cr, uid, journal.sequence_id.id) - else: - raise osv.except_osv(_('Error !'), _('Please define sequence on journal !')) + raise osv.except_osv(_('Error !'), _('Please define sequence on journal !')) ref = False - if inv.type in ('journal_pur_voucher', 'bank_rec_voucher', 'rec_voucher'): + if inv.type in ('purchase', 'receipt'): ref = inv.reference else: ref = invoice_pool._convert_ref(cr, uid, name) @@ -143,7 +137,7 @@ class account_voucher(osv.osv): 'currency_id':inv.currency_id.id }) - if inv.type in ('rec_voucher', 'bank_rec_voucher', 'journal_pur_voucher', 'journal_voucher'): + if inv.type in ('receipt', 'purchase'): move_line['debit'] = inv.amount else: move_line['credit'] = inv.amount @@ -155,7 +149,7 @@ class account_voucher(osv.osv): for line in inv.payment_ids: amount=0.0 - if inv.type in ('bank_pay_voucher', 'pay_voucher', 'journal_voucher'): + if inv.type in ('payment'): ref = line.ref move_line = { @@ -200,7 +194,7 @@ class account_voucher(osv.osv): move_line_id = move_line_pool.create(cr, uid, move_line) line_ids += [move_line_id] - if line.invoice_id and inv.type in ('pay_voucher', 'bank_pay_voucher', 'rec_voucher', 'bank_rec_voucher'): + if line.invoice_id and inv.type in ('payment', 'receipt'): rec_ids += [move_line_id] for move_line in line.invoice_id.move_id.line_id: if line.account_id.id == move_line.account_id.id: @@ -211,7 +205,6 @@ class account_voucher(osv.osv): rec = { 'move_id': move_id, - 'move_ids':[(6, 0,line_ids)] } message = _('Voucher ') + " '" + inv.name + "' "+ _("is confirm") @@ -272,19 +265,19 @@ class account_voucher_line(osv.osv): obj = self.pool.get('account.account') acc_id = False - if type1 in ('rec_voucher','bank_rec_voucher', 'journal_voucher'): + if type1 in ('receipt'): acc_id = obj.browse(cr, uid, account_id) balance = acc_id.credit type = 'cr' - elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') : + elif type1 in ('payment') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.debit type = 'dr' - elif type1 in ('journal_sale_vou') : + elif type1 in ('sale') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.credit type = 'dr' - elif type1 in ('journal_pur_voucher') : + elif type1 in ('purchase') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.debit type = 'cr' diff --git a/addons/account_voucher_payment/account_voucher_payment_view.xml b/addons/account_voucher_payment/account_voucher_payment_view.xml index 6da4c7d45e2..6bc1484e81e 100755 --- a/addons/account_voucher_payment/account_voucher_payment_view.xml +++ b/addons/account_voucher_payment/account_voucher_payment_view.xml @@ -8,13 +8,13 @@ - + - + From 4e5f5bae3fd95506d72a4481113eb5d633c26a4d Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Sat, 14 Aug 2010 02:35:07 +0530 Subject: [PATCH 04/33] [FIX]: small change in label bzr revid: mga@tinyerp.com-20100813210507-hsvfy3as78fg52au --- addons/account_voucher/voucher_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index 8d44df40ee7..eb93df09629 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -58,7 +58,7 @@ - + @@ -212,7 +212,7 @@ - Cheque Register + Vouchers ir.actions.act_window account.voucher form From bdaee0229f4f352021512c0005bb5898ae16ac0b Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Sat, 14 Aug 2010 02:38:42 +0530 Subject: [PATCH 05/33] [IMP]: implement onchange_date, to select period depends on the date bzr revid: mga@tinyerp.com-20100813210842-9rxzooh86329csns --- addons/account_voucher/voucher.py | 25 +++++++++++++++++++++++++ addons/account_voucher/voucher_view.xml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 751a2528439..644d0b70148 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -150,6 +150,31 @@ class account_voucher(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c), } + def onchange_date(self, cr, user, ids, date, context={}): + """ + Returns a dict that contains new values and context + @param cr: A database cursor + @param user: ID of the user currently logged in + @param date: latest value from user input for field date + @param args: other arguments + @param context: context arguments, like lang, time zone + @return: Returns a dict which contains new values, and context + """ + res = {} + period_pool = self.pool.get('account.period') + pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)]) + if pids: + res.update({ + 'period_id':pids[0] + }) + context.update({ + 'period_id':pids[0] + }) + return { + 'value':res, + 'context':context, + } + def onchange_account(self, cr, uid, ids, account_id): if not account_id: return { diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index eb93df09629..f5978970cc6 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -54,7 +54,7 @@ - + From 040a9e861e2ac0236af7451c712b6d499a94e42c Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Sat, 14 Aug 2010 02:42:34 +0530 Subject: [PATCH 06/33] [IMP]: add audit fieild to voucher, to convert workflow audit functionality to field, to make workflow simple bzr revid: mga@tinyerp.com-20100813211234-sr5w1jebaw6rceon --- addons/account_voucher/voucher.py | 4 +++- addons/account_voucher/voucher_view.xml | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 644d0b70148..3bf9453b453 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -136,7 +136,8 @@ class account_voucher(osv.osv): 'move_id':fields.many2one('account.move', 'Account Entry'), 'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Real Entry'), #'move_ids':fields.many2many('account.move.line', 'voucher_id', 'account_id', 'rel_account_move', 'Real Entry', readonly=True, states={'draft':[('readonly',False)]}), - 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, states={'draft':[('readonly',False)]}) + 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True, states={'draft':[('readonly',False)]}), + 'audit':fields.boolean('Audit Complete ?', required=False), } _defaults = { @@ -147,6 +148,7 @@ class account_voucher(osv.osv): 'state': lambda *a: 'draft', 'date' : lambda *a: time.strftime('%Y-%m-%d'), 'reference_type': lambda *a: "none", + 'audit': lambda *a: False, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c), } diff --git a/addons/account_voucher/voucher_view.xml b/addons/account_voucher/voucher_view.xml index f5978970cc6..780d20d3ebb 100644 --- a/addons/account_voucher/voucher_view.xml +++ b/addons/account_voucher/voucher_view.xml @@ -59,8 +59,11 @@ - - + + + + + From 451388d0b93c0b18f0c7a82036d13e19d4fd9c32 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Sat, 14 Aug 2010 08:55:58 +0530 Subject: [PATCH 07/33] [IMP] Account: Invoice analysis report improved bzr revid: mra@mra-laptop-20100814032558-ze1d30hpkczh5duj --- .../account/report/account_invoice_report.py | 30 ++++++++++++------- .../report/account_invoice_report_view.xml | 5 ++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 8c590a58ad6..9021878d40a 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -31,10 +31,10 @@ class account_invoice_report(osv.osv): 'date': fields.date('Date', readonly=True), 'year': fields.char('Year', size=4, readonly=True), 'day': fields.char('Day', size=128, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), + 'month': fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), - 'product_id':fields.many2one('product.product', 'Product', readonly=True), + 'product_id': fields.many2one('product.product', 'Product', readonly=True), 'product_qty':fields.float('Qty', readonly=True), 'uom_name': fields.char('Default UoM', size=128, readonly=True), 'payment_term': fields.many2one('account.payment.term', 'Payment Term', readonly=True), @@ -43,11 +43,12 @@ class account_invoice_report(osv.osv): 'currency_id': fields.many2one('res.currency', 'Currency', readonly=True), 'categ_id': fields.many2one('product.category','Category of Product', readonly=True), 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True), - 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True), - 'company_id':fields.many2one('res.company', 'Company', readonly=True), - 'user_id':fields.many2one('res.users', 'Salesman', readonly=True), - 'price_total':fields.float('Total Price', readonly=True), - 'price_average':fields.float('Average Price', readonly=True), + 'partner_id': fields.many2one('res.partner', 'Partner', readonly=True), + 'company_id': fields.many2one('res.company', 'Company', readonly=True), + 'user_id': fields.many2one('res.users', 'Salesman', readonly=True), + 'price_total': fields.float('Total Without Tax', readonly=True), + 'price_total_tax': fields.float('Total With Tax', readonly=True), + 'price_average': fields.float('Average Price', readonly=True), 'nbr':fields.integer('# of Lines', readonly=True), 'type': fields.selection([ ('out_invoice','Customer Invoice'), @@ -68,8 +69,8 @@ class account_invoice_report(osv.osv): 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True), 'account_id': fields.many2one('account.account', 'Account',readonly=True), 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True), - 'residual':fields.float('Total Residual', readonly=True), - 'delay_to_pay':fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"), + 'residual': fields.float('Total Residual', readonly=True), + 'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"), } _order = 'date desc' def init(self, cr): @@ -110,6 +111,11 @@ class account_invoice_report(osv.osv): else ail.quantity*ail.price_unit end) as price_total, + sum(case when ai.type in ('out_refund','in_invoice') then + ai.amount_total * -1 + else + ai.amount_total + end) as price_total_tax, sum(ail.quantity*ail.price_unit)/sum(ail.quantity*u.factor)*count(ail.product_id)::decimal(16,2) as price_average, sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2) from account_move_line as aml @@ -150,7 +156,11 @@ class account_invoice_report(osv.osv): ai.address_invoice_id, ai.account_id, ai.partner_bank_id, - ai.residual + ai.residual, + ai.amount_total ) """) + account_invoice_report() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 0891577ce98..b241b725673 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -30,7 +30,8 @@ - + + @@ -75,7 +76,7 @@ help = "Draft Invoices"/> Date: Sat, 14 Aug 2010 09:06:52 +0530 Subject: [PATCH 08/33] [IMP] Account: Paid invoices must not be in grey color in the tree view. They must remain bzr revid: mra@mra-laptop-20100814033652-vg2ffjo8p6zfgvn5 --- addons/account/account_invoice_view.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 22df9059305..b71bec0d73f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -16,7 +16,7 @@ - + account.invoice.graph account.invoice @@ -28,7 +28,7 @@ - + account.invoice.line.tree account.invoice.line @@ -45,7 +45,7 @@ - + account.invoice.line.form account.invoice.line @@ -76,7 +76,7 @@ - + account.invoice.tax.tree account.invoice.tax @@ -92,7 +92,7 @@ - + account.invoice.tax.form account.invoice.tax @@ -119,7 +119,7 @@ account.invoice tree - + @@ -417,7 +417,7 @@ tree - + form @@ -437,13 +437,13 @@ Most of customer invoices are automatically generated in draft mode by OpenERP flows, following a purchase order for instance. Review, confirm or cancel, pay or refund your customers' invoices here. A manual invoice can be created here. - + tree - + form From 459d89648668e6507c553554b7c4d799f96dac8b Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Sat, 14 Aug 2010 09:19:05 +0530 Subject: [PATCH 09/33] [IMP] Account: Rename Credit Note into Refund bzr revid: mra@mra-laptop-20100814034905-3233nuwjcr2zdq5b --- addons/account/account_invoice_view.xml | 8 ++++---- addons/account/account_wizard.xml | 4 ---- addons/account/wizard/account_invoice_refund.py | 1 + addons/account/wizard/account_invoice_refund_view.xml | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index b71bec0d73f..4ef4a19eb3b 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -140,7 +140,7 @@