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

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

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

Hello,

Created separate account tax line enrty while posing accouning entries from 
stock valuation.

Currently it was posting (untaxed + tax) amount account move but I should post 
tax entry separately same like it does from invoicing.

Please review it and let me know if changes required.

Thanks,
Rifakat Haradwala
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-572926-rha/+merge/99018
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-572926-rha.
=== modified file 'purchase/stock.py'
--- purchase/stock.py	2012-02-24 12:55:01 +0000
+++ purchase/stock.py	2012-03-23 13:10:28 +0000
@@ -20,6 +20,7 @@
 ##############################################################################
 
 from osv import osv, fields
+import copy
 
 class stock_move(osv.osv):
     _inherit = 'stock.move'
@@ -43,6 +44,27 @@
                 reference_amount, reference_currency_id = move.purchase_line_id.price_unit * move.product_qty, move.picking_id.purchase_id.pricelist_id.currency_id.id
         return reference_amount, reference_currency_id
 
+    def _create_account_move_line(self, cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=None):
+        result = super(stock_move, self)._create_account_move_line(cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=context)
+        tax_obj = self.pool.get('account.tax')
+        if move.purchase_line_id and move.purchase_line_id.taxes_id:
+            tax_info = tax_obj.compute_all(cr, uid, move.purchase_line_id.taxes_id, reference_amount, 1.00)
+            if move.picking_id.type in ('in'):
+                result[1][2].update(credit=tax_info['total'])
+                result[0][2]['debit'] = tax_info['total_included']
+                for tax in tax_info.get('taxes'):
+                    tax_line = copy.deepcopy(result[1][2])
+                    tax_line.update(credit = tax['amount'], account_id=tax['account_collected_id'] or src_account_id, name=tax['name'])
+                    result.append((0, 0, tax_line))
+            elif move.picking_id.type in ('out'):
+                result[1][2]['credit'] = tax_info['total_included']
+                result[0][2].update(debit=tax_info['total'])
+                for tax in tax_info.get('taxes'):
+                    tax_line = copy.deepcopy(result[0][2])
+                    tax_line.update(debit = tax['amount'], account_id=tax['account_collected_id'] or src_account_id, name=tax['name'])
+                    result.append((0, 0, tax_line))
+        return result
+
 stock_move()
 
 #

=== modified file 'sale/stock.py'
--- sale/stock.py	2012-02-21 19:16:22 +0000
+++ sale/stock.py	2012-03-23 13:10:28 +0000
@@ -20,6 +20,7 @@
 ##############################################################################
 
 from osv import osv, fields
+import copy
 
 class stock_move(osv.osv):
     _inherit = 'stock.move'
@@ -32,6 +33,28 @@
         if picking.sale_id:
             self.pool.get('stock.picking').write(cr, uid, [res], {'sale_id': picking.sale_id.id})
         return res
+
+    def _create_account_move_line(self, cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=None):    
+        result = super(stock_move, self)._create_account_move_line(cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=context)
+        tax_obj = self.pool.get('account.tax')
+        if move.sale_line_id and move.sale_line_id.tax_id:
+            tax_info = tax_obj.compute_all(cr, uid, move.sale_line_id.tax_id, reference_amount, 1.00)
+            if move.picking_id.type in ('out'):
+                result[1][2]['credit'] = tax_info['total_included']
+                result[0][2].update(debit=tax_info['total'])
+                for tax in tax_info.get('taxes'):
+                    tax_line = copy.deepcopy(result[0][2])
+                    tax_line.update(debit = tax['amount'], account_id=tax['account_collected_id'] or src_account_id, name=tax['name'])
+                    result.append((0, 0, tax_line))
+            elif move.picking_id.type in ('in'):
+                result[0][2]['debit'] = tax_info['total_included']
+                result[1][2].update(credit=tax_info['total'])
+                for tax in tax_info.get('taxes'):
+                    tax_line = copy.deepcopy(result[1][2])
+                    tax_line.update(credit = tax['amount'], account_id=tax['account_collected_id'] or src_account_id, name=tax['name'])
+                    result.append((0, 0, tax_line))
+        return result
+    
 stock_move()
 
 class stock_picking(osv.osv):

_______________________________________________
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