From 30bce2b56ceb1f87c832d128dc9a132b83f6fb92 Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 21 Sep 2010 13:19:45 +0200 Subject: [PATCH 01/71] [REF] account_voucher: code cleaning bzr revid: qdp-launchpad@tinyerp.com-20100921111945-dij9cmqegah9h9tx --- addons/account_voucher/voucher.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index 6ef093cc935..d90954f9e5b 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -819,10 +819,7 @@ class account_bank_statement(osv.osv): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None): st_line = self.pool.get('account.bank.statement.line').browse(cr, uid, st_line_id, context=context) if st_line.voucher_id: - res = self.pool.get('account.voucher').proforma_voucher(cr, uid, [st_line.voucher_id.id], context={'force_name': next_number}) - #force refresh of the cache - #st_line = self.pool.get('account.bank.statement.line').browse(cr, uid, st_line.id, context=context) - + self.pool.get('account.voucher').proforma_voucher(cr, uid, [st_line.voucher_id.id], context={'force_name': next_number}) return self.pool.get('account.move.line').write(cr, uid, [x.id for x in st_line.voucher_id.move_ids], {'statement_id': st_line.statement_id.id}, context=context) return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context=context) From cad3242b7fecb1c706a62e51a0213b9ed4c1923f Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 21 Sep 2010 14:19:33 +0200 Subject: [PATCH 02/71] [FIX] account: onchange on analytic lines bzr revid: qdp-launchpad@tinyerp.com-20100921121933-yazeuffn1mpkbiw2 --- addons/account/account_analytic_line.py | 67 +++++++++++++------------ 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index be1e5ec65e6..7a66dd4f175 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -71,18 +71,22 @@ class account_analytic_line(osv.osv): # Compute the cost based on the price type define into company # property_valuation_price_type property - def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, + def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id, unit=False, journal_id=False, context=None): if context==None: context={} - uom_obj = self.pool.get('product.uom') + if not journal_id or not prod_id: + return {} product_obj = self.pool.get('product.product') - company_obj=self.pool.get('res.company') - analytic_journal_obj=self.pool.get('account.analytic.journal') - product_price_type_obj = self.pool.get('product.price.type') - if prod_id: - result = 0.0 - prod = product_obj.browse(cr, uid, prod_id) + analytic_journal_obj =self.pool.get('account.analytic.journal') + j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context) + prod = product_obj.browse(cr, uid, prod_id) + if not company_id: + company_id = j_id.company_id.id + result = 0.0 + is_purchase = False + + if j_id.type == 'purchase': a = prod.product_tmpl_id.property_account_expense.id if not a: a = prod.categ_id.property_account_expense_categ.id @@ -91,32 +95,31 @@ class account_analytic_line(osv.osv): _('There is no expense account defined ' \ 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) - if not company_id: - company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) - flag = False - # Compute based on pricetype - pricetype=product_price_type_obj.browse(cr, uid, company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) - if journal_id: - journal = analytic_journal_obj.browse(cr, uid, journal_id) - if journal.type == 'sale': - product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context) - if product_price_type_ids: - pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context)[0] - # Take the company currency as the reference one - if pricetype.field == 'list_price': - flag = True - amount_unit = prod.price_get(pricetype.field, context)[prod.id] - amount = amount_unit*unit_amount or 1.0 - prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') - amount = amount_unit*unit_amount or 1.0 - result = round(amount, prec) - if not flag: - result *= -1 - return {'value': { + amount_unit = prod.price_get('standard_price', context)[prod.id] + is_purchase = True + + else: + a = prod.product_tmpl_id.property_account_income.id + if not a: + a = prod.categ_id.property_account_income_categ.id + if not a: + raise osv.except_osv(_('Error !'), + _('There is no income account defined ' \ + 'for this product: "%s" (id:%d)') % \ + (prod.name, prod_id,)) + amount_unit = prod.price_get('list_price', context)[prod_id] + + prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') + amount = amount_unit * quantity or 1.0 + result = round(amount, prec) + if is_purchase: + result *= -1 + return { + 'value': { 'amount': result, 'general_account_id': a, - }} - return {} + } + } def view_header_get(self, cr, user, view_id, view_type, context): if context.get('account_id', False): From 59f3f157b2a901d5456ad9768c7590c2364767f0 Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 21 Sep 2010 15:53:19 +0200 Subject: [PATCH 03/71] [IMP] account: usability changes in analytic accounting bzr revid: qdp-launchpad@tinyerp.com-20100921135319-1uc18ax7zqs2256b --- addons/account/project/project_view.xml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 7e8f6875553..0d335118d3b 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -8,7 +8,7 @@ tree - + @@ -25,10 +25,11 @@ - + + @@ -36,11 +37,10 @@ - - - - + + + @@ -60,8 +60,11 @@ - + + + + @@ -192,13 +195,14 @@ - - + + + - + From 97542fb978fe273c3f6cabe7719aa01696aa2ede Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 21 Sep 2010 17:31:45 +0200 Subject: [PATCH 04/71] [IMP] account: better error message bzr revid: qdp-launchpad@tinyerp.com-20100921153145-82vhcj0s6d9w0qu2 --- addons/account/invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 42e4bee12b6..c09e88ba49f 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -829,7 +829,7 @@ class account_invoice(osv.osv): total_percent += line.value_amount total_fixed = (total_fixed * 100) / inv.amount_total if (total_fixed + total_percent) > 100: - raise osv.except_osv(_('Error !'), _("You cannot create an invoice !\nAs you have defined payment term and so the total of invoice should be greater than the computed amount for journal entries using payment term")) + raise osv.except_osv(_('Error !'), _("Cannot create the invoice !\nThe payment term defined gives a computed amount greater than the total invoiced amount.")) # one move line per tax line iml += ait_obj.move_line_get(cr, uid, inv.id) From d9ab88c8913b437e9e90fc116cf9b4c2821c8707 Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Tue, 21 Sep 2010 18:41:57 +0200 Subject: [PATCH 05/71] [FIX] account: recurring model legend and %(date)s bzr revid: qdp-launchpad@tinyerp.com-20100921164157-w2yvnv6f0fezsg0o --- addons/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index df6a0492ff9..a3b7c435091 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2021,7 +2021,7 @@ class account_model(osv.osv): period_id = period_id[0] for model in self.browse(cr, uid, ids, context): - entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%d')} + entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], 'period_id': period_id, From 23f99c16818d00bc9c7f26b5c0acb2ebcf181182 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 22 Sep 2010 11:53:08 +0530 Subject: [PATCH 06/71] [ADD] Account_voucher: import invoice from bank statements moved from account module bzr revid: mra@mra-laptop-20100922062308-859tbohs0ne09hj0 --- addons/account/__openerp__.py | 1 - addons/account/account_bank_statement.py | 8 ++--- addons/account/account_view.xml | 6 ---- addons/account/wizard/__init__.py | 2 -- addons/account_voucher/__init__.py | 6 ++-- addons/account_voucher/__openerp__.py | 1 + addons/account_voucher/voucher_view.xml | 31 ++++++++++++++++++- addons/account_voucher/wizard/__init__.py | 3 ++ .../wizard/account_statement_from_invoice.py | 10 +++--- .../account_statement_from_invoice_view.xml | 0 10 files changed, 47 insertions(+), 21 deletions(-) rename addons/{account => account_voucher}/wizard/account_statement_from_invoice.py (96%) rename addons/{account => account_voucher}/wizard/account_statement_from_invoice_view.xml (100%) diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 9bbddb1e050..7c533fe1886 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -49,7 +49,6 @@ module named account_voucher. 'security/ir.model.access.csv', 'account_menuitem.xml', 'account_wizard.xml', - 'wizard/account_statement_from_invoice_view.xml', 'wizard/account_move_bank_reconcile_view.xml', 'wizard/account_use_model_view.xml', 'account_installer.xml', diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 3267ae6cecf..6c78cd1edf0 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -222,10 +222,10 @@ class account_bank_statement(osv.osv): account_move_line_obj = self.pool.get('account.move.line') account_analytic_line_obj = self.pool.get('account.analytic.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') - - st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context) + + st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id.id, context) st = st_line.statement_id - + context.update({'date': st_line.date}) move_id = account_move_obj.create(cr, uid, { 'journal_id': st.journal_id.id, @@ -284,7 +284,7 @@ class account_bank_statement(osv.osv): move_line_id = account_move_line_obj.create(cr, uid, val , context=context) torec.append(move_line_id) - + # Fill the secondary amount/currency # if currency is not the same than the company amount_currency = False diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index b56b3100a5b..6f0b4abc477 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -516,9 +516,6 @@ -