Ravi Gohil (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.1-opw-577100-rgo into
lp:openobject-addons/6.1.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-577100-rgo/+merge/118711
Hello,
Validating the voucher after adding/altering Tax Amount in Sale
Receipt/Purchase Receipt/Journal Voucher forms results in unbalanced journal
items.
Steps to reproduce:
1) Create a record for Sale Receipt, add lines and select a Tax,
2) Alter the tax amount and validate the voucher,
You will have unbalanced entries in 'Journal Items' tab.
This fix fixes this issue by restricting users from doing so by showing
appropriate warning message.
Please review the fix.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-577100-rgo/+merge/118711
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.1-opw-577100-rgo.
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2012-07-17 12:50:52 +0000
+++ account_voucher/account_voucher.py 2012-08-08 10:57:20 +0000
@@ -757,7 +757,27 @@
vals[key].update(res[key])
return vals
+ def _check_tax_amount(self, cr, uid, ids, context=None):
+ '''
+ This method restricts users to alter the tax amount manually
+ in Sale Receipt/Purchase Receipt/Journal Voucher forms by
+ raising appropriate warning message when validated.
+ '''
+ for voucher in self.browse(cr, uid, ids, context=context):
+ if not voucher.tax_id.id and voucher.tax_amount:
+ raise osv.except_osv(_('Warning!'), _('Tax Amount %.2f does not represent a valid Tax!') % voucher.tax_amount)
+ else:
+ if not voucher.line_ids and not voucher.tax_amount:
+ return True
+ else:
+ line_ids = [[1, line.id, {'amount': line.amount}] for line in voucher.line_ids]
+ tax_price = self.onchange_price(cr, uid, ids, line_ids, voucher.tax_id.id, voucher.partner_id.id, context)['value']['tax_amount']
+ if voucher.tax_amount != tax_price:
+ raise osv.except_osv(_('Warning!'), _('Tax Amount %.2f does not match with calculated tax amount %.2f for "%s"!') % (voucher.tax_amount, tax_price, voucher.tax_id.name))
+ return True
+
def proforma_voucher(self, cr, uid, ids, context=None):
+ self._check_tax_amount(cr, uid, ids, context)
self.action_move_line_create(cr, uid, ids, context=context)
return True
_______________________________________________
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