Merge lp:~openerp-dev/openobject-addons/trunk-bug-827649-bde into lp:openobject-addons

Proposed by Bharat Devnani (Open ERP)
Status: Rejected
Rejected by: Fabien (Open ERP)
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-827649-bde
Merge into: lp:openobject-addons
Diff against target: 165 lines (+48/-18)
1 file modified
account_voucher/account_voucher.py (+48/-18)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-827649-bde
Reviewer Review Type Date Requested Status
Bharat Devnani (Open ERP) (community) Needs Resubmitting
Purnendu Singh (OpenERP) (community) Needs Fixing
OpenERP Core Team Pending
Review via email: mp+80869@code.launchpad.net

Description of the change

Hello Sir,

I have corrected the tax value in account_voucher when in it was included in the price.

Thanks & Regards,
Devnani Bharat R.

To post a comment you must log in.
5449. By Bharat Devnani (Open ERP)

[REM] Account : removed unnecessary code

5450. By Bharat Devnani (Open ERP)

[REM] Account : removed unnecessary code

Revision history for this message
Purnendu Singh (OpenERP) (purnendu-singh) wrote :

1) if there isn't any change in account_move_line.py then why it is in your patch!!!!

2) in your patch line 91
    + voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context=context)
    * please make a habit of pooling all required objects at the start of the method
    * browse(cr,uid,voucher_id,context=context)..... we generally using a space between each arguments
3) line 137 to 159 it can be optimize. there are too many variables used!!!! Improve this

review: Needs Fixing
5451. By Bharat Devnani (Open ERP)

[IMP] account_voucher : improved the code in account_voucher/account_voucher.py

Revision history for this message
Bharat Devnani (Open ERP) (bde-openerp) wrote :

Hello Sir,

I have improved the code in account_voucher/account_voucher.py

Thanks & Regards,
Devnani Bharat R.

review: Needs Resubmitting
5452. By Bharat Devnani (Open ERP)

[IMP] account_voucher : pooled the object at start of the method

5453. By Bharat Devnani (Open ERP)

[IMP] account_voucher : optimized the code and made the searching next move_line more dynamic

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

I do not understand why we compute the tax manually ?
The tax object should compute the tax itself.

Unmerged revisions

5453. By Bharat Devnani (Open ERP)

[IMP] account_voucher : optimized the code and made the searching next move_line more dynamic

5452. By Bharat Devnani (Open ERP)

[IMP] account_voucher : pooled the object at start of the method

5451. By Bharat Devnani (Open ERP)

[IMP] account_voucher : improved the code in account_voucher/account_voucher.py

5450. By Bharat Devnani (Open ERP)

[REM] Account : removed unnecessary code

5449. By Bharat Devnani (Open ERP)

[REM] Account : removed unnecessary code

5448. By Bharat Devnani (Open ERP)

[FIX] Account : Supplier voucher - wrong for tax inclusive

5447. By Bharat Devnani (Open ERP)

In Progress

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account/account.py'
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2011-10-27 21:11:24 +0000
+++ account_voucher/account_voucher.py 2011-11-11 06:04:26 +0000
@@ -26,6 +26,7 @@
26from osv import osv, fields26from osv import osv, fields
27import decimal_precision as dp27import decimal_precision as dp
28from tools.translate import _28from tools.translate import _
29import tools
2930
3031
31class account_voucher(osv.osv):32class account_voucher(osv.osv):
@@ -518,7 +519,7 @@
518 elif currency_id == company_currency:519 elif currency_id == company_currency:
519 #otherwise treatments is the same but with other field names520 #otherwise treatments is the same but with other field names
520 if line.amount_residual == price:521 if line.amount_residual == price:
521 #if the amount residual is equal the amount voucher, we assign it to that voucher 522 #if the amount residual is equal the amount voucher, we assign it to that voucher
522 #line, whatever the other voucher lines523 #line, whatever the other voucher lines
523 move_line_found = line.id524 move_line_found = line.id
524 break525 break
@@ -696,8 +697,8 @@
696 Select the context to use accordingly if it needs to be multicurrency or not.697 Select the context to use accordingly if it needs to be multicurrency or not.
697698
698 :param voucher_id: Id of the actual voucher699 :param voucher_id: Id of the actual voucher
699 :return: The returned context will be the same as given in parameter if the voucher currency is the same 700 :return: The returned context will be the same as given in parameter if the voucher currency is the same
700 than the company currency, otherwise it's a copy of the parameter with an extra key 'date' containing 701 than the company currency, otherwise it's a copy of the parameter with an extra key 'date' containing
701 the date of the voucher.702 the date of the voucher.
702 :rtype: dict703 :rtype: dict
703 """704 """
@@ -726,13 +727,19 @@
726 voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)727 voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)
727 debit = credit = 0.0728 debit = credit = 0.0
728 # TODO: is there any other alternative then the voucher type ??729 # TODO: is there any other alternative then the voucher type ??
729 # ANSWER: We can have payment and receipt "In Advance". 730 # ANSWER: We can have payment and receipt "In Advance".
730 # TODO: Make this logic available.731 # TODO: Make this logic available.
731 # -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt732 # -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt
732 if voucher_brw.type in ('purchase', 'payment'):733 if voucher_brw.type in ('purchase', 'payment'):
733 credit = voucher_brw.amount / voucher_brw.payment_rate734 if voucher_brw.tax_id.price_include:
735 credit = (voucher_brw.amount - voucher_brw.tax_amount) / voucher_brw.payment_rate
736 else :
737 credit = voucher_brw.amount / voucher_brw.payment_rate
734 elif voucher_brw.type in ('sale', 'receipt'):738 elif voucher_brw.type in ('sale', 'receipt'):
735 debit = voucher_brw.amount / voucher_brw.payment_rate739 if voucher_brw.tax_id.price_include:
740 debit = (voucher_brw.amount - voucher_brw.tax_amount) / voucher_brw.payment_rate
741 else:
742 debit = voucher_brw.amount / voucher_brw.payment_rate
736 if debit < 0: credit = -debit; debit = 0.0743 if debit < 0: credit = -debit; debit = 0.0
737 if credit < 0: debit = -credit; credit = 0.0744 if credit < 0: debit = -credit; credit = 0.0
738 sign = debit - credit < 0 and -1 or 1745 sign = debit - credit < 0 and -1 or 1
@@ -769,7 +776,7 @@
769 elif voucher_brw.journal_id.sequence_id:776 elif voucher_brw.journal_id.sequence_id:
770 name = seq_obj.next_by_id(cr, uid, voucher_brw.journal_id.sequence_id.id)777 name = seq_obj.next_by_id(cr, uid, voucher_brw.journal_id.sequence_id.id)
771 else:778 else:
772 raise osv.except_osv(_('Error !'), 779 raise osv.except_osv(_('Error !'),
773 _('Please define a sequence on the journal !'))780 _('Please define a sequence on the journal !'))
774 if not voucher_brw.reference:781 if not voucher_brw.reference:
775 ref = name.replace('/','')782 ref = name.replace('/','')
@@ -834,7 +841,7 @@
834 def voucher_move_line_create(self, cr, uid, voucher_id, line_total, move_id, company_currency, current_currency, context=None):841 def voucher_move_line_create(self, cr, uid, voucher_id, line_total, move_id, company_currency, current_currency, context=None):
835 '''842 '''
836 Create one account move line, on the given account move, per voucher line where amount is not 0.0.843 Create one account move line, on the given account move, per voucher line where amount is not 0.0.
837 It returns Tuple with tot_line what is total of difference between debit and credit and 844 It returns Tuple with tot_line what is total of difference between debit and credit and
838 a list of lists with ids to be reconciled with this format (total_deb_cred,list_of_lists).845 a list of lists with ids to be reconciled with this format (total_deb_cred,list_of_lists).
839846
840 :param voucher_id: Voucher id what we are working with847 :param voucher_id: Voucher id what we are working with
@@ -849,8 +856,9 @@
849 currency_obj = self.pool.get('res.currency')856 currency_obj = self.pool.get('res.currency')
850 tot_line = line_total857 tot_line = line_total
851 rec_lst_ids = []858 rec_lst_ids = []
852859 tax_obj = self.pool.get('account.tax')
853 voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)860 account_voucher_obj = self.pool.get('account.voucher')
861 voucher_brw = account_voucher_obj.browse(cr, uid, voucher_id, context=context)
854 for line in voucher_brw.line_ids:862 for line in voucher_brw.line_ids:
855 #create one move line per voucher line where amount is not 0.0863 #create one move line per voucher line where amount is not 0.0
856 if not line.amount:864 if not line.amount:
@@ -860,7 +868,10 @@
860 amount = (line.untax_amount or line.amount) / voucher_brw.payment_rate868 amount = (line.untax_amount or line.amount) / voucher_brw.payment_rate
861 amount_residual = line.move_line_id.amount_residual - amount #residual amount in company currency869 amount_residual = line.move_line_id.amount_residual - amount #residual amount in company currency
862 else:870 else:
863 amount = (line.untax_amount or line.amount) / voucher_brw.payment_rate871 if voucher_brw.tax_id.price_include:
872 amount = line.amount / voucher_brw.payment_rate
873 else:
874 amount = (line.untax_amount or line.amount) / voucher_brw.payment_rate
864 amount_residual = 0.0875 amount_residual = 0.0
865 move_line = {876 move_line = {
866 'journal_id': voucher_brw.journal_id.id,877 'journal_id': voucher_brw.journal_id.id,
@@ -874,8 +885,9 @@
874 'quantity': 1,885 'quantity': 1,
875 'credit': 0.0,886 'credit': 0.0,
876 'debit': 0.0,887 'debit': 0.0,
877 'date': voucher_brw.date888 'date': voucher_brw.date,
878 }889 }
890
879 if amount < 0:891 if amount < 0:
880 amount = -amount892 amount = -amount
881 if line.type == 'dr':893 if line.type == 'dr':
@@ -895,17 +907,37 @@
895 'account_tax_id': voucher_brw.tax_id.id,907 'account_tax_id': voucher_brw.tax_id.id,
896 })908 })
897909
910 # Creates 2nd move line
898 if move_line.get('account_tax_id', False):911 if move_line.get('account_tax_id', False):
899 tax_data = tax_obj.browse(cr, uid, [move_line['account_tax_id']], context=context)[0]912 tax_data = tax_obj.browse(cr, uid, [move_line['account_tax_id']], context=context)[0]
900 if not (tax_data.base_code_id and tax_data.tax_code_id):913 if not (tax_data.base_code_id and tax_data.tax_code_id):
901 raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name))914 raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name))
902
903 sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1915 sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1
904 move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or False916 move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or False
905 voucher_line = move_line_obj.create(cr, uid, move_line)917 voucher_line = move_line_obj.create(cr, uid, move_line, context=context)
918 move_line = move_line_obj.browse(cr, uid, voucher_line, context=context)
919 next_line = tools.ustr(move_line.name) + ' ' + tools.ustr(voucher_brw.tax_id.name)
920 line_search = move_line_obj.search(cr, uid, ['&', ('name','=', next_line), ('id', '>', voucher_line)], context=context)
921 for vals in move_line_obj.browse(cr, uid, line_search, context=context):
922 vals = vals.id
923 if voucher_brw.tax_id.amount:
924 amount = voucher_brw.amount - (voucher_brw.amount * 100) / (100 + (voucher_brw.tax_id.amount * 100))
925
926 if voucher_brw.tax_id.price_include:
927 if (line.type=='dr'):
928 move_line_obj.write(cr, uid, [vals], {
929 'tax_amount': amount,
930 'debit': amount,
931 })
932
933 if (line.type=='cr'):
934 move_line_obj.write(cr, uid, [vals], {
935 'tax_amount': amount,
936 'credit': amount,
937 })
938
906 rec_ids = [voucher_line, line.move_line_id.id]939 rec_ids = [voucher_line, line.move_line_id.id]
907940 if amount_residual:
908 if amount_residual:
909 # Change difference entry941 # Change difference entry
910 exch_lines = self._get_exchange_lines(cr, uid, line, move_id, amount_residual, company_currency, current_currency, context=context)942 exch_lines = self._get_exchange_lines(cr, uid, line, move_id, amount_residual, company_currency, current_currency, context=context)
911 new_id = move_line_obj.create(cr, uid, exch_lines[0],context)943 new_id = move_line_obj.create(cr, uid, exch_lines[0],context)
@@ -914,7 +946,6 @@
914946
915 if line.move_line_id.id:947 if line.move_line_id.id:
916 rec_lst_ids.append(rec_ids)948 rec_lst_ids.append(rec_ids)
917
918 return (tot_line, rec_lst_ids)949 return (tot_line, rec_lst_ids)
919950
920 def writeoff_move_line_get(self, cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=None):951 def writeoff_move_line_get(self, cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=None):
@@ -1200,7 +1231,6 @@
1200 bank_st_line_obj.write(cr, uid, [st_line_id], {1231 bank_st_line_obj.write(cr, uid, [st_line_id], {
1201 'move_ids': [(4, v.move_id.id, False)]1232 'move_ids': [(4, v.move_id.id, False)]
1202 })1233 })
1203
1204 return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)1234 return move_line_obj.write(cr, uid, [x.id for x in v.move_ids], {'statement_id': st_line.statement_id.id}, context=context)
1205 return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)1235 return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
12061236

Subscribers

People subscribed via source and target branches

to all changes: