account-payment-team team mailing list archive
-
account-payment-team team
-
Mailing list archive
-
Message #00068
lp:~santiago-pexego/account-payment/account-payment_improvments into lp:account-payment
Santi (Pexego) has proposed merging lp:~santiago-pexego/account-payment/account-payment_improvments into lp:account-payment.
Requested reviews:
Account Payment (account-payment-team)
For more details, see:
https://code.launchpad.net/~santiago-pexego/account-payment/account-payment_improvments/+merge/152631
Adds a simple button and wizard for direct payment from account_move_line payments tree view. You can now manage your payments completly from this view (not only onformation)
Redefine the _invoice function for account_move_line so it can search for the related invoce if you have several chained payments.
Propose a change for fields_view get in accont_move_line in account_payment_extension
--
https://code.launchpad.net/~santiago-pexego/account-payment/account-payment_improvments/+merge/152631
Your team Account Payment is requested to review the proposed merge of lp:~santiago-pexego/account-payment/account-payment_improvments into lp:account-payment.
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2013-03-11 09:40:37 +0000
@@ -0,0 +1,1 @@
+*.orig
=== modified file 'account_payment_extension/__openerp__.py'
--- account_payment_extension/__openerp__.py 2012-11-01 21:49:33 +0000
+++ account_payment_extension/__openerp__.py 2013-03-11 09:40:37 +0000
@@ -52,10 +52,12 @@
"init_xml" : [],
"demo_xml" : [],
"update_xml" : [
+ "payment_wizard.xml",
"security/ir.model.access.csv",
"wizard/account_payment_order_view.xml",
"payment_view.xml",
"payment_sequence.xml",
+ "wizard/account_move_line_payment_view.xml",
],
"active": False,
"installable": True,
=== modified file 'account_payment_extension/account_move_line.py'
--- account_payment_extension/account_move_line.py 2012-11-01 21:49:33 +0000
+++ account_payment_extension/account_move_line.py 2013-03-11 09:40:37 +0000
@@ -25,13 +25,57 @@
import netsvc
from osv import fields, osv
+from tools.translate import _
class account_move_line(osv.osv):
_name = 'account.move.line'
_inherit = 'account.move.line'
- def _invoice(self, cr, uid, ids, name, arg, context=None):
- return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
+ def _invoice(self, cursor, user, ids, name, arg, context=None):
+ invoice_obj = self.pool.get('account.invoice')
+ res = {}
+ for line_id in ids:
+ res[line_id] = False
+ cursor.execute('SELECT l.id, i.id ' \
+ 'FROM account_move_line l, account_invoice i ' \
+ 'WHERE l.move_id = i.move_id ' \
+ 'AND l.id IN %s',
+ (tuple(ids),))
+ invoice_ids = []
+
+
+ for line_id, invoice_id in cursor.fetchall():
+ res[line_id] = invoice_id
+ invoice_ids.append(invoice_id)
+ invoice_names = {False: ''}
+ for invoice_id, name in invoice_obj.name_get(cursor, user, invoice_ids, context=context):
+ invoice_names[invoice_id] = name
+ for line_id in res.keys():
+ invoice_id = res[line_id]
+ res[line_id] = (invoice_id, invoice_names[invoice_id])
+
+ for key in res.keys():
+ if res[key][0] == False:
+ # if there is no a direct invoice related
+ move_line_obj = self.pool.get('account.move.line')
+ line1 = move_line_obj.browse(cursor, user, key)
+ move = self.pool.get('account.move').browse (cursor, user, line1.move_id.id)
+
+ if move:
+ for line_in in move.line_id:
+ if line_in.id <> key and (line_in.reconcile_id or line_in.reconcile_partial_id):
+ for line_in2 in line_in.reconcile_id.line_id:
+ if line_in2.id <> line_in.id:
+ dict = self._invoice (cursor, user, [line_in2.id], name, arg, context)
+ for item in dict.keys():
+ res[key] = dict[item]
+
+ return res
+
+ #===========================================================================
+ # def _invoice(self, cr, uid, ids, name, arg, context=None):
+ # return super(account_move_line, self)._invoice(cr, uid, ids, name, arg, context)
+ #===========================================================================
def _invoice_search(self, cr, uid, obj, name, args, context={}):
""" Redefinition for searching account move lines without any invoice related ('invoice.id','=',False)"""
@@ -160,7 +204,7 @@
type='many2one', relation='account.invoice', fnct_search=_invoice_search),
'received_check': fields.boolean('Received check', help="To write down that a check in paper support has been received, for example."),
'partner_bank_id': fields.many2one('res.partner.bank','Bank Account'),
- 'amount_to_pay' : fields.function(amount_to_pay, method=True, type='float', string='Amount to pay', fnct_search=_to_pay_search),
+ 'amount_to_pay' : fields.function(amount_to_pay, method=True, type='float', string='Amount to pay', fnct_search=_to_pay_search, store=True),
'payment_type': fields.function(_payment_type_get, fnct_search=_payment_type_search, method=True, type="many2one", relation="payment.type", string="Payment type"),
}
@@ -173,20 +217,92 @@
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False):
menus = [
self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_payment_extension', 'menu_action_invoice_payments'),
- self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_payment_extension', 'menu_action_done_payments'),
- ]
+ #self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_payment_extension', 'menu_action_done_payments'),
+ ]
+ views = [
+ self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_payment_extension', 'view_payments_tree'),
+
+ ]
+
menus = [m[1] for m in menus]
- if 'active_id' in context and context['active_id'] in menus:
- # Use standard views for account.move.line object
- if view_type == 'search':
- # Get a specific search view (bug in 6.0RC1, it does not give the search view defined in the action window)
- view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_payment_extension', 'view_payments_filter')[1]
+ views = [v[1] for v in views]
+ #=======================================================================
+ # if 'active_id' in context and context['active_id'] in menus:
+ # # Use standard views for account.move.line object
+ # if view_type == 'search':
+ # # Get a specific search view (bug in 6.0RC1, it does not give the search view defined in the action window)
+ # view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_payment_extension', 'view_payments_filter')[1]
+ # result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
+ # else:
+ # # Use special views for account.move.line object (for ex. tree view contains user defined fields)
+ # result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
+ #=======================================================================
+ if view_id in views:
result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
else:
- # Use special views for account.move.line object (for ex. tree view contains user defined fields)
result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
+
return result
-
+
+ def pay_move_lines(self, cr, uid, ids, context=None):
+
+ #obj_move = self.pool.get('account.move')
+ amount = 0
+ name = ''
+ ttype = ''
+ invoice_type = ''
+ partner_id = False
+ inv_id = False
+ several_invoices = False
+ if context is None:
+ context = {}
+ data_line = self.browse(cr, uid,ids, context)
+ for line in data_line:
+ #move_ids.append(line.move_id.id)
+ if not inv_id:
+ inv_id = line.invoice.id
+ if inv_id and (line.invoice.id <> inv_id):
+ several_invoices = True
+ if partner_id and (line.partner_id.id <> partner_id):
+ raise osv.except_osv(_('Warning'), _('The pay entries have to be for the same partner!!!'))
+ else :
+ amount += line.amount_to_pay
+ partner_id = line.partner_id.id
+ name += line.name + '/'
+ if several_invoices:
+ inv_id = False
+ if amount > 0:
+ ttype = 'payment'
+ invoice_type = 'in_invoice'
+ else:
+ amount = -amount
+ ttype = 'receipt'
+ invoice_type = 'out_invoice'
+
+ print amount
+
+ return {
+ 'name':_("Pay Moves"),
+ 'view_mode': 'form',
+ 'view_id': False,
+ 'view_type': 'form',
+ 'res_model': 'account.voucher',
+ 'type': 'ir.actions.act_window',
+ 'nodestroy': True,
+ 'target': 'current',
+ 'domain': '[]',
+ 'context': {
+ 'default_partner_id': partner_id,
+ 'default_amount': amount,
+ 'default_name': name,
+ 'close_after_process': True,
+ 'invoice_type': invoice_type,
+ 'invoice_id':inv_id,
+ 'default_type': ttype ,
+ 'type': ttype ,
+ 'move_line_ids': ids
+ }
+ }
account_move_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'account_payment_extension/payment_view.xml'
--- account_payment_extension/payment_view.xml 2012-12-31 10:14:41 +0000
+++ account_payment_extension/payment_view.xml 2013-03-11 09:40:37 +0000
@@ -2,6 +2,9 @@
<openerp>
<data>
+
+
+
<!--
========================================================================================================
PARTNERS - default bank
@@ -190,6 +193,7 @@
</field>
</record>
+
<!--************ account.move.line extension to show additional fields **********-->
<!--
<record model="ir.ui.view" id="payments_move_line_tree">
@@ -313,6 +317,8 @@
</record>
+
+
<!--
====================================================================================================
PAYABLE PAYMENT ORDER
@@ -346,7 +352,7 @@
=========================================================================================
PAYMENTS
=========================================================================================
-
+ -->
<record id="view_payments_tree" model="ir.ui.view">
<field name="name">Payments</field>
<field name="model">account.move.line</field>
@@ -369,6 +375,9 @@
<field name="move_id" readonly="1"/>
<field name="reconcile_id" readonly="1"/>
<field name="reconcile_partial_id" readonly="1"/>
+ <field name="journal_id" invisible="1"/>
+ <field name="period_id" invisible="1"/>
+ <button name="pay_move_lines" type="object" string="Payment" icon="gtk-go-forward"/>
</tree>
</field>
</record>
@@ -394,8 +403,8 @@
<field name="payment_type" widget="selection"/>
<field name="partner_bank_id"/>
<field name="received_check"/>
- </group>
- <newline/>
+ </group>
+ <newline/>
<group expand="0" string="Group By...">
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
@@ -403,12 +412,14 @@
<separator orientation="vertical"/>
<filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id'}"/>
<filter string="Effective date" icon="terp-go-month" domain="[]" context="{'group_by':'date_maturity'}"/>
+ <filter string="Due Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_maturity'}"/>
+
</group>
</search>
</field>
</record>
- -->
- <!-- Invoice Payments
+
+ <!--Invoice Payments-->
<record model="ir.actions.act_window" id="action_invoice_payments">
<field name="name">Invoice payments</field>
<field name="res_model">account.move.line</field>
@@ -418,7 +429,7 @@
<field name="domain">[('account_id.type','in',['receivable','payable']),('invoice','<>',False)]</field>
</record>
<menuitem name="Invoice payments" parent="account_payment.menu_main_payment" action="action_invoice_payments" id="menu_action_invoice_payments" sequence="4"/>
- -->
+
<!-- Done Payments
<record model="ir.actions.act_window" id="action_done_payments">
<field name="name">Done payments</field>
=== modified file 'account_payment_extension/wizard/__init__.py'
--- account_payment_extension/wizard/__init__.py 2012-11-01 21:49:33 +0000
+++ account_payment_extension/wizard/__init__.py 2013-03-11 09:40:37 +0000
@@ -24,6 +24,7 @@
##############################################################################
import account_payment_order
+import account_move_line_payment
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'account_payment_extension/wizard/account_move_line_payment.py'
--- account_payment_extension/wizard/account_move_line_payment.py 1970-01-01 00:00:00 +0000
+++ account_payment_extension/wizard/account_move_line_payment.py 2013-03-11 09:40:37 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from osv import fields, osv
+from tools.translate import _
+
+
+class account_move_line_payment(osv.osv_memory):
+ _name = "account.move.line.payment"
+ _description = "Pay Account Move Lines"
+
+ def pay_move_lines(self, cr, uid, ids, context=None):
+ obj_move_line = self.pool.get('account.move.line')
+ if context is None:
+ context = {}
+ res = obj_move_line.pay_move_lines(cr, uid, context['active_ids'], context)
+ res ['nodestroy'] =False
+ return res
+
+account_move_line_payment()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
=== added file 'account_payment_extension/wizard/account_move_line_payment_view.xml'
--- account_payment_extension/wizard/account_move_line_payment_view.xml 1970-01-01 00:00:00 +0000
+++ account_payment_extension/wizard/account_move_line_payment_view.xml 2013-03-11 09:40:37 +0000
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!--Account Move lines-->
+ <record id="pay_account_move_line_view" model="ir.ui.view">
+ <field name="name">Pay Journal Entries</field>
+ <field name="model">account.move.line.payment</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Change payment entries">
+ <separator string="Pay Journal Entries" colspan="4"/>
+ <label string="Puede cambiar el estado de los efectos comerciales mediante el siguiente asistente" colspan="4"/>
+ <separator colspan="4"/>
+ <group colspan="4" col="6">
+ <button icon="gtk-cancel" special="cancel" string="Cancel"/>
+ <button icon="terp-camera_test" string="Approve" name="pay_move_lines" type="object" default_focus="1"/>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_pay_account_move_line" model="ir.actions.act_window">
+ <field name="name">Change payment</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">account.move.line.payment</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="pay_account_move_line_view"/>
+ <field name="context">{}</field>
+ <field name="target">new</field>
+ <field name="help">with this wizard ypu can change the state of the selected entries. </field>
+ </record>
+
+ <record model="ir.values" id="account_move_line_payment_values">
+ <field name="model_id" ref="account.model_account_move_line" />
+ <field name="name">Change payment entries</field>
+ <field name="key2">client_action_multi</field>
+ <field name="value" eval="'ir.actions.act_window,' + str(ref('action_pay_account_move_line'))" />
+ <field name="key">action</field>
+ <field name="model">account.move.line</field>
+ </record>
+
+ </data>
+</openerp>
Follow ups