[FIX]: improve payment terms, need to improve relativedelta(day=-1) as it will not work
like RelativeDateTime(day=-1) is working -ve val now working with relativedelta with day params [IMP]: improve the code remove TABs bzr revid: mga@tinyerp.com-20100809174801-slgotvx5f194fen1
This commit is contained in:
parent
42069b5302
commit
eda647c97a
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
import time
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from operator import itemgetter
|
||||
|
||||
|
@ -79,9 +79,20 @@ class account_payment_term(osv.osv):
|
|||
elif line.value == 'balance':
|
||||
amt = round(amount, prec)
|
||||
if amt:
|
||||
next_date = datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days)
|
||||
next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days))
|
||||
if line.days2 < 0:
|
||||
next_date += relativedelta(day=line.days2)
|
||||
nyear = next_date.strftime("%Y")
|
||||
nmonth = str(int(next_date.strftime("%m"))% 12+2)
|
||||
nday = "1"
|
||||
|
||||
ndate = "%s-%s-%s" % (nyear, nmonth, nday)
|
||||
nseconds = time.mktime(time.strptime(ndate, '%Y-%m-%d'))
|
||||
next_month = datetime.fromtimestamp(nseconds)
|
||||
|
||||
delta = timedelta(seconds=1)
|
||||
next_date = next_month - delta
|
||||
|
||||
next_date = next_date + relativedelta(days=line.days2)
|
||||
if line.days2 > 0:
|
||||
next_date += relativedelta(day=line.days2, months=1)
|
||||
result.append( (next_date.strftime('%Y-%m-%d'), amt) )
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Import Entries">
|
||||
<group colspan="4" >
|
||||
<field name="line_ids" />
|
||||
<group colspan="4" expand="1">
|
||||
<separator string="Payable and Receivables" colspan="4"/>
|
||||
<field name="line_ids" colspan="4" nolabel="1"/>
|
||||
</group>
|
||||
<group colspan="4" col="6">
|
||||
<label string ="" colspan="2"/>
|
||||
|
@ -56,7 +57,5 @@
|
|||
<field name="target">new</field>
|
||||
<field name="context">{'statement_id': active_id}</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue