[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:
Mantavya Gajjar 2010-08-09 23:18:01 +05:30
parent 42069b5302
commit eda647c97a
4 changed files with 45 additions and 35 deletions

View File

@ -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) )

View File

@ -462,7 +462,7 @@ class account_invoice(osv.osv):
date_invoice = time.strftime('%Y-%m-%d')
pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
if pterm_list:
pterm_list = [line[0] for line in pterm_list]
pterm_list.sort()

View File

@ -92,7 +92,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
'ref': line.ref,
'reconcile_id': reconcile_id,
'date': time.strftime('%Y-%m-%d'), #time.strftime('%Y-%m-%d'), #line.date_maturity or,
}, context=context)
}, context=context)
return {}
account_statement_from_invoice_lines()
@ -107,10 +107,10 @@ class account_statement_from_invoice(osv.osv_memory):
'date': fields.date('Date payment',required=True),
'journal_ids': fields.many2many('account.journal', 'account_journal_relation', 'account_id', 'journal_id', 'Journal'),
'line_ids': fields.many2many('account.move.line', 'account_move_line_relation', 'move_id', 'line_id', 'Invoices'),
}
}
_defaults = {
'date':lambda *a: time.strftime('%Y-%m-%d'),
}
}
def search_invoices(self, cr, uid, ids, context=None):
@ -167,4 +167,4 @@ class account_statement_from_invoice(osv.osv_memory):
}
account_statement_from_invoice()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,33 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_statement_from_invoice" model="ir.ui.view">
<record id="view_account_statement_from_invoice" model="ir.ui.view">
<field name="name">account.statement.from.invoice.form</field>
<field name="model">account.statement.from.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Invoices in Statement">
<group colspan="4" >
<field name="date"/>
<newline/>
<field name="journal_ids" domain="[('type','in',['sale','purchase','cash'])]"/>
</group>
<group colspan="4" >
<field name="date"/>
<newline/>
<field name="journal_ids" domain="[('type','in',['sale','purchase','cash'])]"/>
</group>
<group colspan="4" col="6">
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="terp-gtk-go-back-rtl" string="Go" name="search_invoices" type="object"/>
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="terp-gtk-go-back-rtl" string="Go" name="search_invoices" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_view_account_statement_from_invoice" model="ir.actions.act_window">
<field name="name">Import Invoices in Statement</field>
<record id="action_view_account_statement_from_invoice" model="ir.actions.act_window">
<field name="name">Import Invoices in Statement</field>
<field name="res_model">account.statement.from.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_statement_from_invoice"/>
<field name="target">new</field>
<field name="view_id" ref="view_account_statement_from_invoice"/>
<field name="target">new</field>
</record>
<record id="view_account_statement_from_invoice_lines" model="ir.ui.view">
@ -36,27 +36,26 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Entries">
<group colspan="4" >
<field name="line_ids" />
</group>
<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"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Ok" name="populate_statement" type="object"/>
<label string ="" colspan="2"/>
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="gtk-execute" string="Ok" name="populate_statement" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_view_account_statement_from_invoice_lines" model="ir.actions.act_window">
<field name="name">Import Entries</field>
<record id="action_view_account_statement_from_invoice_lines" model="ir.actions.act_window">
<field name="name">Import Entries</field>
<field name="res_model">account.statement.from.invoice.lines</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_statement_from_invoice_lines"/>
<field name="target">new</field>
<field name="context">{'statement_id': active_id}</field>
<field name="view_id" ref="view_account_statement_from_invoice_lines"/>
<field name="target">new</field>
<field name="context">{'statement_id': active_id}</field>
</record>
</data>
</data>
</openerp>