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
=== 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-02-27 07:41:09 +0000
@@ -27,7 +27,6 @@
2727
28from openerp.osv import fields, orm28from openerp.osv import fields, orm
2929
30
31class account_move_line(orm.Model):30class account_move_line(orm.Model):
32 _inherit = 'account.move.line'31 _inherit = 'account.move.line'
3332
@@ -144,6 +143,7 @@
144 def _payment_type_get(self, cr, uid, ids, field_name, arg, context={}):143 def _payment_type_get(self, cr, uid, ids, field_name, arg, context={}):
145 result = {}144 result = {}
146 invoice_obj = self.pool.get('account.invoice')145 invoice_obj = self.pool.get('account.invoice')
146 partner_obj = self.pool.get('res.partner')
147 for move_line in self.browse(cr, uid, ids, context):147 for move_line in self.browse(cr, uid, ids, context):
148 result[move_line.id] = (0, 0)148 result[move_line.id] = (0, 0)
149 invoice_id = invoice_obj.search(149 invoice_id = invoice_obj.search(
@@ -155,6 +155,21 @@
155 result[move_line.id] = (inv.payment_type.id, self.pool.get(155 result[move_line.id] = (inv.payment_type.id, self.pool.get(
156 'payment.type').browse(156 'payment.type').browse(
157 cr, uid, inv.payment_type.id, context).name)157 cr, uid, inv.payment_type.id, context).name)
158
159 else:
160 partner_id = partner_obj.search(
161 cr, uid, [('id', '=', move_line.partner_id.id)],
162 context=context)
163 if partner_id:
164 partner = partner_obj.browse(cr, uid, partner_id[0], context)
165 if partner.payment_type_supplier:
166 result[move_line.id] = (partner.payment_type_supplier.id, self.pool.get(
167 'payment.type').browse(
168 cr, uid, partner.payment_type_supplier.id, context).name)
169 elif partner.payment_type_customer:
170 result[move_line.id] = (partner.payment_type_customer.id, self.pool.get(
171 'payment.type').browse(
172 cr, uid, partner.payment_type_customer.id, context).name)
158 return result173 return result
159174
160 def _payment_type_search(self, cr, uid, obj, name, args, context={}):175 def _payment_type_search(self, cr, uid, obj, name, args, context={}):
@@ -173,13 +188,29 @@
173 ids = self.pool.get('payment.type').search(188 ids = self.pool.get('payment.type').search(
174 cr, uid, [('name', 'ilike', value)], context=context)189 cr, uid, [('name', 'ilike', value)], context=context)
175 if ids:190 if ids:
191
176 cr.execute("""SELECT l.id192 cr.execute("""SELECT l.id
177 FROM193 FROM
178 account_move_line l, account_invoice i194 account_move_line l, account_invoice i
179 WHERE195 WHERE
180 l.move_id = i.move_id AND196 l.move_id = i.move_id AND i.payment_type in (%s)""" % (','.join(map(str, ids))))
181 i.payment_type in (%s)""" % (','.join(map(str, ids))))197 res_invoice = cr.fetchall()
182 res = cr.fetchall()198
199 cr.execute("""SELECT l.id
200 FROM
201 account_move_line l, ir_property p
202 WHERE
203 l.move_id NOT IN (SELECT i.move_id FROM account_invoice i WHERE i.move_id is not NULL)
204 AND
205 l.partner_id = CAST(replace(p.res_id, 'res.partner,', '') AS INTEGER)
206 AND
207 (p.name = 'payment_type_supplier' OR p.name = 'payment_type_customer')
208 AND
209 p.value_reference = '%s' """ % ('payment.type,' + map(str, ids)[0]))
210 res_move = cr.fetchall()
211
212 res = res_invoice + res_move
213
183 if len(res):214 if len(res):
184 result = [('id', 'in', [x[0] for x in res])]215 result = [('id', 'in', [x[0] for x in res])]
185 return result216 return result
186217
=== 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-02-27 07:41:09 +0000
@@ -152,7 +152,14 @@
152 amount_to_pay = line.amount_to_pay152 amount_to_pay = line.amount_to_pay
153 else:153 else:
154 amount_to_pay = -line.amount_to_pay154 amount_to_pay = -line.amount_to_pay
155155
156 ## Set move line currency. If not related to an invoice, set company`s default currency
157 currency_id = False
158 if(line.invoice and line.invoice.currency_id.id):
159 currency_id = line.invoice.currency_id.id
160 else:
161 currency_id = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.currency_id.id
162
156 payment_obj.create(cr, uid,{163 payment_obj.create(cr, uid,{
157 'move_line_id': line.id,164 'move_line_id': line.id,
158 'amount_currency': amount_to_pay,165 'amount_currency': amount_to_pay,
@@ -162,7 +169,7 @@
162 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/',169 'communication': (line.ref and line.name!='/' and line.ref+'. '+line.name) or line.ref or line.name or '/',
163 'communication2': data.communication2,170 'communication2': data.communication2,
164 'date': date_to_pay,171 'date': date_to_pay,
165 'currency': line.invoice and line.invoice.currency_id.id or False,172 'currency': currency_id,
166 'account_id': line.account_id.id,173 'account_id': line.account_id.id,
167 }, context=context)174 }, context=context)
168 return {'type': 'ir.actions.act_window_close'}175 return {'type': 'ir.actions.act_window_close'}