From: Dikshit Prajapati Date: Wed, 1 Oct 2014 06:45:13 +0000 (+0530) Subject: [IMP] account: value_amount field 0-1 -> 0-100% X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=19c7bfb635e93b913255300f46e3c92f4277b656;p=odoo%2Fodoo.git [IMP] account: value_amount field 0-1 -> 0-100% --- diff --git a/addons/account/account.py b/addons/account/account.py index 9b80239..d74bfce 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -94,7 +94,7 @@ class account_payment_term(osv.osv): if line.value == 'fixed': amt = round(line.value_amount, prec) elif line.value == 'procent': - amt = round(value * line.value_amount, prec) + amt = round(value * (line.value_amount/100.0), prec) elif line.value == 'balance': amt = round(amount, prec) if amt: @@ -122,7 +122,7 @@ class account_payment_term_line(osv.osv): ('fixed', 'Fixed Amount')], 'Computation', required=True, help="""Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be treated."""), - 'value_amount': fields.float('Amount To Pay', digits_compute=dp.get_precision('Payment Term'), help="For percent enter a ratio between 0-1."), + 'value_amount': fields.float('Amount To Pay', digits_compute=dp.get_precision('Payment Term'), help="For percent enter a ratio between 0-100%."), 'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \ "If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."), 'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."), @@ -137,12 +137,12 @@ class account_payment_term_line(osv.osv): def _check_percent(self, cr, uid, ids, context=None): obj = self.browse(cr, uid, ids[0], context=context) - if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0): + if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 100.0): return False return True _constraints = [ - (_check_percent, 'Percentages for Payment Term Line must be between 0 and 1, Example: 0.02 for 2%.', ['value_amount']), + (_check_percent, 'Percentages for Payment Term Line must be between 0 and 100.', ['value_amount']), ] diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 0d6353d..ecb5c95 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -812,7 +812,7 @@ class account_invoice(models.Model): if line.value == 'fixed': total_fixed += line.value_amount if line.value == 'procent': - total_percent += line.value_amount + total_percent += (line.value_amount/100.0) total_fixed = (total_fixed * 100) / (inv.amount_total or 1.0) if (total_fixed + total_percent) > 100: raise except_orm(_('Error!'), _("Cannot create the invoice.\nThe related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount. In order to avoid rounding issues, the latest line of your payment term must be of type 'balance'.")) diff --git a/addons/account/demo/account_demo.xml b/addons/account/demo/account_demo.xml index 5ee0385..7bd02b8 100644 --- a/addons/account/demo/account_demo.xml +++ b/addons/account/demo/account_demo.xml @@ -144,7 +144,7 @@ procent - +