Merge lp:~openbig/bigconsulting/foreign_currency_changes into lp:bigconsulting

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
Reviewer Review Type Date Requested Status
openbig Pending
Review via email: mp+36456@code.launchpad.net

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
=== modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py'
--- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-22 14:21:33 +0000
+++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-09-23 15:15:57 +0000
@@ -786,7 +786,7 @@
786 new_amount_currency = 0.0786 new_amount_currency = 0.0
787 newline_amount_currency = 0.0787 newline_amount_currency = 0.0
788 for newline in move.reconcile_id.line_new_ids:788 for newline in move.reconcile_id.line_new_ids:
789 newline_amount_currency += newline.amount789 newline_amount_currency = newline.amount
790 if st.currency.id <> company_currency_id:790 if st.currency.id <> company_currency_id:
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,
792 company_currency_id, newline.amount, context=context)792 company_currency_id, newline.amount, context=context)
@@ -817,8 +817,7 @@
817 817
818 for line in move.reconcile_id.line_ids:818 for line in move.reconcile_id.line_ids:
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)
820 if st.currency.id <> (move_line_data.currency_id.id or company_currency_id):820 if st.currency.id <> company_currency_id:
821
822 expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id821 expense_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.expense_account_id.id
823 revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id822 revene_acc = res_users_obj.browse(cr, uid, uid, context=context).company_id.revenue_account_id.id
824 currency_id = st.currency.id823 currency_id = st.currency.id
@@ -836,6 +835,19 @@
836 for line in reconcile_data.line_new_ids:835 for line in reconcile_data.line_new_ids:
837 reconcile_sum += line.amount836 reconcile_sum += line.amount
838 balance = round((balance_sum - reconcile_sum),2)837 balance = round((balance_sum - reconcile_sum),2)
838
839 if st.currency.id <> move_line_data.currency_id.id:
840 invoice_cret_balance = 0.0
841 payment_balance = 0.0
842 context.update({'date': move_line_data.date})
843 inv_create_balance = res_currency_obj.compute(cr, uid, company_currency_id,
844 st.currency.id, amount, context=context)
845 currenct_date = time.strftime('%Y-%m-%d')
846 context.update({'date': currenct_date})
847 payment_balance = res_currency_obj.compute(cr, uid, company_currency_id,
848 st.currency.id, amount, context=context)
849 balance = inv_create_balance - payment_balance
850
839 ###### set fisical position for the currency_diff account and partner account851 ###### set fisical position for the currency_diff account and partner account
840 fpos = move_line_data.invoice.fiscal_position or False852 fpos = move_line_data.invoice.fiscal_position or False
841 if expense_acc:853 if expense_acc:
@@ -848,7 +860,7 @@
848 860
849 ## Account selection############861 ## Account selection############
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:
851 curr_diff_account_id = revene_acc 863 curr_diff_account_id = revene_acc
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:
853 curr_diff_account_id = expense_acc865 curr_diff_account_id = expense_acc
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:
@@ -856,14 +868,50 @@
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:
857 curr_diff_account_id = expense_acc869 curr_diff_account_id = expense_acc
858 #######################################870 #######################################
859 if balance > 0.0 or balance < 0.0: 871 if balance > 0.0:
860 account_move_line_obj.create(cr, uid, {872 currency_diff1 = account_move_line_obj.create(cr, uid, {
861 'name': move.name,873 'name': move.name,
862 'date': move.date,874 'date': move.date,
863 'ref': move.ref,875 'ref': move.ref,
864 'move_id': move_id,876 'move_id': move_id,
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,
866 'account_id': expense_acc,878 'account_id': move.account_id.id,
879 'credit': 0.0,
880 'debit': abs(balance),
881 'statement_id': st.id,
882 'journal_id': st.journal_id.id,
883 'period_id': st.period_id.id,
884 'amount_currency': 0.0,
885 'currency_id': currency_id,
886 }, context=context)
887
888 currency_diff2 = account_move_line_obj.create(cr, uid, {
889 'name': move.name,
890 'date': move.date,
891 'ref': move.ref,
892 'move_id': move_id,
893 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
894 'account_id': partner_acc_id,
895 'credit': abs(balance),
896 'debit': 0.0,
897 'statement_id': st.id,
898 'journal_id': st.journal_id.id,
899 'period_id': st.period_id.id,
900 'amount_currency': 0.0,
901 'currency_id': currency_id,
902 }, context=context)
903
904 if move_line_data.invoice.currency_id.id != company_currency_id:
905 torec.append(currency_diff1)
906
907 if balance < 0.0:
908 currency_diff1 = account_move_line_obj.create(cr, uid, {
909 'name': move.name,
910 'date': move.date,
911 'ref': move.ref,
912 'move_id': move_id,
913 'partner_id': ((move.partner_id) and move.partner_id.id) or False,
914 'account_id': move.account_id.id,
867 'credit': abs(balance),915 'credit': abs(balance),
868 'debit': 0.0,916 'debit': 0.0,
869 'statement_id': st.id,917 'statement_id': st.id,
@@ -872,15 +920,15 @@
872 'amount_currency': 0.0,920 'amount_currency': 0.0,
873 'currency_id': currency_id,921 'currency_id': currency_id,
874 }, context=context)922 }, context=context)
875 923
876 account_move_line_obj.create(cr, uid, {924 currency_diff2 = account_move_line_obj.create(cr, uid, {
877 'name': move.name,925 'name': move.name,
878 'date': move.date,926 'date': move.date,
879 'ref': move.ref,927 'ref': move.ref,
880 'move_id': move_id,928 'move_id': move_id,
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,
882 'account_id': partner_acc_id,930 'account_id': partner_acc_id,
883 'credit': 0.0,931 'credit': 0.0,
884 'debit': abs(balance),932 'debit': abs(balance),
885 'statement_id': st.id,933 'statement_id': st.id,
886 'journal_id': st.journal_id.id,934 'journal_id': st.journal_id.id,
@@ -888,13 +936,17 @@
888 'amount_currency': 0.0,936 'amount_currency': 0.0,
889 'currency_id': currency_id,937 'currency_id': currency_id,
890 }, context=context)938 }, context=context)
891 939
940 if move_line_data.invoice.currency_id.id != company_currency_id:
941 torec.append(currency_diff1)
942
892 new_end_value += amount+st_tax_amount-newline_sum943 new_end_value += amount+st_tax_amount-newline_sum
893 944
894 if st.currency.id <> company_currency_id:945 if st.currency.id <> company_currency_id:
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,
896 (amount+st_tax_amount-newline_sum), context=context,947 (amount+st_tax_amount-newline_sum), context=context,
897 account=acc_cur)948 account=acc_cur)
949 currency_id = st.currency.id
898950
899 account_move_line_obj.create(cr, uid, {951 account_move_line_obj.create(cr, uid, {
900 'name': move.name,952 'name': move.name,
@@ -924,7 +976,6 @@
924 if line.state <> 'valid':976 if line.state <> 'valid':
925 raise osv.except_osv(_('Error !'),977 raise osv.except_osv(_('Error !'),
926 _('Account move line "%s" is not valid') % line.name)978 _('Account move line "%s" is not valid') % line.name)
927
928 if move.reconcile_id and move.reconcile_id.line_ids:979 if move.reconcile_id and move.reconcile_id.line_ids:
929 torec += map(lambda x: x.id, move.reconcile_id.line_ids)980 torec += map(lambda x: x.id, move.reconcile_id.line_ids)
930 #try:981 #try:

Subscribers

People subscribed via source and target branches