Rifakat (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-17387-rha into 
lp:openobject-addons/6.0.

Requested reviews:
  Raphael Collet (OpenERP) (rco-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-17387-rha/+merge/76338

Hello,

Wrong accounting entries are generated while adding tax using Sales Receipt and 
Supplier Vouchers with 'tax include in price'.

This fix solves the problem.

Thanks,
Rifakat
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-17387-rha/+merge/76338
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-17387-rha.
=== modified file 'account/account_move_line.py'
--- account/account_move_line.py	2011-06-22 20:05:58 +0000
+++ account/account_move_line.py	2011-09-21 06:47:35 +0000
@@ -1297,7 +1297,13 @@
         # CREATE Taxes
         if vals.get('account_tax_id', False):
             tax_id = tax_obj.browse(cr, uid, vals['account_tax_id'])
-            total = vals['debit'] - vals['credit']
+            if tax_id.price_include:
+                if context.get('credit'):
+                    total = context.get('credit', 0.0)
+                else:
+                    total = context.get('debit', 0.0)
+            else:
+                total = vals['debit'] - vals['credit']
             if journal.refund_journal:
                 base_code = 'ref_base_code_id'
                 tax_code = 'ref_tax_code_id'

=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py	2011-08-31 06:33:42 +0000
+++ account_voucher/account_voucher.py	2011-09-21 06:47:35 +0000
@@ -719,7 +719,15 @@
                 if line.amount == line.amount_unreconciled:
                     amount = line.move_line_id.amount_residual #residual amount in company currency
                 else:
-                    amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
+                    if inv.tax_id and inv.tax_id.price_include:
+                        if inv.type == 'sale':
+                            amount = currency_pool.compute(cr, uid, current_currency, company_currency, line_total, context=context_multi_currency)
+                            context.update({'credit': -inv.amount})
+                        if inv.type == 'purchase':
+                            amount = currency_pool.compute(cr, uid, current_currency, company_currency, -line_total, context=context_multi_currency)
+                            context.update({'debit': inv.amount})
+                    else:
+                        amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
                 move_line = {
                     'journal_id': inv.journal_id.id,
                     'period_id': inv.period_id.id,
@@ -758,7 +766,7 @@
                         raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name))
                 sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1
                 move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or 0.0
-                voucher_line = move_line_pool.create(cr, uid, move_line)
+                voucher_line = move_line_pool.create(cr, uid, move_line, context=context)
                 if line.move_line_id.id:
                     rec_ids = [voucher_line, line.move_line_id.id]
                     rec_list_ids.append(rec_ids)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to