Merge lp:~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves into lp:~account-payment-team/account-payment/7.0

Proposed by Pedro Rodríguez Gil (Otherway)
Status: Needs review
Proposed branch: lp:~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves
Merge into: lp:~account-payment-team/account-payment/7.0
Diff against target: 103 lines (+44/-6)
2 files modified
account_payment_extension/account_move_line.py (+35/-4)
account_payment_extension/wizard/account_payment_order.py (+9/-2)
To merge this branch: bzr merge lp:~pedro-q/account-payment/7.0-account_payment_extension-IMP-payment-order-manual-moves
Reviewer Review Type Date Requested Status
Account Payment Pending
Review via email: mp+203005@code.launchpad.net

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.

Description of the change

[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.

To post a comment you must log in.
106. By Pedro Rodríguez Gil (Otherway)

Removed logs

107. By Pedro Rodríguez Gil (Otherway)

Modified to search all payable accounts

108. By Pedro Rodríguez Gil (Otherway)

Main branch changes

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/account-payment. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

108. By Pedro Rodríguez Gil (Otherway)

Main branch changes

107. By Pedro Rodríguez Gil (Otherway)

Modified to search all payable accounts

106. By Pedro Rodríguez Gil (Otherway)

Removed logs

105. By Pedro Rodríguez Gil (Otherway)

Added functionality wich allows to add lines to a payment order related to payable accont moves wich are not linked to an invoice line but manually made by an accountant, such as human resources salaries

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_payment_extension/account_move_line.py'
2--- account_payment_extension/account_move_line.py 2013-11-10 17:00:26 +0000
3+++ account_payment_extension/account_move_line.py 2014-02-27 07:41:09 +0000
4@@ -27,7 +27,6 @@
5
6 from openerp.osv import fields, orm
7
8-
9 class account_move_line(orm.Model):
10 _inherit = 'account.move.line'
11
12@@ -144,6 +143,7 @@
13 def _payment_type_get(self, cr, uid, ids, field_name, arg, context={}):
14 result = {}
15 invoice_obj = self.pool.get('account.invoice')
16+ partner_obj = self.pool.get('res.partner')
17 for move_line in self.browse(cr, uid, ids, context):
18 result[move_line.id] = (0, 0)
19 invoice_id = invoice_obj.search(
20@@ -155,6 +155,21 @@
21 result[move_line.id] = (inv.payment_type.id, self.pool.get(
22 'payment.type').browse(
23 cr, uid, inv.payment_type.id, context).name)
24+
25+ else:
26+ partner_id = partner_obj.search(
27+ cr, uid, [('id', '=', move_line.partner_id.id)],
28+ context=context)
29+ if partner_id:
30+ partner = partner_obj.browse(cr, uid, partner_id[0], context)
31+ if partner.payment_type_supplier:
32+ result[move_line.id] = (partner.payment_type_supplier.id, self.pool.get(
33+ 'payment.type').browse(
34+ cr, uid, partner.payment_type_supplier.id, context).name)
35+ elif partner.payment_type_customer:
36+ result[move_line.id] = (partner.payment_type_customer.id, self.pool.get(
37+ 'payment.type').browse(
38+ cr, uid, partner.payment_type_customer.id, context).name)
39 return result
40
41 def _payment_type_search(self, cr, uid, obj, name, args, context={}):
42@@ -173,13 +188,29 @@
43 ids = self.pool.get('payment.type').search(
44 cr, uid, [('name', 'ilike', value)], context=context)
45 if ids:
46+
47 cr.execute("""SELECT l.id
48 FROM
49 account_move_line l, account_invoice i
50 WHERE
51- l.move_id = i.move_id AND
52- i.payment_type in (%s)""" % (','.join(map(str, ids))))
53- res = cr.fetchall()
54+ l.move_id = i.move_id AND i.payment_type in (%s)""" % (','.join(map(str, ids))))
55+ res_invoice = cr.fetchall()
56+
57+ cr.execute("""SELECT l.id
58+ FROM
59+ account_move_line l, ir_property p
60+ WHERE
61+ l.move_id NOT IN (SELECT i.move_id FROM account_invoice i WHERE i.move_id is not NULL)
62+ AND
63+ l.partner_id = CAST(replace(p.res_id, 'res.partner,', '') AS INTEGER)
64+ AND
65+ (p.name = 'payment_type_supplier' OR p.name = 'payment_type_customer')
66+ AND
67+ p.value_reference = '%s' """ % ('payment.type,' + map(str, ids)[0]))
68+ res_move = cr.fetchall()
69+
70+ res = res_invoice + res_move
71+
72 if len(res):
73 result = [('id', 'in', [x[0] for x in res])]
74 return result
75
76=== modified file 'account_payment_extension/wizard/account_payment_order.py'
77--- account_payment_extension/wizard/account_payment_order.py 2013-11-20 09:17:16 +0000
78+++ account_payment_extension/wizard/account_payment_order.py 2014-02-27 07:41:09 +0000
79@@ -152,7 +152,14 @@
80 amount_to_pay = line.amount_to_pay
81 else:
82 amount_to_pay = -line.amount_to_pay
83-
84+
85+ ## Set move line currency. If not related to an invoice, set company`s default currency
86+ currency_id = False
87+ if(line.invoice and line.invoice.currency_id.id):
88+ currency_id = line.invoice.currency_id.id
89+ else:
90+ currency_id = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.currency_id.id
91+
92 payment_obj.create(cr, uid,{
93 'move_line_id': line.id,
94 'amount_currency': amount_to_pay,
95@@ -162,7 +169,7 @@
96 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/',
97 'communication2': data.communication2,
98 'date': date_to_pay,
99- 'currency': line.invoice and line.invoice.currency_id.id or False,
100+ 'currency': currency_id,
101 'account_id': line.account_id.id,
102 }, context=context)
103 return {'type': 'ir.actions.act_window_close'}