account-payment-team team mailing list archive
-
account-payment-team team
-
Mailing list archive
-
Message #00270
lp:~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves into lp:account-payment/7.0
Pedro Rodríguez Gil (Otherway) has proposed merging lp:~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves into lp:account-payment/7.0.
Commit message:
[IMP]-Added functionality which allows to make a payment order from manual moves for payable accounts which are not linked to an invoice line.
Requested reviews:
Account Payment (account-payment-team)
For more details, see:
https://code.launchpad.net/~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves/+merge/203005
[IMP] - Added functionality which allows to make a payment order from manual moves for payable accounts which are not linked to an invoice line. For example when accounting salaries for employees and making an payment order for them.
--
https://code.launchpad.net/~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves/+merge/203005
Your team Account Payment is requested to review the proposed merge of lp:~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves into lp:account-payment/7.0.
=== modified file 'account_payment_extension/account_move_line.py'
--- account_payment_extension/account_move_line.py 2013-11-10 17:00:26 +0000
+++ account_payment_extension/account_move_line.py 2014-01-24 08:18:27 +0000
@@ -27,7 +27,6 @@
from openerp.osv import fields, orm
-
class account_move_line(orm.Model):
_inherit = 'account.move.line'
@@ -144,6 +143,7 @@
def _payment_type_get(self, cr, uid, ids, field_name, arg, context={}):
result = {}
invoice_obj = self.pool.get('account.invoice')
+ partner_obj = self.pool.get('res.partner')
for move_line in self.browse(cr, uid, ids, context):
result[move_line.id] = (0, 0)
invoice_id = invoice_obj.search(
@@ -155,6 +155,21 @@
result[move_line.id] = (inv.payment_type.id, self.pool.get(
'payment.type').browse(
cr, uid, inv.payment_type.id, context).name)
+
+ else:
+ partner_id = partner_obj.search(
+ cr, uid, [('id', '=', move_line.partner_id.id)],
+ context=context)
+ if partner_id:
+ partner = partner_obj.browse(cr, uid, partner_id[0], context)
+ if partner.payment_type_supplier:
+ result[move_line.id] = (partner.payment_type_supplier.id, self.pool.get(
+ 'payment.type').browse(
+ cr, uid, partner.payment_type_supplier.id, context).name)
+ elif partner.payment_type_customer:
+ result[move_line.id] = (partner.payment_type_customer.id, self.pool.get(
+ 'payment.type').browse(
+ cr, uid, partner.payment_type_customer.id, context).name)
return result
def _payment_type_search(self, cr, uid, obj, name, args, context={}):
@@ -173,13 +188,29 @@
ids = self.pool.get('payment.type').search(
cr, uid, [('name', 'ilike', value)], context=context)
if ids:
+
cr.execute("""SELECT l.id
FROM
account_move_line l, account_invoice i
WHERE
- l.move_id = i.move_id AND
- i.payment_type in (%s)""" % (','.join(map(str, ids))))
- res = cr.fetchall()
+ l.move_id = i.move_id AND i.payment_type in (%s)""" % (','.join(map(str, ids))))
+ res_invoice = cr.fetchall()
+
+ cr.execute("""SELECT l.id
+ FROM
+ account_move_line l, ir_property p
+ WHERE
+ l.move_id NOT IN (SELECT i.move_id FROM account_invoice i)
+ AND
+ l.partner_id = CAST(replace(p.res_id, 'res.partner,', '') AS INTEGER)
+ AND
+ (p.name = 'payment_type_supplier' OR p.name = 'payment_type_customer')
+ AND
+ p.value_reference = '%s' """ % ('payment.type,' + map(str, ids)[0]))
+ res_move = cr.fetchall()
+
+ res = res_invoice + res_move
+
if len(res):
result = [('id', 'in', [x[0] for x in res])]
return result
=== modified file 'account_payment_extension/wizard/account_payment_order.py'
--- account_payment_extension/wizard/account_payment_order.py 2013-11-20 09:17:16 +0000
+++ account_payment_extension/wizard/account_payment_order.py 2014-01-24 08:18:27 +0000
@@ -28,6 +28,8 @@
import pooler
+import logging
+
class payment_order_create(osv.osv_memory):
@@ -101,6 +103,10 @@
domain += ['|',('date_maturity','<=',search_due_date),('date_maturity','=',False)]
line_ids = line_obj.search(cr, uid, domain, order='date_maturity', context=context)
+ logging.getLogger(__name__).error("payment_type: %r", payment.type)
+ logging.getLogger(__name__).error("payment_mode_type: %r", payment.mode.type)
+ logging.getLogger(__name__).error("Line moves: %r", len(line_ids))
+
selected_ids = []
if amount > 0.0:
# If user specified an amount, search what moves match the criteria taking into account
Follow ups