From c8a0a2a19165323500a15b4080512286174bf0d3 Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Thu, 17 Jun 2010 18:47:58 +0530 Subject: [PATCH 1/7] [IMP]: 1) added missing wizards under Financial Management/Periodical Processing 2) added entry_type on move line for different types of invoices bzr revid: pap@tinyerp.co.in-20100617131758-668hhpu1q1qkmt20 --- addons/account/account_view.xml | 22 +++++++++---------- addons/account/invoice.py | 21 +++++++++++++++--- .../account_subscription_generate_view.xml | 2 +- .../account/wizard/account_use_model_view.xml | 4 ++-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index cf117613189..694a48177d9 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1022,7 +1022,7 @@ - Journal Entries + Journal Vouchers account.move form tree,form @@ -1033,7 +1033,7 @@ - Journal Items + Receivable Entries account.move form tree,form @@ -1045,7 +1045,7 @@ - Transaction Journals + Payable Entries account.move form tree,form @@ -1167,20 +1167,20 @@ form,tree - - - - - + - - - + company_currency # create one move line for the total and possibly adjust the other lines amount @@ -847,7 +854,7 @@ class account_invoice(osv.osv): line = self.finalize_invoice_move_lines(cr, uid, inv, line) - move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date} + move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date, 'type': entry_type} period_id=inv.period_id and inv.period_id.id or False if not period_id: period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))]) @@ -1070,10 +1077,18 @@ class account_invoice(osv.osv): else: amount_currency = False currency_id = False + entry_type='' if invoice.type in ('in_invoice', 'in_refund'): ref = invoice.reference + entry_type = 'journal_pur_voucher' + if invoice.type in ('in_refund'): + entry_type = 'cont_voucher' else: ref = self._convert_ref(cr, uid, invoice.number) + entry_type = 'journal_sale_vou' + if invoice.type in ('out_refund'): + entry_type = 'cont_voucher' + # Pay attention to the sign for both debit/credit AND amount_currency l1 = { 'debit': direction * pay_amount>0 and direction * pay_amount, @@ -1104,7 +1119,7 @@ class account_invoice(osv.osv): l2['name'] = name lines = [(0, 0, l1), (0, 0, l2)] - move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} + move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date, 'type': entry_type} move_id = self.pool.get('account.move').create(cr, uid, move, context=context) line_ids = [] diff --git a/addons/account/wizard/account_subscription_generate_view.xml b/addons/account/wizard/account_subscription_generate_view.xml index cfe91171621..ad0e4f958d1 100644 --- a/addons/account/wizard/account_subscription_generate_view.xml +++ b/addons/account/wizard/account_subscription_generate_view.xml @@ -32,7 +32,7 @@ new - + diff --git a/addons/account/wizard/account_use_model_view.xml b/addons/account/wizard/account_use_model_view.xml index 6ca3de7aa65..9ff781ea53c 100644 --- a/addons/account/wizard/account_use_model_view.xml +++ b/addons/account/wizard/account_use_model_view.xml @@ -41,8 +41,8 @@ account.move.line - - + account.use.model.open.entry.form From 2506713fbc62903f2e27fc113d2107e60723ddee Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Fri, 18 Jun 2010 15:03:36 +0530 Subject: [PATCH 2/7] [IMP]:refund_journals on refund invoices created from invoices bzr revid: pap@tinyerp.co.in-20100618093336-0el3z13wro96fbwl --- addons/account/demo/account_minimal.xml | 4 ++-- addons/account/invoice.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/account/demo/account_minimal.xml b/addons/account/demo/account_minimal.xml index 37225273e03..18abf70dd80 100644 --- a/addons/account/demo/account_minimal.xml +++ b/addons/account/demo/account_minimal.xml @@ -169,7 +169,7 @@ your own chart of account. x Sales Credit Note Journal SCNJ - sale + sale_refund True @@ -191,7 +191,7 @@ your own chart of account. x Expenses Credit Notes Journal ECNJ - purchase + purchase_refund True diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 44bc5802889..65448aec41f 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -50,11 +50,12 @@ class account_invoice(osv.osv): type_inv = context.get('type', 'out_invoice') user = self.pool.get('res.users').browse(cr, uid, uid) company_id = context.get('company_id', user.company_id.id) - type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'} + type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale_refund', 'in_refund': 'purchase_refund'} refund_journal = {'out_invoice': False, 'in_invoice': False, 'out_refund': True, 'in_refund': True} journal_obj = self.pool.get('account.journal') res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')), - ('company_id', '=', company_id),('refund_journal', '=', refund_journal.get(type_inv, False))], + ('company_id', '=', company_id), + ('refund_journal', '=', refund_journal.get(type_inv, False))], limit=1) if res: return res[0] @@ -1011,7 +1012,7 @@ class account_invoice(osv.osv): def refund(self, cr, uid, ids, date=None, period_id=None, description=None): invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id']) - + new_ids = [] for invoice in invoices: del invoice['id'] @@ -1030,6 +1031,10 @@ class account_invoice(osv.osv): tax_lines = self.pool.get('account.invoice.tax').read(cr, uid, invoice['tax_line']) tax_lines = filter(lambda l: l['manual'], tax_lines) tax_lines = self._refund_cleanup_lines(cr, uid, tax_lines) + if invoice['type'] == 'in_invoice': + refund_journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','purchase_refund')]) + else: + refund_journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','sale_refund')]) if not date : date = time.strftime('%Y-%m-%d') invoice.update({ @@ -1038,7 +1043,8 @@ class account_invoice(osv.osv): 'state': 'draft', 'number': False, 'invoice_line': invoice_lines, - 'tax_line': tax_lines + 'tax_line': tax_lines, + 'journal_id': refund_journal_ids }) if period_id : invoice.update({ From d62cd51810b9ba0567ca13eb8fc98dc804d1444a Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Fri, 18 Jun 2010 16:33:55 +0530 Subject: [PATCH 3/7] [FIX]:payment_term on account.invoice generated error bzr revid: pap@tinyerp.co.in-20100618110355-gj9qlqd0na0dxnfy --- addons/account/account.py | 2 +- addons/analytic/i18n/analytic.pot | 251 ++++++++++++++++++++++++++++++ addons/analytic/i18n/en_US.po | 251 ++++++++++++++++++++++++++++++ 3 files changed, 503 insertions(+), 1 deletion(-) create mode 100644 addons/analytic/i18n/analytic.pot create mode 100644 addons/analytic/i18n/en_US.po diff --git a/addons/account/account.py b/addons/account/account.py index f946723e350..f6a5680e6f3 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -81,7 +81,7 @@ class account_payment_term(osv.osv): if amt: next_date = datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days) if line.days2 < 0: - next_date += relativedelta(day=line.days2) + next_date += relativedelta(day=31) if line.days2 > 0: next_date += relativedelta(day=line.days2, months=1) result.append( (next_date.strftime('%Y-%m-%d'), amt) ) diff --git a/addons/analytic/i18n/analytic.pot b/addons/analytic/i18n/analytic.pot new file mode 100644 index 00000000000..170243cf16e --- /dev/null +++ b/addons/analytic/i18n/analytic.pot @@ -0,0 +1,251 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * analytic +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0dev\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2010-06-18 10:59:19+0000\n" +"PO-Revision-Date: 2010-06-18 10:59:19+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: analytic +#: field:account.analytic.account,child_ids:0 +msgid "Child Accounts" +msgstr "" + +#. module: analytic +#: help:account.analytic.line,amount_currency:0 +msgid "The amount expressed in the related account currency if not equal to the company one." +msgstr "" + +#. module: analytic +#: constraint:ir.model:0 +msgid "The Object name must start with x_ and not contain any special character !" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,name:0 +msgid "Account Name" +msgstr "" + +#. module: analytic +#: help:account.analytic.line,unit_amount:0 +msgid "Specifies the amount of quantity to count." +msgstr "" + +#. module: analytic +#: help:account.analytic.line,currency_id:0 +msgid "The related account currency if not equal to the company one." +msgstr "" + +#. module: analytic +#: model:ir.module.module,description:analytic.module_meta_information +msgid "Module for defining analytic accounting object.\n" +" " +msgstr "" + +#. module: analytic +#: field:account.analytic.account,state:0 +msgid "State" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,user_id:0 +msgid "Account Manager" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Draft" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Closed" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,debit:0 +msgid "Debit" +msgstr "" + +#. module: analytic +#: help:account.analytic.account,state:0 +msgid "* When an account is created its in 'Draft' state. \n" +"* If any associated partner is there, it can be in 'Open' state. \n" +"* If any pending balance is there it can be in 'Pending'. \n" +"* And finally when all the transactions are over, it can be in 'Close' state. \n" +"* The project can be in either if the states 'Template' and 'Running'.\n" +" If it is template then we can make projects based on the template projects. If its in 'Running' state it is a normal project. \n" +" If it is to be reviewed then the state is 'Pending'.\n" +" When the project is completed the state is set to 'Done'." +msgstr "" + +#. module: analytic +#: field:account.analytic.account,type:0 +msgid "Account Type" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Template" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Pending" +msgstr "" + +#. module: analytic +#: model:ir.model,name:analytic.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,description:0 +#: field:account.analytic.line,name:0 +msgid "Description" +msgstr "" + +#. module: analytic +#: help:account.analytic.line,amount:0 +msgid "Calculated by multiplying the quantity and the price given in the Product's cost price." +msgstr "" + +#. module: analytic +#: field:account.analytic.account,company_id:0 +#: field:account.analytic.line,company_id:0 +msgid "Company" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,quantity_max:0 +msgid "Maximum Quantity" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,user_id:0 +msgid "User" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,parent_id:0 +msgid "Parent Analytic Account" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,date:0 +msgid "Date" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,currency_id:0 +#: field:account.analytic.line,currency_id:0 +msgid "Account currency" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,type:0 +msgid "View" +msgstr "" + +#. module: analytic +#: help:account.analytic.account,quantity_max:0 +msgid "Sets the higher limit of quantity of hours." +msgstr "" + +#. module: analytic +#: field:account.analytic.account,credit:0 +msgid "Credit" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,amount:0 +msgid "Amount" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,contact_id:0 +msgid "Contact" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Cancelled" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,balance:0 +msgid "Balance" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,date_start:0 +msgid "Date Start" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,quantity:0 +#: field:account.analytic.line,unit_amount:0 +msgid "Quantity" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,date:0 +msgid "Date End" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,code:0 +msgid "Account Code" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,type:0 +msgid "Normal" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,complete_name:0 +msgid "Full Account Name" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,account_id:0 +#: model:ir.model,name:analytic.model_account_analytic_account +#: model:ir.module.module,shortdesc:analytic.module_meta_information +msgid "Analytic Account" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,company_currency_id:0 +msgid "Currency" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,amount_currency:0 +msgid "Amount currency" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,partner_id:0 +msgid "Associated Partner" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Open" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,line_ids:0 +msgid "Analytic Entries" +msgstr "" + diff --git a/addons/analytic/i18n/en_US.po b/addons/analytic/i18n/en_US.po new file mode 100644 index 00000000000..65db82b92be --- /dev/null +++ b/addons/analytic/i18n/en_US.po @@ -0,0 +1,251 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * analytic +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0dev\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2010-06-18 11:01:12+0000\n" +"PO-Revision-Date: 2010-06-18 11:01:12+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: analytic +#: field:account.analytic.account,child_ids:0 +msgid "Child Accounts" +msgstr "" + +#. module: analytic +#: help:account.analytic.line,amount_currency:0 +msgid "The amount expressed in the related account currency if not equal to the company one." +msgstr "" + +#. module: analytic +#: constraint:ir.model:0 +msgid "The Object name must start with x_ and not contain any special character !" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,name:0 +msgid "Account Name" +msgstr "" + +#. module: analytic +#: help:account.analytic.line,unit_amount:0 +msgid "Specifies the amount of quantity to count." +msgstr "" + +#. module: analytic +#: help:account.analytic.line,currency_id:0 +msgid "The related account currency if not equal to the company one." +msgstr "" + +#. module: analytic +#: model:ir.module.module,description:analytic.module_meta_information +msgid "Module for defining analytic accounting object.\n" +" " +msgstr "" + +#. module: analytic +#: field:account.analytic.account,state:0 +msgid "State" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,user_id:0 +msgid "Account Manager" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Draft" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Closed" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,debit:0 +msgid "Debit" +msgstr "" + +#. module: analytic +#: help:account.analytic.account,state:0 +msgid "* When an account is created its in 'Draft' state. \n" +"* If any associated partner is there, it can be in 'Open' state. \n" +"* If any pending balance is there it can be in 'Pending'. \n" +"* And finally when all the transactions are over, it can be in 'Close' state. \n" +"* The project can be in either if the states 'Template' and 'Running'.\n" +" If it is template then we can make projects based on the template projects. If its in 'Running' state it is a normal project. \n" +" If it is to be reviewed then the state is 'Pending'.\n" +" When the project is completed the state is set to 'Done'." +msgstr "" + +#. module: analytic +#: field:account.analytic.account,type:0 +msgid "Account Type" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Template" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Pending" +msgstr "" + +#. module: analytic +#: model:ir.model,name:analytic.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,description:0 +#: field:account.analytic.line,name:0 +msgid "Description" +msgstr "" + +#. module: analytic +#: help:account.analytic.line,amount:0 +msgid "Calculated by multiplying the quantity and the price given in the Product's cost price." +msgstr "" + +#. module: analytic +#: field:account.analytic.account,company_id:0 +#: field:account.analytic.line,company_id:0 +msgid "Company" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,quantity_max:0 +msgid "Maximum Quantity" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,user_id:0 +msgid "User" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,parent_id:0 +msgid "Parent Analytic Account" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,date:0 +msgid "Date" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,currency_id:0 +#: field:account.analytic.line,currency_id:0 +msgid "Account currency" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,type:0 +msgid "View" +msgstr "" + +#. module: analytic +#: help:account.analytic.account,quantity_max:0 +msgid "Sets the higher limit of quantity of hours." +msgstr "" + +#. module: analytic +#: field:account.analytic.account,credit:0 +msgid "Credit" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,amount:0 +msgid "Amount" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,contact_id:0 +msgid "Contact" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Cancelled" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,balance:0 +msgid "Balance" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,date_start:0 +msgid "Date Start" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,quantity:0 +#: field:account.analytic.line,unit_amount:0 +msgid "Quantity" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,date:0 +msgid "Date End" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,code:0 +msgid "Account Code" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,type:0 +msgid "Normal" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,complete_name:0 +msgid "Full Account Name" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,account_id:0 +#: model:ir.model,name:analytic.model_account_analytic_account +#: model:ir.module.module,shortdesc:analytic.module_meta_information +msgid "Analytic Account" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,company_currency_id:0 +msgid "Currency" +msgstr "" + +#. module: analytic +#: field:account.analytic.line,amount_currency:0 +msgid "Amount currency" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,partner_id:0 +msgid "Associated Partner" +msgstr "" + +#. module: analytic +#: selection:account.analytic.account,state:0 +msgid "Open" +msgstr "" + +#. module: analytic +#: field:account.analytic.account,line_ids:0 +msgid "Analytic Entries" +msgstr "" + From da3906117926812c47647f38d7415b392e10cf7e Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Fri, 18 Jun 2010 16:44:50 +0530 Subject: [PATCH 4/7] [IMP]:renamed analytic/project.py to analytic/analytic.py bzr revid: pap@tinyerp.co.in-20100618111450-p6hvlvugv2wy8xxk --- addons/analytic/__init__.py | 2 +- addons/analytic/analytic.py | 344 ++++++++++++++++++++++++++++++++++++ 2 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 addons/analytic/analytic.py diff --git a/addons/analytic/__init__.py b/addons/analytic/__init__.py index dc48b6f4001..d0175cf1424 100644 --- a/addons/analytic/__init__.py +++ b/addons/analytic/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import project +import analytic # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py new file mode 100644 index 00000000000..f52dd23caa0 --- /dev/null +++ b/addons/analytic/analytic.py @@ -0,0 +1,344 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . +# +############################################################################## + +import time +import operator + +from osv import fields, osv +import decimal_precision as dp + +# +# Object definition +# + +class account_analytic_account(osv.osv): + _name = 'account.analytic.account' + _description = 'Analytic Account' + + def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, context={}): + # Handle multi-currency on each level of analytic account + # This is a refactoring of _balance_calc computation + cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),)) + currency= dict(cr.fetchall()) + res_currency= self.pool.get('res.currency') + for id in ids: + if id not in ids2: + continue + for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): + if child != id: + res.setdefault(id, 0.0) + if currency[child]!=currency[id]: + res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context) + else: + res[id] += res.get(child, 0.0) + + cur_obj = res_currency.browse(cr, uid, currency.values(), context) + cur_obj = dict([(o.id, o) for o in cur_obj]) + for id in ids: + if id in ids2: + res[id] = res_currency.round(cr, uid, cur_obj[currency[id]], res.get(id,0.0)) + + return dict([(i, res[i]) for i in ids ]) + + + def _credit_calc(self, cr, uid, ids, name, arg, context={}): + res = {} + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + for i in ids: + res.setdefault(i,0.0) + + if not parent_ids: + return res + + where_date = '' + if context.get('from_date',False): + where_date += " AND l.date >= '" + context['from_date'] + "'" + if context.get('to_date',False): + where_date += " AND l.date <= '" + context['to_date'] + "'" + cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),)) + r = dict(cr.fetchall()) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context) + + def _debit_calc(self, cr, uid, ids, name, arg, context={}): + res = {} + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + for i in ids: + res.setdefault(i,0.0) + + if not parent_ids: + return res + + where_date = '' + if context.get('from_date',False): + where_date += " AND l.date >= '" + context['from_date'] + "'" + if context.get('to_date',False): + where_date += " AND l.date <= '" + context['to_date'] + "'" + cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),)) + r= dict(cr.fetchall()) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context) + + def _balance_calc(self, cr, uid, ids, name, arg, context={}): + res = {} + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + for i in ids: + res.setdefault(i,0.0) + + if not parent_ids: + return res + + where_date = '' + if context.get('from_date',False): + where_date += " AND l.date >= '" + context['from_date'] + "'" + if context.get('to_date',False): + where_date += " AND l.date <= '" + context['to_date'] + "'" + cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),)) + + for account_id, sum in cr.fetchall(): + res[account_id] = sum + + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) + + def _quantity_calc(self, cr, uid, ids, name, arg, context={}): + #XXX must convert into one uom + res = {} + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + + for i in ids: + res.setdefault(i,0.0) + + if not parent_ids: + return res + + where_date = '' + if context.get('from_date',False): + where_date += " AND l.date >= '" + context['from_date'] + "'" + if context.get('to_date',False): + where_date += " AND l.date <= '" + context['to_date'] + "'" + + cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ + FROM account_analytic_account a \ + LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \ + WHERE a.id IN %s GROUP BY a.id',(tuple(parent_ids),)) + + for account_id, sum in cr.fetchall(): + res[account_id] = sum + + for id in ids: + if id not in parent_ids: + continue + for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): + if child != id: + res.setdefault(id, 0.0) + res[id] += res.get(child, 0.0) + return dict([(i, res[i]) for i in ids]) + + def name_get(self, cr, uid, ids, context={}): + if not len(ids): + return [] + reads = self.read(cr, uid, ids, ['name','parent_id'], context) + res = [] + for record in reads: + name = record['name'] + if record['parent_id']: + name = record['parent_id'][1]+' / '+name + res.append((record['id'], name)) + return res + + def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): + res = self.name_get(cr, uid, ids) + return dict(res) + + def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): + result = {} + for rec in self.browse(cr, uid, ids, context): + result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code) or False + return result + + def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): + result=self._get_company_currency(cr, uid, ids, field_name, arg, context={}) + return result + + _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), + 'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type'), + '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'), + 'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance',store=True), + 'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit',store=True), + 'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit',store=True), + 'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity',store=True), + 'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'), + 'partner_id' : fields.many2one('res.partner', 'Associated Partner'), + 'contact_id' : fields.many2one('res.partner.address', 'Contact'), + 'user_id' : fields.many2one('res.users', 'Account Manager'), + 'date_start': fields.date('Date Start'), + 'date': fields.date('Date End'), + 'company_id': fields.many2one('res.company', 'Company', required=True), + 'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Currency'), + 'state': fields.selection([('draft','Draft'),('open','Open'), ('pending','Pending'),('cancelled', 'Cancelled'),('close','Closed'),('template', 'Template')], 'State', required=True,readonly=True, + help='* When an account is created its in \'Draft\' state.\ + \n* If any associated partner is there, it can be in \'Open\' state.\ + \n* If any pending balance is there it can be in \'Pending\'. \ + \n* And finally when all the transactions are over, it can be in \'Close\' state. \ + \n* The project can be in either if the states \'Template\' and \'Running\'.\n If it is template then we can make projects based on the template projects. If its in \'Running\' state it is a normal project.\ + \n If it is to be reviewed then the state is \'Pending\'.\n When the project is completed the state is set to \'Done\'.'), + 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', store=True), + } + + def _default_company(self, cr, uid, context={}): + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + if user.company_id: + return user.company_id.id + return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] + _defaults = { + 'type' : lambda *a : 'normal', + 'company_id': _default_company, + 'state' : lambda *a : 'open', + 'user_id' : lambda self, cr, uid, ctx : uid, + 'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False), + 'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False), + 'date_start': lambda *a: time.strftime('%Y-%m-%d') + } + + def check_recursion(self, cr, uid, ids, parent=None): + return super(account_analytic_account, self).check_recursion(cr, uid, ids, parent=parent) + + _order = 'parent_id desc,code' + _constraints = [ + (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={}): + if not default: + default = {} + default['code'] = False + default['line_ids'] = [] + return super(account_analytic_account, self).copy(cr, uid, id, default, context=context) + + + def on_change_parent(self, cr, uid, id, parent_id): + if not parent_id: + return {} + parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0] + childs = self.search(cr, uid, [('parent_id', '=', parent_id)]) + numchild = len(childs) + if parent['partner_id']: + partner = parent['partner_id'][0] + else: + partner = False + res = {'value' : {}} + if partner: + res['value']['partner_id'] = partner + return res + + def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): + if not args: + args=[] + if not context: + context={} + account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context) + if not account: + account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context) + newacc = account + while newacc: + newacc = self.search(cr, uid, [('parent_id', 'in', newacc)]+args, limit=limit, context=context) + account+=newacc + return self.name_get(cr, uid, account, context=context) + +account_analytic_account() + + +class account_analytic_line(osv.osv): + _name = 'account.analytic.line' + _description = 'Analytic Line' + def _amount_currency(self, cr, uid, ids, field_name, arg, context={}): + result = {} + for rec in self.browse(cr, uid, ids, context): + cmp_cur_id=rec.company_id.currency_id.id + aa_cur_id=rec.account_id.currency_id.id + # Always provide the amount in currency + if cmp_cur_id != aa_cur_id: + cur_obj = self.pool.get('res.currency') + ctx = {} + if rec.date and rec.amount: + ctx['date'] = rec.date + result[rec.id] = cur_obj.compute(cr, uid, rec.company_id.currency_id.id, + rec.account_id.currency_id.id, rec.amount, + context=ctx) + else: + result[rec.id]=rec.amount + return result + + def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): + result = {} + for rec in self.browse(cr, uid, ids, context): + # Always provide second currency + result[rec.id] = (rec.account_id.currency_id.id,rec.account_id.currency_id.code) + return result + def _get_account_line(self, cr, uid, ids, context={}): + aac_ids = {} + for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): + aac_ids[acc.id] = True + aal_ids = [] + if aac_ids: + aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) + return aal_ids + + _columns = { + 'name' : fields.char('Description', size=256, required=True), + 'date' : fields.date('Date', required=True), + 'amount' : fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price.'), + 'unit_amount' : fields.float('Quantity', help='Specifies the amount of quantity to count.'), + 'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True), + 'user_id' : fields.many2one('res.users', 'User',), + 'company_id': fields.many2one('res.company','Company',required=True), + 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', + store={ + 'account.analytic.account': (_get_account_line, ['company_id'], 50), + 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10), + }, + help="The related account currency if not equal to the company one."), + 'amount_currency': fields.function(_amount_currency, method=True, digits_compute= dp.get_precision('Account'), string='Amount currency', + store={ + 'account.analytic.account': (_get_account_line, ['company_id'], 50), + 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10), + }, + help="The amount expressed in the related account currency if not equal to the company one."), + + } + _defaults = { + 'date': lambda *a: time.strftime('%Y-%m-%d'), + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), + } + _order = 'date' +account_analytic_line() + + From 16770ac54e5635a3ccd4ef7b7471f2185f883750 Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Fri, 18 Jun 2010 17:10:34 +0530 Subject: [PATCH 5/7] [FIX]:bug for test_xml bzr revid: pap@tinyerp.co.in-20100618114034-ugpwgey3qc1svjmj --- addons/analytic/project.py | 344 ------------------ .../wizard/l10_be_partner_vat_listing.py | 5 +- 2 files changed, 3 insertions(+), 346 deletions(-) delete mode 100644 addons/analytic/project.py diff --git a/addons/analytic/project.py b/addons/analytic/project.py deleted file mode 100644 index f52dd23caa0..00000000000 --- a/addons/analytic/project.py +++ /dev/null @@ -1,344 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# 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 . -# -############################################################################## - -import time -import operator - -from osv import fields, osv -import decimal_precision as dp - -# -# Object definition -# - -class account_analytic_account(osv.osv): - _name = 'account.analytic.account' - _description = 'Analytic Account' - - def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, context={}): - # Handle multi-currency on each level of analytic account - # This is a refactoring of _balance_calc computation - cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),)) - currency= dict(cr.fetchall()) - res_currency= self.pool.get('res.currency') - for id in ids: - if id not in ids2: - continue - for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): - if child != id: - res.setdefault(id, 0.0) - if currency[child]!=currency[id]: - res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context) - else: - res[id] += res.get(child, 0.0) - - cur_obj = res_currency.browse(cr, uid, currency.values(), context) - cur_obj = dict([(o.id, o) for o in cur_obj]) - for id in ids: - if id in ids2: - res[id] = res_currency.round(cr, uid, cur_obj[currency[id]], res.get(id,0.0)) - - return dict([(i, res[i]) for i in ids ]) - - - def _credit_calc(self, cr, uid, ids, name, arg, context={}): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - for i in ids: - res.setdefault(i,0.0) - - if not parent_ids: - return res - - where_date = '' - if context.get('from_date',False): - where_date += " AND l.date >= '" + context['from_date'] + "'" - if context.get('to_date',False): - where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),)) - r = dict(cr.fetchall()) - return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context) - - def _debit_calc(self, cr, uid, ids, name, arg, context={}): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - for i in ids: - res.setdefault(i,0.0) - - if not parent_ids: - return res - - where_date = '' - if context.get('from_date',False): - where_date += " AND l.date >= '" + context['from_date'] + "'" - if context.get('to_date',False): - where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),)) - r= dict(cr.fetchall()) - return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context) - - def _balance_calc(self, cr, uid, ids, name, arg, context={}): - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - for i in ids: - res.setdefault(i,0.0) - - if not parent_ids: - return res - - where_date = '' - if context.get('from_date',False): - where_date += " AND l.date >= '" + context['from_date'] + "'" - if context.get('to_date',False): - where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),)) - - for account_id, sum in cr.fetchall(): - res[account_id] = sum - - return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) - - def _quantity_calc(self, cr, uid, ids, name, arg, context={}): - #XXX must convert into one uom - res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) - - for i in ids: - res.setdefault(i,0.0) - - if not parent_ids: - return res - - where_date = '' - if context.get('from_date',False): - where_date += " AND l.date >= '" + context['from_date'] + "'" - if context.get('to_date',False): - where_date += " AND l.date <= '" + context['to_date'] + "'" - - cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ - FROM account_analytic_account a \ - LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \ - WHERE a.id IN %s GROUP BY a.id',(tuple(parent_ids),)) - - for account_id, sum in cr.fetchall(): - res[account_id] = sum - - for id in ids: - if id not in parent_ids: - continue - for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): - if child != id: - res.setdefault(id, 0.0) - res[id] += res.get(child, 0.0) - return dict([(i, res[i]) for i in ids]) - - def name_get(self, cr, uid, ids, context={}): - if not len(ids): - return [] - reads = self.read(cr, uid, ids, ['name','parent_id'], context) - res = [] - for record in reads: - name = record['name'] - if record['parent_id']: - name = record['parent_id'][1]+' / '+name - res.append((record['id'], name)) - return res - - def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict): - res = self.name_get(cr, uid, ids) - return dict(res) - - def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): - result = {} - for rec in self.browse(cr, uid, ids, context): - result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code) or False - return result - - def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): - result=self._get_company_currency(cr, uid, ids, field_name, arg, context={}) - return result - - _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), - 'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type'), - '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'), - 'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance',store=True), - 'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit',store=True), - 'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit',store=True), - 'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity',store=True), - 'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'), - 'partner_id' : fields.many2one('res.partner', 'Associated Partner'), - 'contact_id' : fields.many2one('res.partner.address', 'Contact'), - 'user_id' : fields.many2one('res.users', 'Account Manager'), - 'date_start': fields.date('Date Start'), - 'date': fields.date('Date End'), - 'company_id': fields.many2one('res.company', 'Company', required=True), - 'company_currency_id': fields.function(_get_company_currency, method=True, type='many2one', relation='res.currency', string='Currency'), - 'state': fields.selection([('draft','Draft'),('open','Open'), ('pending','Pending'),('cancelled', 'Cancelled'),('close','Closed'),('template', 'Template')], 'State', required=True,readonly=True, - help='* When an account is created its in \'Draft\' state.\ - \n* If any associated partner is there, it can be in \'Open\' state.\ - \n* If any pending balance is there it can be in \'Pending\'. \ - \n* And finally when all the transactions are over, it can be in \'Close\' state. \ - \n* The project can be in either if the states \'Template\' and \'Running\'.\n If it is template then we can make projects based on the template projects. If its in \'Running\' state it is a normal project.\ - \n If it is to be reviewed then the state is \'Pending\'.\n When the project is completed the state is set to \'Done\'.'), - 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', store=True), - } - - def _default_company(self, cr, uid, context={}): - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - if user.company_id: - return user.company_id.id - return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] - _defaults = { - 'type' : lambda *a : 'normal', - 'company_id': _default_company, - 'state' : lambda *a : 'open', - 'user_id' : lambda self, cr, uid, ctx : uid, - 'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False), - 'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False), - 'date_start': lambda *a: time.strftime('%Y-%m-%d') - } - - def check_recursion(self, cr, uid, ids, parent=None): - return super(account_analytic_account, self).check_recursion(cr, uid, ids, parent=parent) - - _order = 'parent_id desc,code' - _constraints = [ - (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={}): - if not default: - default = {} - default['code'] = False - default['line_ids'] = [] - return super(account_analytic_account, self).copy(cr, uid, id, default, context=context) - - - def on_change_parent(self, cr, uid, id, parent_id): - if not parent_id: - return {} - parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0] - childs = self.search(cr, uid, [('parent_id', '=', parent_id)]) - numchild = len(childs) - if parent['partner_id']: - partner = parent['partner_id'][0] - else: - partner = False - res = {'value' : {}} - if partner: - res['value']['partner_id'] = partner - return res - - def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): - if not args: - args=[] - if not context: - context={} - account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context) - if not account: - account = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context) - newacc = account - while newacc: - newacc = self.search(cr, uid, [('parent_id', 'in', newacc)]+args, limit=limit, context=context) - account+=newacc - return self.name_get(cr, uid, account, context=context) - -account_analytic_account() - - -class account_analytic_line(osv.osv): - _name = 'account.analytic.line' - _description = 'Analytic Line' - def _amount_currency(self, cr, uid, ids, field_name, arg, context={}): - result = {} - for rec in self.browse(cr, uid, ids, context): - cmp_cur_id=rec.company_id.currency_id.id - aa_cur_id=rec.account_id.currency_id.id - # Always provide the amount in currency - if cmp_cur_id != aa_cur_id: - cur_obj = self.pool.get('res.currency') - ctx = {} - if rec.date and rec.amount: - ctx['date'] = rec.date - result[rec.id] = cur_obj.compute(cr, uid, rec.company_id.currency_id.id, - rec.account_id.currency_id.id, rec.amount, - context=ctx) - else: - result[rec.id]=rec.amount - return result - - def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): - result = {} - for rec in self.browse(cr, uid, ids, context): - # Always provide second currency - result[rec.id] = (rec.account_id.currency_id.id,rec.account_id.currency_id.code) - return result - def _get_account_line(self, cr, uid, ids, context={}): - aac_ids = {} - for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): - aac_ids[acc.id] = True - aal_ids = [] - if aac_ids: - aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) - return aal_ids - - _columns = { - 'name' : fields.char('Description', size=256, required=True), - 'date' : fields.date('Date', required=True), - 'amount' : fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price.'), - 'unit_amount' : fields.float('Quantity', help='Specifies the amount of quantity to count.'), - 'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True), - 'user_id' : fields.many2one('res.users', 'User',), - 'company_id': fields.many2one('res.company','Company',required=True), - 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', - store={ - 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10), - }, - help="The related account currency if not equal to the company one."), - 'amount_currency': fields.function(_amount_currency, method=True, digits_compute= dp.get_precision('Account'), string='Amount currency', - store={ - 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10), - }, - help="The amount expressed in the related account currency if not equal to the company one."), - - } - _defaults = { - 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), - } - _order = 'date' -account_analytic_line() - - diff --git a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py index 415db0ba067..51267636403 100644 --- a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py +++ b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py @@ -62,6 +62,7 @@ class partner_vat(osv.osv_memory): obj_vat_lclient = self.pool.get('vat.listing.clients') obj_model_data = self.pool.get('ir.model.data') data = self.read(cursor, user, ids)[0] + context['test_xml'] = data['test_xml'] period = obj_period.search(cursor, user, [('fiscalyear_id', '=', data['fyear'])], context=context) p_id_list = obj_partner.search(cursor, user, [('vat_subjected', '!=', False)], context=context) if not p_id_list: @@ -196,7 +197,7 @@ class partner_vat_list(osv.osv_memory): data_file = '\n\n\t\t'+tools.ustr(obj_cmpny.name)+'\n\t\t'+ tools.ustr(street) +'\n\t\t'+ tools.ustr(zip_city) +'' @@ -225,7 +226,7 @@ class partner_vat_list(osv.osv_memory): seq +=1 sum_tax +=line['amount'] sum_turnover +=line['turnover'] - data_clientinfo +='\n\n\t\n\t\t'+line['vat'] +'\n\t\t'+tools.ustr(line['country']) +'\n\t\n\t'+str(int(line['amount'] * 100)) +'\n\t'+str(int(line['turnover'] * 100)) +'\n' + data_clientinfo +='\n\n\t\n\t\t'+str(line['vat']) +'\n\t\t'+tools.ustr(line['country']) +'\n\t\n\t'+str(int(line['amount'] * 100)) +'\n\t'+str(int(line['turnover'] * 100)) +'\n' data_decl ='\n' data_file += tools.ustr(data_decl) + tools.ustr(data_comp) + tools.ustr(data_period) + tools.ustr(data_clientinfo) + '\n' From 68fc5a468b9f59964c65bda2b98974eb65763e17 Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Mon, 21 Jun 2010 10:57:51 +0530 Subject: [PATCH 6/7] [IMP]:improved views in account bzr revid: pap@tinyerp.co.in-20100621052751-f7kwfs9zj25bo371 --- addons/account/account_view.xml | 28 ++++++++++++++++++++---- addons/account/project/project_view.xml | 29 +++++++++++++++++++++---- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index a5dc4061e6b..9efcc377d5c 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -1373,12 +1373,32 @@ - + - + + + + + + + + + + + + + + + + + + + + + Payment Terms account.payment.term @@ -1905,7 +1925,7 @@ - + @@ -1915,7 +1935,7 @@ - + diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 067fbd38ab1..6431b9f9144 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -24,7 +24,7 @@ search - + @@ -32,7 +32,15 @@ - + + + + + + + + + @@ -277,7 +285,20 @@ - + + + account.analytic.journal.search + account.analytic.journal + search + + + + + + + + + account.analytic.journal.form account.analytic.journal @@ -296,7 +317,7 @@ Analytic Journals account.analytic.journal form - tree,form + tree,form,search From 556ccf4741109e9d5ffc93f29f364ba4cce34d15 Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Mon, 21 Jun 2010 18:42:11 +0530 Subject: [PATCH 7/7] [IMP]:changed icon bzr revid: pap@tinyerp.co.in-20100621131211-94dihxr61m53z9iy --- addons/account/account_view.xml | 8 ++++---- addons/l10n_ch/dta_wizard.xml | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 4e2f2fb62e3..82781b45ab0 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -444,7 +444,7 @@ - + @@ -967,9 +967,9 @@ - - - + + + diff --git a/addons/l10n_ch/dta_wizard.xml b/addons/l10n_ch/dta_wizard.xml index 7fb083d51bd..c2eeff9b4cc 100644 --- a/addons/l10n_ch/dta_wizard.xml +++ b/addons/l10n_ch/dta_wizard.xml @@ -7,6 +7,5 @@ name="account.dta_create" menu= "False" id="wizard_account_dta_create"/> -