[REF] account_payment: removal of amount_to_pay field on account.move.line and account.invoice, replaced by amount_residual
bzr revid: qdp-launchpad@openerp.com-20130318122748-ac9k5bhka1foadvr
This commit is contained in:
parent
2b64c79c3d
commit
333e83fc5b
|
@ -53,7 +53,6 @@ have a new option to import payment orders as bank statement lines.
|
||||||
'account_payment_view.xml',
|
'account_payment_view.xml',
|
||||||
'account_payment_workflow.xml',
|
'account_payment_workflow.xml',
|
||||||
'account_payment_sequence.xml',
|
'account_payment_sequence.xml',
|
||||||
'account_invoice_view.xml',
|
|
||||||
'account_payment_report.xml',
|
'account_payment_report.xml',
|
||||||
],
|
],
|
||||||
'demo': ['account_payment_demo.xml'],
|
'demo': ['account_payment_demo.xml'],
|
||||||
|
|
|
@ -19,9 +19,8 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.osv import fields, osv
|
from openerp.osv import osv
|
||||||
|
|
||||||
class Invoice(osv.osv):
|
class Invoice(osv.osv):
|
||||||
_inherit = 'account.invoice'
|
_inherit = 'account.invoice'
|
||||||
|
@ -43,13 +42,6 @@ class Invoice(osv.osv):
|
||||||
raise osv.except_osv(_('Error!'), _("You cannot cancel an invoice which has already been imported in a payment order. Remove it from the following payment order : %s."%(payment_order_name)))
|
raise osv.except_osv(_('Error!'), _("You cannot cancel an invoice which has already been imported in a payment order. Remove it from the following payment order : %s."%(payment_order_name)))
|
||||||
return super(Invoice, self).action_cancel(cr, uid, ids, context=context)
|
return super(Invoice, self).action_cancel(cr, uid, ids, context=context)
|
||||||
|
|
||||||
|
|
||||||
_columns = {
|
|
||||||
'amount_to_pay': fields.related('residual',
|
|
||||||
type='float', string='Amount to be paid',
|
|
||||||
help='The amount which should be paid at the current date. '),
|
|
||||||
}
|
|
||||||
|
|
||||||
Invoice()
|
Invoice()
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<openerp>
|
|
||||||
<data>
|
|
||||||
<record id="invoice_supplier_form" model="ir.ui.view">
|
|
||||||
<field name="name">account.invoice.supplier.form.inherit</field>
|
|
||||||
<field name="model">account.invoice</field>
|
|
||||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="partner_bank_id" position="before">
|
|
||||||
<field name="amount_to_pay"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</openerp>
|
|
|
@ -19,65 +19,12 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from operator import itemgetter
|
from openerp.osv import osv
|
||||||
from openerp.osv import fields, osv
|
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
|
|
||||||
class account_move_line(osv.osv):
|
class account_move_line(osv.osv):
|
||||||
_inherit = "account.move.line"
|
_inherit = "account.move.line"
|
||||||
|
|
||||||
def amount_to_pay(self, cr, uid, ids, name, arg=None, context=None):
|
|
||||||
""" Return the amount still to pay regarding all the payemnt orders
|
|
||||||
(excepting cancelled orders)"""
|
|
||||||
if not ids:
|
|
||||||
return {}
|
|
||||||
cr.execute("""SELECT ml.id,
|
|
||||||
CASE WHEN ml.amount_currency < 0
|
|
||||||
THEN - ml.amount_currency
|
|
||||||
ELSE ml.credit
|
|
||||||
END -
|
|
||||||
(SELECT coalesce(sum(amount_currency),0)
|
|
||||||
FROM payment_line pl
|
|
||||||
INNER JOIN payment_order po
|
|
||||||
ON (pl.order_id = po.id)
|
|
||||||
WHERE move_line_id = ml.id
|
|
||||||
AND po.state != 'cancel') AS amount
|
|
||||||
FROM account_move_line ml
|
|
||||||
WHERE id IN %s""", (tuple(ids),))
|
|
||||||
r = dict(cr.fetchall())
|
|
||||||
return r
|
|
||||||
|
|
||||||
def _to_pay_search(self, cr, uid, obj, name, args, context=None):
|
|
||||||
if not args:
|
|
||||||
return []
|
|
||||||
line_obj = self.pool.get('account.move.line')
|
|
||||||
query = line_obj._query_get(cr, uid, context={})
|
|
||||||
where = ' and '.join(map(lambda x: '''(SELECT
|
|
||||||
CASE WHEN l.amount_currency < 0
|
|
||||||
THEN - l.amount_currency
|
|
||||||
ELSE l.credit
|
|
||||||
END - coalesce(sum(pl.amount_currency), 0)
|
|
||||||
FROM payment_line pl
|
|
||||||
INNER JOIN payment_order po ON (pl.order_id = po.id)
|
|
||||||
WHERE move_line_id = l.id
|
|
||||||
AND po.state != 'cancel'
|
|
||||||
) %(operator)s %%s ''' % {'operator': x[1]}, args))
|
|
||||||
sql_args = tuple(map(itemgetter(2), args))
|
|
||||||
|
|
||||||
cr.execute(('''SELECT id
|
|
||||||
FROM account_move_line l
|
|
||||||
WHERE account_id IN (select id
|
|
||||||
FROM account_account
|
|
||||||
WHERE type=%s AND active)
|
|
||||||
AND reconcile_id IS null
|
|
||||||
AND credit > 0
|
|
||||||
AND ''' + where + ' and ' + query), ('payable',)+sql_args )
|
|
||||||
|
|
||||||
res = cr.fetchall()
|
|
||||||
if not res:
|
|
||||||
return [('id', '=', '0')]
|
|
||||||
return [('id', 'in', map(lambda x:x[0], res))]
|
|
||||||
|
|
||||||
def line2bank(self, cr, uid, ids, payment_type=None, context=None):
|
def line2bank(self, cr, uid, ids, payment_type=None, context=None):
|
||||||
"""
|
"""
|
||||||
Try to return for each Ledger Posting line a corresponding bank
|
Try to return for each Ledger Posting line a corresponding bank
|
||||||
|
@ -110,11 +57,6 @@ class account_move_line(osv.osv):
|
||||||
raise osv.except_osv(_('Error!'), _('There is no partner defined on the entry line.'))
|
raise osv.except_osv(_('Error!'), _('There is no partner defined on the entry line.'))
|
||||||
return line2bank
|
return line2bank
|
||||||
|
|
||||||
_columns = {
|
|
||||||
'amount_to_pay': fields.function(amount_to_pay,
|
|
||||||
type='float', string='Amount to pay', fnct_search=_to_pay_search),
|
|
||||||
}
|
|
||||||
|
|
||||||
account_move_line()
|
account_move_line()
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -352,7 +352,7 @@ class payment_line(osv.osv):
|
||||||
|
|
||||||
if move_line_id:
|
if move_line_id:
|
||||||
line = move_line_obj.browse(cr, uid, move_line_id, context=context)
|
line = move_line_obj.browse(cr, uid, move_line_id, context=context)
|
||||||
data['amount_currency'] = line.amount_to_pay
|
data['amount_currency'] = line.amount_residual_currency
|
||||||
|
|
||||||
res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency,
|
res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency,
|
||||||
company_currency, context)
|
company_currency, context)
|
||||||
|
|
|
@ -2,29 +2,6 @@
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<!-- View used in the wizard -->
|
|
||||||
<record id="view_move_line_form" model="ir.ui.view">
|
|
||||||
<field name="name">account.move.line.form.inherit</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_line_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="reconcile_partial_id" position="after">
|
|
||||||
<field name="amount_to_pay"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- <record model="ir.ui.view" id="view_move_line_tree_wiz">
|
|
||||||
<field name="name">account.move.line.tree</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_line_tree"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="reconcile" position="after">
|
|
||||||
<field name="amount_to_pay"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record> -->
|
|
||||||
|
|
||||||
<menuitem id="menu_main_payment" name="Payment" parent="account.menu_finance" sequence="7"/>
|
<menuitem id="menu_main_payment" name="Payment" parent="account.menu_finance" sequence="7"/>
|
||||||
|
|
||||||
<record id="view_payment_mode_search" model="ir.ui.view">
|
<record id="view_payment_mode_search" model="ir.ui.view">
|
||||||
|
@ -116,7 +93,7 @@
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Payment">
|
<page string="Payment">
|
||||||
<group col="4">
|
<group col="4">
|
||||||
<field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_scheduled,currency,company_currency)" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/>
|
<field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_scheduled,currency,company_currency)" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_residual','>',0)] "/>
|
||||||
<separator colspan="4" string="Transaction Information"/>
|
<separator colspan="4" string="Transaction Information"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<label for="amount_currency" groups="base.group_multi_currency"/>
|
<label for="amount_currency" groups="base.group_multi_currency"/>
|
||||||
|
@ -242,7 +219,7 @@
|
||||||
<page string="Payment">
|
<page string="Payment">
|
||||||
<group col="4">
|
<group col="4">
|
||||||
<field name="order_id"/>
|
<field name="order_id"/>
|
||||||
<field name="move_line_id" on_change="onchange_move_line(move_line_id, False, currency, company_currency)" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)]"/>
|
<field name="move_line_id" on_change="onchange_move_line(move_line_id, False, currency, company_currency)" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_residual','>',0)]"/>
|
||||||
<separator colspan="4" string="Transaction Information"/>
|
<separator colspan="4" string="Transaction Information"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<label for="amount_currency" groups="base.group_multi_currency"/>
|
<label for="amount_currency" groups="base.group_multi_currency"/>
|
||||||
|
|
|
@ -82,7 +82,7 @@ class payment_order_create(osv.osv_memory):
|
||||||
date_to_pay = payment.date_scheduled
|
date_to_pay = payment.date_scheduled
|
||||||
payment_obj.create(cr, uid,{
|
payment_obj.create(cr, uid,{
|
||||||
'move_line_id': line.id,
|
'move_line_id': line.id,
|
||||||
'amount_currency': line.amount_to_pay,
|
'amount_currency': line.amount_residual_currency,
|
||||||
'bank_id': line2bank.get(line.id),
|
'bank_id': line2bank.get(line.id),
|
||||||
'order_id': payment.id,
|
'order_id': payment.id,
|
||||||
'partner_id': line.partner_id and line.partner_id.id or False,
|
'partner_id': line.partner_id and line.partner_id.id or False,
|
||||||
|
@ -102,7 +102,7 @@ class payment_order_create(osv.osv_memory):
|
||||||
# payment = self.pool.get('payment.order').browse(cr, uid, context['active_id'], context=context)
|
# payment = self.pool.get('payment.order').browse(cr, uid, context['active_id'], context=context)
|
||||||
|
|
||||||
# Search for move line to pay:
|
# Search for move line to pay:
|
||||||
domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_to_pay', '>', 0)]
|
domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_residual', '>', 0)]
|
||||||
domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)]
|
domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)]
|
||||||
line_ids = line_obj.search(cr, uid, domain, context=context)
|
line_ids = line_obj.search(cr, uid, domain, context=context)
|
||||||
context.update({'line_ids': line_ids})
|
context.update({'line_ids': line_ids})
|
||||||
|
|
Loading…
Reference in New Issue