← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/ocb-addons/ocb-addons-hr_expense-tax_vre into lp:ocb-addons

 

Vincent Renaville@camptocamp has proposed merging lp:~camptocamp/ocb-addons/ocb-addons-hr_expense-tax_vre into lp:ocb-addons.

Requested reviews:
  Holger Brunn (Therp) (hbrunn)
  Yannick Vaucher @ Camptocamp (yvaucher-c2c): differ from opw

For more details, see:
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-addons-hr_expense-tax_vre/+merge/196122
-- 
https://code.launchpad.net/~camptocamp/ocb-addons/ocb-addons-hr_expense-tax_vre/+merge/196122
Your team OpenERP Community Backports Team is subscribed to branch lp:ocb-addons.
=== modified file 'hr_expense/hr_expense.py'
--- hr_expense/hr_expense.py	2013-09-09 08:02:09 +0000
+++ hr_expense/hr_expense.py	2013-11-21 14:42:04 +0000
@@ -297,6 +297,7 @@
             if not mres:
                 continue
             res.append(mres)
+            current_product_line_pos = len(res) - 1
             tax_code_found= False
             
             #Calculate tax according to default tax on product
@@ -340,18 +341,20 @@
                 is_price_include = tax_obj.read(cr,uid,tax['id'],['price_include'],context)['price_include']
                 if is_price_include:
                     ## We need to deduce the price for the tax
-                    res[-1]['price'] = res[-1]['price']  - (tax['amount'] * tax['base_sign'] or 0.0)
-                assoc_tax = {
-                             'type':'tax',
-                             'name':tax['name'],
-                             'price_unit': tax['price_unit'],
-                             'quantity': 1,
-                             'price':  tax['amount'] * tax['base_sign'] or 0.0,
-                             'account_id': tax['account_collected_id'] or mres['account_id'],
-                             'tax_code_id': tax['tax_code_id'],
-                             'tax_amount': tax['amount'] * tax['base_sign'],
-                             }
-                res.append(assoc_tax)
+                    res[current_product_line_pos]['price'] = res[current_product_line_pos]['price']  - (-(tax['amount'] * tax['base_sign'] or 0.0))
+                #Will create the tax here as we don't have the access
+                if (tax['amount'] * tax['base_sign'] or 0.0) or (tax['tax_code_id'] != False ): 
+                    assoc_tax = {
+                                 'type':'tax',
+                                 'name':tax['name'],
+                                 'price_unit': tax['price_unit'],
+                                 'quantity': 1,
+                                 'price':  -(tax['amount'] * tax['base_sign'] or 0.0),
+                                 'account_id': tax['account_collected_id'] or mres['account_id'],
+                                 'tax_code_id': tax['tax_code_id'],
+                                 'tax_amount': tax['amount'] * tax['base_sign'],
+                                 }
+                    res.append(assoc_tax)
         return res
 
     def move_line_get_item(self, cr, uid, line, context=None):


Follow ups