Merge lp:~openbig/bigconsulting/foreign_currency_changes into lp:bigconsulting
- foreign_currency_changes
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 108 |
Proposed branch: | lp:~openbig/bigconsulting/foreign_currency_changes |
Merge into: | lp:bigconsulting |
Diff against target: |
156 lines (+68/-17) 1 file modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+68/-17) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/foreign_currency_changes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+36456@code.launchpad.net |
Commit message
Description of the change
added changes for the foreign currency.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py' | |||
2 | --- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-22 14:21:33 +0000 | |||
3 | +++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-23 15:15:57 +0000 | |||
4 | @@ -786,7 +786,7 @@ | |||
5 | 786 | new_amount_currency = 0.0 | 786 | new_amount_currency = 0.0 |
6 | 787 | newline_amount_currency = 0.0 | 787 | newline_amount_currency = 0.0 |
7 | 788 | for newline in move.reconcile_id.line_new_ids: | 788 | for newline in move.reconcile_id.line_new_ids: |
9 | 789 | newline_amount_currency += newline.amount | 789 | newline_amount_currency = newline.amount |
10 | 790 | if st.currency.id <> company_currency_id: | 790 | if st.currency.id <> company_currency_id: |
11 | 791 | newline_amount_currency = res_currency_obj.compute(cr, uid, st.currency.id, | 791 | newline_amount_currency = res_currency_obj.compute(cr, uid, st.currency.id, |
12 | 792 | company_currency_id, newline.amount, context=context) | 792 | company_currency_id, newline.amount, context=context) |
13 | @@ -817,8 +817,7 @@ | |||
14 | 817 | 817 | ||
15 | 818 | for line in move.reconcile_id.line_ids: | 818 | for line in move.reconcile_id.line_ids: |
16 | 819 | move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context) | 819 | move_line_data = self.pool.get('account.move.line').browse(cr, uid, line.id, context=context) |
19 | 820 | if st.currency.id <> (move_line_data.currency_id.id or company_currency_id): | 820 | if st.currency.id <> company_currency_id: |
18 | 821 | |||
20 | 822 | expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id | 821 | expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id |
21 | 823 | revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id | 822 | revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id |
22 | 824 | currency_id = st.currency.id | 823 | currency_id = st.currency.id |
23 | @@ -836,6 +835,19 @@ | |||
24 | 836 | for line in reconcile_data.line_new_ids: | 835 | for line in reconcile_data.line_new_ids: |
25 | 837 | reconcile_sum += line.amount | 836 | reconcile_sum += line.amount |
26 | 838 | balance = round((balance_sum - reconcile_sum),2) | 837 | balance = round((balance_sum - reconcile_sum),2) |
27 | 838 | |||
28 | 839 | if st.currency.id <> move_line_data.currency_id.id: | ||
29 | 840 | invoice_cret_balance = 0.0 | ||
30 | 841 | payment_balance = 0.0 | ||
31 | 842 | context.update({'date': move_line_data.date}) | ||
32 | 843 | inv_create_balance = res_currency_obj.compute(cr, uid, company_currency_id, | ||
33 | 844 | st.currency.id, amount, context=context) | ||
34 | 845 | currenct_date = time.strftime('%Y-%m-%d') | ||
35 | 846 | context.update({'date': currenct_date}) | ||
36 | 847 | payment_balance = res_currency_obj.compute(cr, uid, company_currency_id, | ||
37 | 848 | st.currency.id, amount, context=context) | ||
38 | 849 | balance = inv_create_balance - payment_balance | ||
39 | 850 | |||
40 | 839 | ###### set fisical position for the currency_diff account and partner account | 851 | ###### set fisical position for the currency_diff account and partner account |
41 | 840 | fpos = move_line_data.invoice.fiscal_position or False | 852 | fpos = move_line_data.invoice.fiscal_position or False |
42 | 841 | if expense_acc: | 853 | if expense_acc: |
43 | @@ -848,7 +860,7 @@ | |||
44 | 848 | 860 | ||
45 | 849 | ## Account selection############ | 861 | ## Account selection############ |
46 | 850 | if move_line_data.invoice.type in ['in_invoice','out_refund'] and balance < 0.00: | 862 | if move_line_data.invoice.type in ['in_invoice','out_refund'] and balance < 0.00: |
48 | 851 | curr_diff_account_id = revene_acc | 863 | curr_diff_account_id = revene_acc |
49 | 852 | elif move_line_data.invoice.type in ['in_invoice','out_refund'] and balance > 0.00: | 864 | elif move_line_data.invoice.type in ['in_invoice','out_refund'] and balance > 0.00: |
50 | 853 | curr_diff_account_id = expense_acc | 865 | curr_diff_account_id = expense_acc |
51 | 854 | elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance < 0.00: | 866 | elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance < 0.00: |
52 | @@ -856,14 +868,50 @@ | |||
53 | 856 | elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance > 0.00: | 868 | elif move_line_data.invoice.type in ['out_invoice','in_refund'] and balance > 0.00: |
54 | 857 | curr_diff_account_id = expense_acc | 869 | curr_diff_account_id = expense_acc |
55 | 858 | ####################################### | 870 | ####################################### |
64 | 859 | if balance > 0.0 or balance < 0.0: | 871 | if balance > 0.0: |
65 | 860 | account_move_line_obj.create(cr, uid, { | 872 | currency_diff1 = account_move_line_obj.create(cr, uid, { |
66 | 861 | 'name': move.name, | 873 | 'name': move.name, |
67 | 862 | 'date': move.date, | 874 | 'date': move.date, |
68 | 863 | 'ref': move.ref, | 875 | 'ref': move.ref, |
69 | 864 | 'move_id': move_id, | 876 | 'move_id': move_id, |
70 | 865 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | 877 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, |
71 | 866 | 'account_id': expense_acc, | 878 | 'account_id': move.account_id.id, |
72 | 879 | 'credit': 0.0, | ||
73 | 880 | 'debit': abs(balance), | ||
74 | 881 | 'statement_id': st.id, | ||
75 | 882 | 'journal_id': st.journal_id.id, | ||
76 | 883 | 'period_id': st.period_id.id, | ||
77 | 884 | 'amount_currency': 0.0, | ||
78 | 885 | 'currency_id': currency_id, | ||
79 | 886 | }, context=context) | ||
80 | 887 | |||
81 | 888 | currency_diff2 = account_move_line_obj.create(cr, uid, { | ||
82 | 889 | 'name': move.name, | ||
83 | 890 | 'date': move.date, | ||
84 | 891 | 'ref': move.ref, | ||
85 | 892 | 'move_id': move_id, | ||
86 | 893 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | ||
87 | 894 | 'account_id': partner_acc_id, | ||
88 | 895 | 'credit': abs(balance), | ||
89 | 896 | 'debit': 0.0, | ||
90 | 897 | 'statement_id': st.id, | ||
91 | 898 | 'journal_id': st.journal_id.id, | ||
92 | 899 | 'period_id': st.period_id.id, | ||
93 | 900 | 'amount_currency': 0.0, | ||
94 | 901 | 'currency_id': currency_id, | ||
95 | 902 | }, context=context) | ||
96 | 903 | |||
97 | 904 | if move_line_data.invoice.currency_id.id != company_currency_id: | ||
98 | 905 | torec.append(currency_diff1) | ||
99 | 906 | |||
100 | 907 | if balance < 0.0: | ||
101 | 908 | currency_diff1 = account_move_line_obj.create(cr, uid, { | ||
102 | 909 | 'name': move.name, | ||
103 | 910 | 'date': move.date, | ||
104 | 911 | 'ref': move.ref, | ||
105 | 912 | 'move_id': move_id, | ||
106 | 913 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | ||
107 | 914 | 'account_id': move.account_id.id, | ||
108 | 867 | 'credit': abs(balance), | 915 | 'credit': abs(balance), |
109 | 868 | 'debit': 0.0, | 916 | 'debit': 0.0, |
110 | 869 | 'statement_id': st.id, | 917 | 'statement_id': st.id, |
111 | @@ -872,15 +920,15 @@ | |||
112 | 872 | 'amount_currency': 0.0, | 920 | 'amount_currency': 0.0, |
113 | 873 | 'currency_id': currency_id, | 921 | 'currency_id': currency_id, |
114 | 874 | }, context=context) | 922 | }, context=context) |
117 | 875 | 923 | ||
118 | 876 | account_move_line_obj.create(cr, uid, { | 924 | currency_diff2 = account_move_line_obj.create(cr, uid, { |
119 | 877 | 'name': move.name, | 925 | 'name': move.name, |
120 | 878 | 'date': move.date, | 926 | 'date': move.date, |
121 | 879 | 'ref': move.ref, | 927 | 'ref': move.ref, |
122 | 880 | 'move_id': move_id, | 928 | 'move_id': move_id, |
123 | 881 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | 929 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, |
124 | 882 | 'account_id': partner_acc_id, | 930 | 'account_id': partner_acc_id, |
126 | 883 | 'credit': 0.0, | 931 | 'credit': 0.0, |
127 | 884 | 'debit': abs(balance), | 932 | 'debit': abs(balance), |
128 | 885 | 'statement_id': st.id, | 933 | 'statement_id': st.id, |
129 | 886 | 'journal_id': st.journal_id.id, | 934 | 'journal_id': st.journal_id.id, |
130 | @@ -888,13 +936,17 @@ | |||
131 | 888 | 'amount_currency': 0.0, | 936 | 'amount_currency': 0.0, |
132 | 889 | 'currency_id': currency_id, | 937 | 'currency_id': currency_id, |
133 | 890 | }, context=context) | 938 | }, context=context) |
135 | 891 | 939 | ||
136 | 940 | if move_line_data.invoice.currency_id.id != company_currency_id: | ||
137 | 941 | torec.append(currency_diff1) | ||
138 | 942 | |||
139 | 892 | new_end_value += amount+st_tax_amount-newline_sum | 943 | new_end_value += amount+st_tax_amount-newline_sum |
140 | 893 | 944 | ||
141 | 894 | if st.currency.id <> company_currency_id: | 945 | if st.currency.id <> company_currency_id: |
142 | 895 | amount_currency = res_currency_obj.compute(cr, uid, company_currency_id, st.currency.id, | 946 | amount_currency = res_currency_obj.compute(cr, uid, company_currency_id, st.currency.id, |
143 | 896 | (amount+st_tax_amount-newline_sum), context=context, | 947 | (amount+st_tax_amount-newline_sum), context=context, |
144 | 897 | account=acc_cur) | 948 | account=acc_cur) |
145 | 949 | currency_id = st.currency.id | ||
146 | 898 | 950 | ||
147 | 899 | account_move_line_obj.create(cr, uid, { | 951 | account_move_line_obj.create(cr, uid, { |
148 | 900 | 'name': move.name, | 952 | 'name': move.name, |
149 | @@ -924,7 +976,6 @@ | |||
150 | 924 | if line.state <> 'valid': | 976 | if line.state <> 'valid': |
151 | 925 | raise osv.except_osv(_('Error !'), | 977 | raise osv.except_osv(_('Error !'), |
152 | 926 | _('Account move line "%s" is not valid') % line.name) | 978 | _('Account move line "%s" is not valid') % line.name) |
153 | 927 | |||
154 | 928 | if move.reconcile_id and move.reconcile_id.line_ids: | 979 | if move.reconcile_id and move.reconcile_id.line_ids: |
155 | 929 | torec += map(lambda x: x.id, move.reconcile_id.line_ids) | 980 | torec += map(lambda x: x.id, move.reconcile_id.line_ids) |
156 | 930 | #try: | 981 | #try: |