Merge lp:~openerp-dev/openobject-addons/6.0-opw-572926-rha into lp:openobject-addons/6.0

Proposed by Rifakat Husen (OpenERP)
Status: Approved
Approved by: Naresh(OpenERP)
Approved revision: 5157
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-572926-rha
Merge into: lp:openobject-addons/6.0
Diff against target: 74 lines (+42/-0)
3 files modified
purchase/stock.py (+9/-0)
sale/stock.py (+10/-0)
stock/stock.py (+23/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-572926-rha
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Review via email: mp+99018@code.launchpad.net

Description of the change

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

To post a comment you must log in.
5156. By Rifakat Husen (OpenERP)

[FIX] stock: optomized code and refactore mothod

5157. By Rifakat Husen (OpenERP)

[FIX] stock: refactored method and created proper tax movement

Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve

Unmerged revisions

5157. By Rifakat Husen (OpenERP)

[FIX] stock: refactored method and created proper tax movement

5156. By Rifakat Husen (OpenERP)

[FIX] stock: optomized code and refactore mothod

5155. By Rifakat Husen (OpenERP)

[FIX] sale,purchase: created separate account tax line enrty while posing accouning entries from stoack valuation

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'purchase/stock.py'
2--- purchase/stock.py 2012-02-24 12:55:01 +0000
3+++ purchase/stock.py 2012-03-26 06:26:18 +0000
4@@ -43,6 +43,15 @@
5 reference_amount, reference_currency_id = move.purchase_line_id.price_unit * move.product_qty, move.picking_id.purchase_id.pricelist_id.currency_id.id
6 return reference_amount, reference_currency_id
7
8+ def _create_account_move_line(self, cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=None):
9+ 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)
10+ if move.purchase_line_id and move.purchase_line_id.taxes_id:
11+ tax_info = self.pool.get('account.tax').compute_all(cr, uid, move.purchase_line_id.taxes_id, reference_amount, 1.00)
12+ result = self._tax_line_from_move_line(cr, uid, move,
13+ src_account_id, dest_account_id, tax_info,
14+ result, move.picking_id.type, context=context)
15+ return result
16+
17 stock_move()
18
19 #
20
21=== modified file 'sale/stock.py'
22--- sale/stock.py 2012-02-21 19:16:22 +0000
23+++ sale/stock.py 2012-03-26 06:26:18 +0000
24@@ -32,6 +32,16 @@
25 if picking.sale_id:
26 self.pool.get('stock.picking').write(cr, uid, [res], {'sale_id': picking.sale_id.id})
27 return res
28+
29+ def _create_account_move_line(self, cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=None):
30+ 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)
31+ if move.sale_line_id and move.sale_line_id.tax_id:
32+ tax_info = self.pool.get('account.tax').compute_all(cr, uid, move.sale_line_id.tax_id, reference_amount, 1.00)
33+ result = self._tax_line_from_move_line(cr, uid, move,
34+ src_account_id, dest_account_id, tax_info,
35+ result, move.picking_id.type, context=context)
36+ return result
37+
38 stock_move()
39
40 class stock_picking(osv.osv):
41
42=== modified file 'stock/stock.py'
43--- stock/stock.py 2012-03-13 16:33:22 +0000
44+++ stock/stock.py 2012-03-26 06:26:18 +0000
45@@ -2176,6 +2176,29 @@
46 wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
47
48 return True
49+
50+ def _tax_line_from_move_line(self, cr, uid, move, src_account_id, dest_account_id, tax_info, result, type, context=None):
51+ if type in ('in'):
52+ result[0][2]['debit'] = tax_info['total_included']
53+ result[1][2].update(credit=tax_info['total'])
54+ for tax in tax_info.get('taxes'):
55+ tax_line = result[1][2].copy()
56+ tax_line.update(name=tax['name'], credit = tax['amount'],
57+ account_id=tax['account_collected_id'] or src_account_id,
58+ tax_code_id = tax['tax_code_id'],
59+ tax_amount = tax['tax_sign'] * abs(tax['amount']))
60+ result.append((0, 0, tax_line))
61+ elif type in ('out'):
62+ result[1][2]['credit'] = tax_info['total_included']
63+ result[0][2].update(debit=tax_info['total'])
64+ for tax in tax_info.get('taxes'):
65+ tax_line = result[0][2].copy()
66+ tax_line.update(name=tax['name'], debit = tax['amount'],
67+ account_id=tax['account_collected_id'] or src_account_id,
68+ tax_code_id = tax['tax_code_id'],
69+ tax_amount = tax['tax_sign'] * abs(tax['amount']))
70+ result.append((0, 0, tax_line))
71+ return result
72
73 def _create_account_move_line(self, cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=None):
74 """