[IMP] account: value_amount field 0-1 -> 0-100%
authorDikshit Prajapati <pdi@openerp.com>
Wed, 1 Oct 2014 06:45:13 +0000 (12:15 +0530)
committerRichard Mathot <rim@openerp.com>
Tue, 14 Oct 2014 08:52:49 +0000 (10:52 +0200)
addons/account/account.py
addons/account/account_invoice.py
addons/account/demo/account_demo.xml

index 9b80239..d74bfce 100644 (file)
@@ -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']),
     ]
 
 
index 0d6353d..ecb5c95 100644 (file)
@@ -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'."))
index 5ee0385..7bd02b8 100644 (file)
         </record>
         <record id="account_payment_term_line_advance1" model="account.payment.term.line">
             <field name="value">procent</field>
-            <field eval="0.300000" name="value_amount"/>
+            <field eval="30.00" name="value_amount"/>
             <field eval="0" name="days"/>
             <field eval="0" name="days2"/>
             <field eval="account_payment_term_advance" name="payment_id"/>