account-payment-team team mailing list archive
-
account-payment-team team
-
Mailing list archive
-
Message #00151
[Merge] lp:~renatonlima/account-payment/account-payment-extension-7.0 into lp:account-payment/7.0
Renato Lima - http://www.akretion.com has proposed merging lp:~renatonlima/account-payment/account-payment-extension-7.0 into lp:account-payment/7.0.
Requested reviews:
Account Payment (account-payment-team)
For more details, see:
https://code.launchpad.net/~renatonlima/account-payment/account-payment-extension-7.0/+merge/180750
Hi guys,
I'm proposing this merge to improve and organization account_payment_extension module like:
- Moved all code, objects and views inherited by others in payment.py modules to new files (res_partner.py, account_invoice.py, account_payment.py)
- Renamed bad file names (payment.py => account_payment.py, payment_view.xml => account_payment_view.xml, payment_sequence.xml => account_payment_sequence.xml)
- Updated brazilian portuguese translation (pt_BR.po)
- Refactored the code to be more compatible with PEP8 (still some parts to refactore)
- Created test folder to add test files in future
Best Regards,
Renato Lima - http://www.akretion.com
--
https://code.launchpad.net/~renatonlima/account-payment/account-payment-extension-7.0/+merge/180750
Your team Account Payment is requested to review the proposed merge of lp:~renatonlima/account-payment/account-payment-extension-7.0 into lp:account-payment/7.0.
=== modified file 'account_payment_extension/__init__.py'
--- account_payment_extension/__init__.py 2012-11-01 21:49:33 +0000
+++ account_payment_extension/__init__.py 2013-08-18 21:37:33 +0000
@@ -1,29 +1,33 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
-# Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
-# AvanzOSC, Avanzed Open Source Consulting
-# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
-# $Id$
-#
-# 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/>.
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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/>.
#
##############################################################################
-import payment
+import account_payment_extension
+import res_partner
import account_invoice
import account_move_line
+import account_payment
import wizard
=== 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-08-18 21:37:33 +0000
@@ -1,38 +1,43 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
-# Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
-# AvanzOSC, Avanzed Open Source Consulting
-# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
-# $Id$
-#
-# 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/>.
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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/>.
#
##############################################################################
{
- "name" : "Account Payment Extension",
- "version" : "1.1",
- "author" : "Zikzakmedia SL",
- "category" : "Accounting & Finance",
- "website" : "www.zikzakmedia.com",
- "license" : "AGPL-3",
- "description": """Account payment extension.
+ 'name': 'Account Payment Extension',
+ 'version': '1.1',
+ 'author': 'Zikzakmedia SL',
+ 'category': 'Accounting & Finance',
+ 'website': 'www.zikzakmedia.com',
+ 'license': 'AGPL-3',
+ 'description': """
+Account payment extension.
+==========================
This module extends the account_payment module with a lot of features:
+----------------------------------------------------------------------
* Definition of payment types (cash, bank transfer, automatical bank transfer, ...). The payment type has a translatable name and note that can be shown in the invoices.
* Two default payment types for partners (client and supplier).
* Automatic selection of payment type in invoices. Now an invoice can have a payment term (30 days, 30/60 days, ...) and a payment type (cash, bank transfer, ...).
@@ -44,19 +49,22 @@
* Payment orders: Selected invoices are filtered by payment type, the second message communication can be set at the same time for several invoices.
Based on previous work of Pablo Rocandio & Zikzakmedia (version for 4.2).
""",
- "depends" : [
- "base",
- "account",
- "account_payment",
+ 'depends': [
+ 'base',
+ 'account',
+ 'account_payment',
],
- "init_xml" : [],
- "demo_xml" : [],
- "update_xml" : [
- "security/ir.model.access.csv",
- "wizard/account_payment_order_view.xml",
- "payment_view.xml",
- "payment_sequence.xml",
- ],
- "active": False,
- "installable": True,
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'wizard/account_payment_order_view.xml',
+ 'account_payment_extension_view.xml',
+ 'account_payment_sequence.xml',
+ 'account_payment_view.xml',
+ 'account_invoice_view.xml',
+ 'res_partner_view.xml',
+ ],
+ 'demo': [],
+ 'test': [],
+ 'installable': True,
+ 'auto_install': False,
}
=== modified file 'account_payment_extension/account_invoice.py'
--- account_payment_extension/account_invoice.py 2012-12-03 08:17:51 +0000
+++ account_payment_extension/account_invoice.py 2013-08-18 21:37:33 +0000
@@ -1,61 +1,72 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
-# Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
-# AvanzOSC, Avanzed Open Source Consulting
-# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
-# $Id$
-#
-# 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/>.
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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/>.
#
##############################################################################
-import netsvc
-from osv import fields, osv
-
-class account_invoice(osv.osv):
- _inherit='account.invoice'
- _columns={
+from openerp.osv import fields, orm
+
+
+class account_invoice(orm.Model):
+ _inherit = 'account.invoice'
+ _columns = {
'payment_type': fields.many2one('payment.type', 'Payment type'),
}
- def onchange_partner_id(self, cr, uid, ids, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
- # Copy partner data to invoice, also the new field payment_type
- result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, date_invoice, payment_term, partner_bank_id, company_id)
+ def onchange_partner_id(self, cr, uid, ids, type, partner_id,
+ date_invoice=False, payment_term=False,
+ partner_bank_id=False, company_id=False):
+
+ result = super(account_invoice, self).onchange_partner_id(
+ cr, uid, ids, type, partner_id, date_invoice, payment_term,
+ partner_bank_id, company_id)
payment_type = False
if partner_id:
- partner_line = self.pool.get('res.partner').browse(cr, uid, partner_id)
- if partner_line:
- if type=='in_invoice' or type=='in_refund':
- payment_type = partner_line.payment_type_supplier.id
- else:
- payment_type = partner_line.payment_type_customer.id
- if payment_type:
- result['value']['payment_type'] = payment_type
- return self.onchange_payment_type(cr, uid, ids, payment_type, partner_id, result)
+ partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
+ if type in ('in_invoice', 'in_refund'):
+ payment_type = partner.payment_type_supplier.id
+ else:
+ payment_type = partner.payment_type_customer.id
+ result['value']['payment_type'] = payment_type
+ return self.onchange_payment_type(
+ cr, uid, ids, payment_type, partner_id, result)
- def onchange_payment_type(self, cr, uid, ids, payment_type, partner_id, result = None):
- if result is None:
+ def onchange_payment_type(self, cr, uid, ids, payment_type,
+ partner_id, result=None):
+ if not result:
result = {'value': {}}
+
if payment_type and partner_id:
- bank_types = self.pool.get('payment.type').browse(cr, uid, payment_type).suitable_bank_types
- if bank_types: # If the payment type is related with a bank account
+ bank_types = self.pool.get('payment.type').browse(
+ cr, uid, payment_type).suitable_bank_types
+ # If the payment type is related with a bank account
+ if bank_types:
bank_types = [bt.code for bt in bank_types]
partner_bank_obj = self.pool.get('res.partner.bank')
- args = [('partner_id', '=', partner_id), ('default_bank', '=', 1), ('state', 'in', bank_types)]
+ args = [('partner_id', '=', partner_id),
+ ('default_bank', '=', 1),
+ ('state', 'in', bank_types)]
bank_account_id = partner_bank_obj.search(cr, uid, args)
if bank_account_id:
result['value']['partner_bank_id'] = bank_account_id[0]
@@ -63,17 +74,20 @@
result['value']['partner_bank_id'] = False
return result
- def action_move_create(self, cr, uid, ids, *args):
- ret = super(account_invoice, self).action_move_create(cr, uid, ids, *args)
- if ret:
- for inv in self.browse(cr, uid, ids):
+ def action_move_create(self, cr, uid, ids, context=None):
+ result = super(account_invoice, self).action_move_create(
+ cr, uid, ids, context)
+ if result:
+ for inv in self.browse(cr, uid, ids, context):
move_line_ids = []
for move_line in inv.move_id.line_id:
- if (move_line.account_id.type == 'receivable' or move_line.account_id.type == 'payable') and move_line.state != 'reconciled' and not move_line.reconcile_id.id:
+ if (move_line.account_id.type == 'receivable' or
+ move_line.account_id.type == 'payable') and \
+ move_line.state != 'reconciled' and \
+ not move_line.reconcile_id.id:
move_line_ids.append(move_line.id)
if len(move_line_ids) and inv.partner_bank_id:
aml_obj = self.pool.get("account.move.line")
- aml_obj.write(cr, uid, move_line_ids, {'partner_bank_id': inv.partner_bank_id.id})
- return ret
-
-account_invoice()
+ aml_obj.write(cr, uid, move_line_ids,
+ {'partner_bank_id': inv.partner_bank_id.id})
+ return result
=== added file 'account_payment_extension/account_invoice_view.xml'
--- account_payment_extension/account_invoice_view.xml 1970-01-01 00:00:00 +0000
+++ account_payment_extension/account_invoice_view.xml 2013-08-18 21:37:33 +0000
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record model="ir.ui.view" id="invoice_form3">
+ <field name="name">account.invoice.form3.payment_type</field>
+ <field name="model">account.invoice</field>
+ <field name="inherit_id" ref="account.invoice_form"/>
+ <field name="arch" type="xml">
+ <field name="partner_bank_id" position="replace">
+ <field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
+ </field>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="invoice_form4">
+ <field name="name">account.invoice.form4.payment_type</field>
+ <field name="model">account.invoice</field>
+ <field name="inherit_id" ref="account.invoice_form"/>
+ <field name="arch" type="xml">
+ <field name="fiscal_position" position="after">
+ <field domain="[('company_id', '=', company_id)]" name="payment_type" on_change="onchange_payment_type(payment_type, partner_id)" />
+ </field>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="invoice_supplier_form2">
+ <field name="name">account.invoice.supplier.form2</field>
+ <field name="model">account.invoice</field>
+ <field name="inherit_id" ref="account.invoice_supplier_form"/>
+ <field name="arch" type="xml">
+ <field name="fiscal_position" position="after">
+ <field domain="[('company_id', '=', company_id)]" name="payment_type" on_change="onchange_payment_type(payment_type, partner_id)" />
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
\ No newline at end of file
=== modified file 'account_payment_extension/account_move_line.py' (properties changed: +x to -x)
--- account_payment_extension/account_move_line.py 2013-01-02 17:48:45 +0000
+++ account_payment_extension/account_move_line.py 2013-08-18 21:37:33 +0000
@@ -1,91 +1,76 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
-# Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
-# AvanzOSC, Avanzed Open Source Consulting
-# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
-# $Id$
-#
-# 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/>.
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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/>.
#
##############################################################################
-import netsvc
-from osv import fields, osv
-
-class account_move_line(osv.osv):
- _name = 'account.move.line'
+from openerp.osv import fields, orm
+
+
+class account_move_line(orm.Model):
_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_search(self, cr, uid, obj, name, args, context={}):
- """ Redefinition for searching account move lines without any invoice related ('invoice.id','=',False)"""
- for x in args:
- if (x[2] is False) and (x[1] == '=') and (x[0] == 'invoice'):
- cr.execute('SELECT l.id FROM account_move_line l ' \
- 'LEFT JOIN account_invoice i ON l.move_id = i.move_id ' \
- 'WHERE i.id IS NULL', [])
- res = cr.fetchall()
- if not len(res):
- return [('id', '=', '0')]
- return [('id', 'in', [x[0] for x in res])]
- return super(account_move_line, self)._invoice_search(cr, uid, obj, name, args, context=context)
-
def amount_to_pay(self, cr, uid, ids, name, arg={}, context={}):
"""
- Return amount pending to be paid taking into account payment lines and the reconciliation.
- Note that the amount to pay can be due to negative supplier refund invoices or customer invoices.
+ Return amount pending to be paid taking into account payment
+ lines and the reconciliation. Note that the amount to pay can be
+ due to negative supplier refund invoices or customer invoices.
"""
-
if not ids:
return {}
cr.execute("""SELECT ml.id,
- CASE WHEN ml.amount_currency < 0
- THEN - ml.amount_currency
- WHEN ml.amount_currency > 0
- THEN ml.amount_currency
- ELSE ml.credit - ml.debit
- END AS debt,
- (SELECT coalesce(sum(CASE WHEN pl.type='receivable' THEN -amount_currency ELSE amount_currency END),0)
- FROM payment_line pl
- INNER JOIN payment_order po
- ON (pl.order_id = po.id)
- WHERE
- pl.move_line_id = ml.id AND
- pl.payment_move_id IS NULL AND
- po.state != 'cancel'
- ) AS paid,
- (
- SELECT
- COALESCE( SUM(COALESCE(amrl.credit,0) - COALESCE(amrl.debit,0)), 0 )
- FROM
- account_move_reconcile amr,
- account_move_line amrl
- WHERE
- amr.id = amrl.reconcile_partial_id AND
- amr.id = ml.reconcile_partial_id
- ) AS unreconciled,
- reconcile_id
- FROM account_move_line ml
- WHERE id in (%s)""" % (",".join([str(int(x)) for x in ids])))
+ CASE WHEN ml.amount_currency < 0
+ THEN - ml.amount_currency
+ WHEN ml.amount_currency > 0
+ THEN ml.amount_currency
+ ELSE ml.credit - ml.debit
+ END AS debt,
+ (SELECT coalesce(sum(CASE WHEN pl.type='receivable' THEN -amount_currency ELSE amount_currency END),0)
+ FROM payment_line pl
+ INNER JOIN payment_order po
+ ON (pl.order_id = po.id)
+ WHERE
+ pl.move_line_id = ml.id AND
+ pl.payment_move_id IS NULL AND
+ po.state != 'cancel'
+ ) AS paid,
+ (
+ SELECT
+ COALESCE( SUM(COALESCE(amrl.credit,0) - COALESCE(amrl.debit,0)), 0 )
+ FROM
+ account_move_reconcile amr,
+ account_move_line amrl
+ WHERE
+ amr.id = amrl.reconcile_partial_id AND
+ amr.id = ml.reconcile_partial_id
+ ) AS unreconciled,
+ reconcile_id
+ FROM account_move_line ml
+ WHERE id in (%s)""" % (",".join([str(int(x)) for x in ids])))
result = {}
for record in cr.fetchall():
- id = record[0]
+ move_id = record[0]
debt = record[1] or 0.0
paid = record[2]
unreconciled = record[3]
@@ -99,101 +84,92 @@
debt = min(debt - paid, max(0.0, unreconciled))
else:
debt = max(debt - paid, min(0.0, unreconciled))
- result[id] = debt
+ result[move_id] = debt
return result
def _to_pay_search(self, cr, uid, obj, name, args, context={}):
if not len(args):
return []
- currency = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.currency_id
+ currency = self.pool.get('res.users').browse(
+ cr, uid, uid, context).company_id.currency_id
- # For searching we first discard reconciled moves because the filter is fast and discards most records
- # quickly.
- ids = self.pool.get('account.move.line').search(cr, uid, [('reconcile_id','=',False)], context=context)
- records = self.pool.get('account.move.line').read(cr, uid, ids, ['id', 'amount_to_pay'], context)
+ # For searching we first discard reconciled moves
+ # because the filter is fast and discards most records quickly.
+ ids = self.pool.get('account.move.line').search(
+ cr, uid, [('reconcile_id', '=', False)], context=context)
+ records = self.pool.get('account.move.line').read(
+ cr, uid, ids, ['id', 'amount_to_pay'], context)
ids = []
for record in records:
- if not self.pool.get('res.currency').is_zero( cr, uid, currency, record['amount_to_pay'] ):
- ids.append( record['id'] )
+ if not self.pool.get('res.currency').is_zero(
+ cr, uid, currency, record['amount_to_pay']):
+ ids.append(record['id'])
if not ids:
- return [('id','=',False)]
- return [('id','in',ids)]
+ return [('id', '=', False)]
+ return [('id', 'in', ids)]
def _payment_type_get(self, cr, uid, ids, field_name, arg, context={}):
result = {}
invoice_obj = self.pool.get('account.invoice')
- for rec in self.browse(cr, uid, ids, context):
- result[rec.id] = (0,0)
- invoice_id = invoice_obj.search(cr, uid, [('move_id', '=', rec.move_id.id)], context=context)
+ for move_line in self.browse(cr, uid, ids, context):
+ result[move_line.id] = (0, 0)
+ invoice_id = invoice_obj.search(
+ cr, uid, [('move_id', '=', move_line.move_id.id)],
+ context=context)
if invoice_id:
inv = invoice_obj.browse(cr, uid, invoice_id[0], context)
if inv.payment_type:
- result[rec.id] = (inv.payment_type.id, self.pool.get('payment.type').browse(cr, uid, inv.payment_type.id, context).name)
- else:
- result[rec.id] = (0,0)
+ result[move_line.id] = (inv.payment_type.id, self.pool.get(
+ 'payment.type').browse(
+ cr, uid, inv.payment_type.id, context).name)
return result
def _payment_type_search(self, cr, uid, obj, name, args, context={}):
+ result = [('id', '=', '0')]
if not len(args):
- return []
- operator = args[0][1]
+ return result
+# operator = args[0][1]
value = args[0][2]
if not value:
return []
if isinstance(value, int) or isinstance(value, long):
ids = [value]
elif isinstance(value, list):
- ids = value
+ ids = value
else:
- ids = self.pool.get('payment.type').search(cr,uid,[('name','ilike',value)], context=context)
+ 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))))
+ 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()
if len(res):
- return [('id', 'in', [x[0] for x in res])]
- return [('id','=','0')]
+ result = [('id', 'in', [x[0] for x in res])]
+ return result
_columns = {
- 'invoice': fields.function(_invoice, method=True, string='Invoice',
- 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),
- 'payment_type': fields.function(_payment_type_get, fnct_search=_payment_type_search, method=True, type="many2one", relation="payment.type", string="Payment type"),
+ '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),
+ 'payment_type': fields.function(_payment_type_get,
+ type="many2one", relation="payment.type", method=True,
+ string="Payment type", fnct_search=_payment_type_search),
}
- def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
- for key in vals.keys():
- if key not in ['received_check', 'partner_bank_id', 'date_maturity']:
- return super(account_move_line, self).write(cr, uid, ids, vals, context, check, update_check)
- return super(account_move_line, self).write(cr, uid, ids, vals, context, check, update_check=False)
-
-
-#the search filter view system changed in v7: you can now search by any field and there is no more select in widget, so further work would be
-# required to port the following logic to v7.
-#
-# In the meantime, as the feature loss isn't that huge and as workarounds are possible we simply commented the following code out.
-
-# 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'),
-# ]
-#
-# menus = [m[1] for m in menus]
-# if 1==1: # '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)
-# return result
-
-account_move_line()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ def write(self, cr, uid, ids, vals, context=None,
+ check=True, update_check=True):
+ for key in list(vals.keys()):
+ if key not in ('received_check', 'partner_bank_id',
+ 'date_maturity'):
+ return super(account_move_line, self).write(
+ cr, uid, ids, vals, context, check, update_check)
+ return super(account_move_line, self).write(
+ cr, uid, ids, vals, context, check, update_check=False)
=== renamed file 'account_payment_extension/payment.py' => 'account_payment_extension/account_payment.py'
--- account_payment_extension/payment.py 2013-05-17 13:28:00 +0000
+++ account_payment_extension/account_payment.py 2013-08-18 21:37:33 +0000
@@ -1,108 +1,81 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
-# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
-# Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
-# AvanzOSC, Avanzed Open Source Consulting
-# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
-# $Id$
-#
-# 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/>.
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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/>.
#
##############################################################################
-import time
-import netsvc
-from osv import fields, osv
-from tools.translate import _
-import decimal_precision as dp
-
-class payment_type(osv.osv):
- _name= 'payment.type'
- _description= 'Payment type'
- _columns= {
- 'name': fields.char('Name', size=64, required=True, help='Payment Type', translate=True),
- 'code': fields.char('Code', size=64, required=True, help='Specify the Code for Payment Type'),
- 'suitable_bank_types': fields.many2many('res.partner.bank.type','bank_type_payment_type_rel','pay_type_id','bank_type_id','Suitable bank types'),
+from openerp.osv import fields, orm
+from openerp.tools.translate import _
+
+
+class payment_type(orm.Model):
+ _name = 'payment.type'
+ _description = 'Payment type'
+ _columns = {
+ 'name': fields.char('Name', size=64, required=True,
+ help='Payment Type', translate=True),
+ 'code': fields.char('Code', size=64, required=True,
+ help='Specify the Code for Payment Type'),
+ 'suitable_bank_types': fields.many2many(
+ 'res.partner.bank.type', 'bank_type_payment_type_rel',
+ 'pay_type_id', 'bank_type_id', 'Suitable bank types'),
'active': fields.boolean('Active', select=True),
- 'note': fields.text('Description', translate=True, help="Description of the payment type that will be shown in the invoices"),
+ 'note': fields.text('Description', translate=True,
+ help="""Description of the payment type that will be shown in
+ the invoices"""),
'company_id': fields.many2one('res.company', 'Company', required=True),
}
-
_defaults = {
- 'active': lambda *a: 1,
- 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id
+ 'active': True,
+ 'company_id': lambda self, cr, uid, c: self.pool.get(
+ 'res.users').browse(cr, uid, uid, c).company_id.id
}
-payment_type()
-
-
-class payment_mode(osv.osv):
+
+class payment_mode(orm.Model):
_inherit = 'payment.mode'
_columns = {
- 'type': fields.many2one('payment.type', 'Payment type', required=True, help='Select the Payment Type for the Payment Mode.'),
- 'require_bank_account': fields.boolean('Require Bank Account', help='Ensure all lines in the payment order have a bank account when proposing lines to be added in the payment order.'),
- 'require_received_check': fields.boolean('Require Received Check', help='Ensure all lines in the payment order have the Received Check flag set.'),
- 'require_same_bank_account': fields.boolean('Require the Same Bank Account', help='Ensure all lines in the payment order and the payment mode have the same account number.'),
+ 'type': fields.many2one('payment.type', 'Payment type', required=True,
+ help='Select the Payment Type for the Payment Mode.'),
+ 'require_bank_account': fields.boolean('Require Bank Account',
+ help="""Ensure all lines in the payment order have a bank
+ account when proposing lines to be added in the
+ payment order."""),
+ 'require_received_check': fields.boolean('Require Received Check',
+ help="""Ensure all lines in the payment order have the
+ Received Check flag set."""),
+ 'require_same_bank_account': fields.boolean(
+ 'Require the Same Bank Account', help="""Ensure all lines in the
+ payment order and the payment mode have the same
+ account number."""),
}
_defaults = {
- 'require_bank_account': lambda *a: False,
- }
-payment_mode()
-
-
-class res_partner(osv.osv):
- _inherit='res.partner'
- _columns={
- 'payment_type_customer': fields.property('payment.type', type='many2one', relation='payment.type', string ='Customer Payment Type', method=True, view_load=True, help="Payment type of the customer"),
- 'payment_type_supplier': fields.property('payment.type', type='many2one', relation='payment.type', string ='Supplier Payment Type', method=True, view_load=True, help="Payment type of the supplier"),
- }
-res_partner()
-
-
-class res_partner_bank(osv.osv):
- _inherit="res.partner.bank"
-
- def create(self, cr, uid, vals, context=None):
- if vals.get('default_bank') and vals.get('partner_id') and vals.get('state'):
- sql = "UPDATE res_partner_bank SET default_bank='0' WHERE partner_id=%i AND default_bank='1' AND state='%s'" % (vals['partner_id'], vals['state'])
- cr.execute(sql)
- return super(res_partner_bank, self).create(cr, uid, vals, context=context)
-
- def write(self, cr, uid, ids, vals, context=None):
- if 'default_bank' in vals and vals['default_bank'] == True:
- partner_bank = self.pool.get('res.partner.bank').browse(cr, uid, ids)[0]
- partner_id = partner_bank.partner_id.id
- if 'state' in vals and vals['state']:
- state = vals['state']
- else:
- state = partner_bank.state
- sql = "UPDATE res_partner_bank SET default_bank='0' WHERE partner_id=%i AND default_bank='1' AND state='%s' AND id<>%i" % (partner_id, state, ids[0])
- cr.execute(sql)
- return super(res_partner_bank, self).write(cr, uid, ids, vals, context=context)
-
-
- _columns = {
- 'default_bank' : fields.boolean('Default'),
- }
-
-res_partner_bank()
-
-
-class payment_order(osv.osv):
- _name = 'payment.order'
+ 'require_bank_account': False,
+ }
+
+
+class payment_order(orm.Model):
_inherit = 'payment.order'
def _get_type(self, cr, uid, context=None):
@@ -113,24 +86,27 @@
def _get_reference(self, cr, uid, context=None):
if context is None:
context = {}
- type = context.get('type', 'payable')
- model = type == 'payable' and 'payment.order' or 'rec.payment.order'
+ PAYMENT_MODEL = {
+ 'payable': 'payment.order', 'receivable': 'rec.payment.order'}
+ model = PAYMENT_MODEL.get(context.get('type', 'payable'))
return self.pool.get('ir.sequence').get(cr, uid, model)
def _get_period(self, cr, uid, context=None):
try:
- # find() function will throw an exception if no period can be found for
- # current date. That should not be a problem because user would be notified
- # but as this model inherits an existing one, once installed it will create
- # the new field and try to update existing records (even if there are no records yet)
- # So we must ensure no exception is thrown, otherwise the module can only be installed
- # once periods are created.
+ # find() function will throw an exception if no period can be
+ # found for current date. That should not be a problem because
+ # user would be notified but as this model inherits an existing
+ # one, once installed it will create the new field and try to
+ # update existing records (even if there are no records yet)
+ # So we must ensure no exception is thrown, otherwise the
+ # module can only be installed once periods are created.
periods = self.pool.get('account.period').find(cr, uid)
return periods[0]
- except Exception, e:
+ except Exception:
return False
- def _payment_type_name_get(self, cr, uid, ids, field_name, arg, context=None):
+ def _payment_type_name_get(self, cr, uid, ids, field_name,
+ arg, context=None):
result = {}
for rec in self.browse(cr, uid, ids, context):
result[rec.id] = rec.mode and rec.mode.type.name or ""
@@ -144,21 +120,28 @@
_columns = {
'type': fields.selection([
- ('payable','Payable'),
- ('receivable','Receivable'),
- ],'Type', readonly=True, select=True),
+ ('payable', 'Payable'),
+ ('receivable', 'Receivable'),
+ ], 'Type', readonly=True, select=True),
# invisible field to filter payment order lines by payment type
- 'payment_type_name': fields.function(_payment_type_name_get, method=True, type="char", size=64, string="Payment type name"),
- # The field name is necessary to add attachement documents to payment orders
- 'name': fields.function(_name_get, method=True, type="char", size=64, string="Name"),
- 'create_account_moves': fields.selection([('bank-statement','Bank Statement'),('direct-payment','Direct Payment')],
- 'Create Account Moves',
- required=True,
- states={'done':[('readonly',True)]},
- help='Indicates when account moves should be created for order payment lines. "Bank Statement" '\
- 'will wait until user introduces those payments in bank a bank statement. "Direct Payment" '\
- 'will mark all payment lines as payied once the order is done.'),
- 'period_id': fields.many2one('account.period', 'Period', states={'done':[('readonly',True)]}),
+ 'payment_type_name': fields.function(
+ _payment_type_name_get, method=True, type="char", size=64,
+ string="Payment type name"),
+ # The field name is necessary to add attachement documents to
+ # payment orders
+ 'name': fields.function(
+ _name_get, method=True, type="char", size=64, string="Name"),
+ 'create_account_moves': fields.selection(
+ [('bank-statement', 'Bank Statement'),
+ ('direct-payment', 'Direct Payment')], 'Create Account Moves',
+ required=True, states={'done': [('readonly', True)]},
+ help="""Indicates when account moves should be created for
+ order payment lines. 'Bank Statement' will wait until user
+ introduces those payments in bank a bank statement.
+ 'Direct Payment' will mark all payment lines as payied once
+ the order is done."""),
+ 'period_id': fields.many2one('account.period', 'Period',
+ states={'done': [('readonly', True)]}),
}
_defaults = {
'type': _get_type,
@@ -168,22 +151,21 @@
}
def cancel_from_done(self, cr, uid, ids, context=None):
- if context is None:
+ if not context:
context = {}
#Search for account_moves
remove = []
- for move in self.browse(cr,uid,ids,context):
+ for move in self.browse(cr, uid, ids, context=context):
#Search for any line
- for line in move.line_ids:
- if line.payment_move_id:
- remove += [ line.payment_move_id.id ]
-
- self.pool.get('account.move').button_cancel( cr, uid, remove, context=context)
+ for move_line in move.line_ids:
+ if move_line.payment_move_id:
+ remove.append(move_line.payment_move_id.id)
+
+ self.pool.get('account.move').button_cancel(
+ cr, uid, remove, context=context)
self.pool.get('account.move').unlink(cr, uid, remove, context)
- self.write( cr, uid, ids, {
- 'state':'cancel'
- },context=context)
+ self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
return True
def unlink(self, cr, uid, ids, context=None):
@@ -193,8 +175,12 @@
if t['state'] in ('draft', 'cancel'):
unlink_ids.append(t['id'])
else:
- raise osv.except_osv(_('Invalid action!'), _('You cannot delete payment order(s) which are already confirmed or done!'))
- result = super(payment_order, self).unlink(cr, uid, unlink_ids, context=context)
+ raise orm.except_orm(
+ _('Invalid action!'),
+ _("""You cannot delete payment order(s) which are
+ already confirmed or done!"""))
+ result = super(payment_order, self).unlink(
+ cr, uid, unlink_ids, context=context)
return result
def set_done(self, cr, uid, ids, context=None):
@@ -212,21 +198,27 @@
if order.create_account_moves != 'direct-payment':
continue
- # This process creates a simple account move with bank and line accounts and line's amount. At the end
- # it will reconcile or partial reconcile both entries if that is possible.
-
- move_id = move_obj.create(cr, uid, {
+ # This process creates a simple account move with
+ # bank and line accounts and line's amount. At the end
+ # it will reconcile or partial reconcile both entries
+ # if that is possible.
+ move_id = self.pool.get('account.move').create(cr, uid, {
'name': '/',
'journal_id': order.mode.journal.id,
'period_id': order.period_id.id,
}, context)
-
+
for line in order.line_ids:
if not line.amount:
continue
if not line.account_id:
- raise osv.except_osv(_('Error!'), _('Payment order should create account moves but line with amount %.2f for partner "%s" has no account assigned.') % (line.amount, line.partner_id.name ) )
+ raise orm.except_orm(
+ _('Error!'),
+ _("""Payment order should create account moves
+ but line with amount %.2f for partner "%s" has
+ no account assigned.""") %
+ (line.amount, line.partner_id.name))
currency_id = order.mode.journal.currency and order.mode.journal.currency.id or company_currency_id
@@ -234,12 +226,12 @@
line_amount = line.amount_currency or line.amount
else:
line_amount = -line.amount_currency or -line.amount
-
+
if line_amount >= 0:
account_id = order.mode.journal.default_credit_account_id.id
else:
account_id = order.mode.journal.default_debit_account_id.id
- acc_cur = ((line_amount<=0) and order.mode.journal.default_debit_account_id) or line.account_id
+ acc_cur = ((line_amount <= 0) and order.mode.journal.default_debit_account_id) or line.account_id
ctx = context.copy()
ctx['res.currency.compute.account'] = acc_cur
@@ -252,14 +244,14 @@
'ref': line.move_line_id and line.move_line_id.ref or False,
'partner_id': line.partner_id and line.partner_id.id or False,
'account_id': line.account_id.id,
- 'debit': ((amount>0) and amount) or 0.0,
- 'credit': ((amount<0) and -amount) or 0.0,
+ 'debit': ((amount > 0) and amount) or 0.0,
+ 'credit': ((amount < 0) and - amount) or 0.0,
'journal_id': order.mode.journal.id,
'period_id': order.period_id.id,
'currency_id': currency_id,
'state': 'valid',
}
-
+
if currency_id <> company_currency_id:
amount_cur = currency_obj.compute(cr, uid, company_currency_id, currency_id, amount, context=ctx)
val['amount_currency'] = -amount_cur
@@ -313,7 +305,7 @@
amount = 0.0
for rline in move_line_obj.browse(cr, uid, lines_to_reconcile, context):
amount += rline.debit - rline.credit
-
+
if currency_obj.is_zero(cr, uid, currency, amount):
move_line_obj.reconcile(cr, uid, lines_to_reconcile, 'payment', context=context)
else:
@@ -330,15 +322,16 @@
return result
-payment_order()
-
-
-class payment_line(osv.osv):
- _name = 'payment.line'
+
+class payment_line(orm.Model):
_inherit = 'payment.line'
def _auto_init(self, cr, context=None):
- cr.execute("SELECT column_name FROM information_schema.columns WHERE table_name = 'payment_line' and column_name='type'")
+ cr.execute("""SELECT column_name
+ FROM
+ information_schema.columns
+ WHERE
+ table_name = 'payment_line' and column_name='type'""")
if cr.fetchone():
update_sign = False
else:
@@ -346,33 +339,49 @@
result = super(payment_line, self)._auto_init(cr, context=context)
if update_sign:
- # Ensure related store value of field 'type' is updated in the database.
- # Note that by forcing the update here we also ensure everything is done in the same transaction.
- # Because addons/__init__.py will execute a commit just after creating table fields.
+ # Ensure related store value of field 'type' is updated in
+ # the database.
+ # Note that by forcing the update here we also ensure
+ # everything is done in the same transaction.
+ # Because addons/__init__.py will execute a commit just
+ # after creating table fields.
result.sort()
for item in result:
item[1](cr, *item[2])
# Change sign of 'receivable' payment lines
- cr.execute("UPDATE payment_line SET amount_currency = -amount_currency WHERE type='receivable'")
+ cr.execute("""UPDATE payment_line
+ SET
+ amount_currency = -amount_currency
+ WHERE
+ type='receivable'""")
return result
_columns = {
- 'move_line_id': fields.many2one('account.move.line', 'Entry line', domain="[('reconcile_id','=', False), ('amount_to_pay','<>',0), ('account_id.type','=',parent.type),('payment_type','ilike',parent.payment_type_name or '%')]", help='This Entry Line will be referred for the information of the ordering customer.'),
- 'payment_move_id': fields.many2one('account.move', 'Payment Move', readonly=True, help='Account move that pays this debt.'),
+ 'move_line_id': fields.many2one(
+ 'account.move.line', 'Entry line',
+ domain="[('reconcile_id', '=', False), ('amount_to_pay', '!=', 0), ('account_id.type', '=', parent.type), ('payment_type', 'ilike', parent.payment_type_name or '%')]",
+ help="""This Entry Line will be referred for the information
+ of the ordering customer."""),
+ 'payment_move_id': fields.many2one(
+ 'account.move', 'Payment Move', readonly=True,
+ help='Account move that pays this debt.'),
'account_id': fields.many2one('account.account', 'Account'),
- 'type': fields.related('order_id','type', type='selection', selection=[('payable','Payable'),('receivable','Receivable')], readonly=True, store=True, string='Type'),
+ 'type': fields.related('order_id', 'type',
+ type='selection', readonly=True, store=True, string='Type',
+ selection=[('payable', 'Payable'), ('receivable', 'Receivable')]),
}
- def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type, date_prefered, date_scheduled, currency=False, company_currency=False, context=None):
+ def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type,
+ date_prefered, date_scheduled, currency=False,
+ company_currency=False, context=None):
# Adds account.move.line name to the payment line communication
- res = super(payment_line, self).onchange_move_line(cr, uid, ids, move_line_id, payment_type, date_prefered, date_scheduled, currency, company_currency, context)
+ result = super(payment_line, self).onchange_move_line(
+ cr, uid, ids, move_line_id, payment_type, date_prefered,
+ date_scheduled, currency, company_currency, context)
if move_line_id:
- line = self.pool.get('account.move.line').browse(cr, uid, move_line_id)
+ line = self.pool.get('account.move.line').browse(
+ cr, uid, move_line_id, context=context)
if line.name != '/':
- res['value']['communication'] = res['value']['communication'] + '. ' + line.name
- res['value']['account_id'] = line.account_id.id
- return res
-
-payment_line()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ result['value']['communication'] = result['value']['communication'] + '. ' + line.name
+ result['value']['account_id'] = line.account_id.id
+ return result
=== added file 'account_payment_extension/account_payment_extension.py'
--- account_payment_extension/account_payment_extension.py 1970-01-01 00:00:00 +0000
+++ account_payment_extension/account_payment_extension.py 2013-08-18 21:37:33 +0000
@@ -0,0 +1,51 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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 openerp.osv import fields, orm
+
+
+class payment_type(orm.Model):
+ _name = 'payment.type'
+ _description = 'Payment type'
+ _columns = {
+ 'name': fields.char('Name', size=64, required=True,
+ help='Payment Type', translate=True),
+ 'code': fields.char('Code', size=64, required=True,
+ help='Specify the Code for Payment Type'),
+ 'suitable_bank_types': fields.many2many(
+ 'res.partner.bank.type', 'bank_type_payment_type_rel',
+ 'pay_type_id', 'bank_type_id', 'Suitable bank types'),
+ 'active': fields.boolean('Active', select=True),
+ 'note': fields.text('Description', translate=True,
+ help="""Description of the payment type that will be shown
+ in the invoices"""),
+ 'company_id': fields.many2one('res.company', 'Company', required=True),
+ }
+ _defaults = {
+ 'active': lambda *a: 1,
+ 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id
+ }
=== added file 'account_payment_extension/account_payment_extension_view.xml'
--- account_payment_extension/account_payment_extension_view.xml 1970-01-01 00:00:00 +0000
+++ account_payment_extension/account_payment_extension_view.xml 2013-08-18 21:37:33 +0000
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record model="ir.ui.view" id="view_payment_type_tree">
+ <field name="name">payment.type.tree</field>
+ <field name="model">payment.type</field>
+ <field name="arch" type="xml">
+ <tree string="Payment Type">
+ <field name="name"/>
+ <field name="code"/>
+ <field name="active"/>
+ <field name="company_id" groups="base.group_multi_company"/>
+ </tree>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="view_payment_type_form">
+ <field name="name">payment.type.form</field>
+ <field name="model">payment.type</field>
+ <field name="arch" type="xml">
+ <form string="Payment Type">
+ <field name="name" select="1"/>
+ <field name="code" select="1"/>
+ <field name="active" select="1"/>
+ <field name="company_id" select="1" widget='selection' groups="base.group_multi_company"/>
+ <separator string="Description" colspan="4"/>
+ <field name="note" nolabel="1" colspan="4"/>
+ <separator string="Suitable Bank Types" colspan="4"/>
+ <field name="suitable_bank_types" nolabel="1" colspan="4"/>
+ </form>
+ </field>
+ </record>
+
+ <record model="ir.actions.act_window" id="action_payment_type">
+ <field name="name">Payment Type</field>
+ <field name="res_model">payment.type</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem action="action_payment_type" id="menu_action_payment_type" parent="account.menu_configuration_misc"/>
+
+</data>
+</openerp>
=== renamed file 'account_payment_extension/payment_sequence.xml' => 'account_payment_extension/account_payment_sequence.xml'
=== renamed file 'account_payment_extension/payment_view.xml' => 'account_payment_extension/account_payment_view.xml' (properties changed: +x to -x)
--- account_payment_extension/payment_view.xml 2013-01-02 20:38:09 +0000
+++ account_payment_extension/account_payment_view.xml 2013-08-18 21:37:33 +0000
@@ -3,131 +3,6 @@
<data>
<!--
- ========================================================================================================
- PARTNERS - default bank
- ========================================================================================================
- -->
- <record model="ir.ui.view" id="view_partner_form">
- <field name="model">res.partner</field>
- <field name="inherit_id" ref="account.view_partner_property_form"/>
- <field name="arch" type="xml">
- <field name="acc_number" position="after">
- <field name="default_bank"/>
- </field>
- </field>
- </record>
-
- <record model="ir.ui.view" id="view_partner_form2">
- <field name="model">res.partner</field>
- <field name="inherit_id" ref="account.view_partner_property_form"/>
- <field name="arch" type="xml">
- <tree string="Bank Details" position="inside">
- <field name="default_bank"/>
- </tree>
- </field>
- </record>
-
- <record model="ir.ui.view" id="view_partner_form3">
- <field name="name">view.partner.form3</field>
- <field name="model">res.partner.bank</field>
- <field name="inherit_id" ref="base.view_partner_bank_form"/>
- <field name="arch" type="xml">
- <field name="acc_number" position="after">
- <field name="default_bank"/>
- </field>
- </field>
- </record>
-
- <record model="ir.ui.view" id="view_partner_bank_tree">
- <field name="name">view.partner.bank.tree </field>
- <field name="model">res.partner.bank</field>
- <field name="inherit_id" ref="base.view_partner_bank_tree"/>
- <field name="arch" type="xml">
- <field name="partner_id" position="before">
- <field name="default_bank"/>
- </field>
- </field>
- </record>
-
-
- <!--
- ====================================================================================================
- PARTNERS - payment type
- ====================================================================================================
- -->
- <record model="ir.ui.view" id="view_payment_type_res_partner_form1">
- <field name="name">res.partner.form.payment_type1</field>
- <field name="model">res.partner</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account.view_partner_property_form"/>
- <field name="priority" eval="20"/>
- <field name="arch" type="xml">
- <field name="property_account_receivable" position="after">
- <field name="payment_type_customer" widget="selection"/>
- </field>
- </field>
- </record>
-
- <record model="ir.ui.view" id="view_payment_type_res_partner_form2">
- <field name="name">res.partner.form.payment_type2</field>
- <field name="model">res.partner</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account.view_partner_property_form"/>
- <field name="priority" eval="20"/>
- <field name="arch" type="xml">
- <field name="property_account_payable" position="after">
- <field name="payment_type_supplier" widget="selection"/>
- </field>
- </field>
- </record>
-
-
- <!--
- =====================================================================================================
- PAYMENT TYPE
- =====================================================================================================
- -->
- <record model="ir.ui.view" id="view_payment_type_tree">
- <field name="name">payment.type.tree</field>
- <field name="model">payment.type</field>
- <field name="type">tree</field>
- <field name="arch" type="xml">
- <tree string="Payment Type">
- <field name="name"/>
- <field name="code"/>
- <field name="active"/>
- <field name="company_id" groups="base.group_multi_company"/>
- </tree>
- </field>
- </record>
-
- <record model="ir.ui.view" id="view_payment_type_form">
- <field name="name">payment.type.form</field>
- <field name="model">payment.type</field>
- <field name="type">form</field>
- <field name="arch" type="xml">
- <form string="Payment Type">
- <field name="name" select="1"/>
- <field name="code" select="1"/>
- <field name="active" select="1"/>
- <field name="company_id" select="1" widget='selection' groups="base.group_multi_company"/>
- <separator string="Description" colspan="4"/>
- <field name="note" nolabel="1" colspan="4"/>
- <separator string="Suitable Bank Types" colspan="4"/>
- <field name="suitable_bank_types" nolabel="1" colspan="4"/>
- </form>
- </field>
- </record>
-
- <record model="ir.actions.act_window" id="action_payment_type">
- <field name="name">Payment Type</field>
- <field name="res_model">payment.type</field>
- <field name="view_mode">tree,form</field>
- </record>
-
- <menuitem action="action_payment_type" id="menu_action_payment_type" parent="account.menu_configuration_misc"/>
-
- <!--
=======================================================================================================
PAYMENT MODE
=======================================================================================================
@@ -135,7 +10,6 @@
<record id="view_payment_mode_form_require_bank_account" model="ir.ui.view">
<field name="name">payment.mode.form.require_bank_account</field>
<field name="model">payment.mode</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
<field name="arch" type="xml">
<field name="bank_id" position="before">
@@ -145,49 +19,6 @@
</field>
</record>
- <!--
- =================================================================================================
- INVOICES
- =================================================================================================
- -->
- <!--Field partner_bank_id in client invoices has a strange domain: domain="[('partner_id.ref_companies', 'in', [company_id])]"-->
-
- <record model="ir.ui.view" id="invoice_form3">
- <field name="name">account.invoice.form3.payment_type</field>
- <field name="model">account.invoice</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account.invoice_form"/>
- <field name="arch" type="xml">
- <field name="partner_bank_id" position="replace">
- <field domain="[('partner_id', '=', partner_id)]" name="partner_bank_id" on_change="onchange_partner_bank(partner_bank_id)"/>
- </field>
- </field>
- </record>
-
- <record model="ir.ui.view" id="invoice_form4">
- <field name="name">account.invoice.form4.payment_type</field>
- <field name="model">account.invoice</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account.invoice_form"/>
- <field name="arch" type="xml">
- <field name="fiscal_position" position="after">
- <field domain="[('company_id', '=', company_id)]" name="payment_type" on_change="onchange_payment_type(payment_type, partner_id)" />
- </field>
- </field>
- </record>
-
- <record model="ir.ui.view" id="invoice_supplier_form2">
- <field name="name">account.invoice.supplier.form2</field>
- <field name="model">account.invoice</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account.invoice_supplier_form"/>
- <field name="arch" type="xml">
- <field name="fiscal_position" position="after">
- <field domain="[('company_id', '=', company_id)]" name="payment_type" on_change="onchange_payment_type(payment_type, partner_id)" />
- </field>
- </field>
- </record>
-
<!--************ account.move.line extension to show additional fields ********** -->
<record model="ir.ui.view" id="view_move_line_tree_wiz">
<field name="name">account.move.line.tree</field>
@@ -210,7 +41,6 @@
<record model="ir.ui.view" id="payments_move_line_form">
<field name="name">account.payments.move.line.form</field>
<field name="model">account.move.line</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account.view_move_line_form"/>
<field name="arch" type="xml">
<field name="narration" position="before">
@@ -233,12 +63,11 @@
<record id="view_bank_statement_form_ext" model="ir.ui.view">
<field name="name">account.bank.statement.form.ext</field>
<field name="model">account.bank.statement</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_payment.view_bank_statement_form"/>
<field name="arch" type="xml">
<button name="%(account_payment.action_account_populate_statement_confirm)d" position="replace">
<button name="%(act_wizard_populate_statement)d" string="Import payment lines" type="action" attrs="{'invisible':[('state','=','confirm')]}" icon="gtk-execute"/>
- </button>
+ </button>
</field>
</record>
-->
@@ -251,27 +80,20 @@
<record id="view_payment_order_form_ext1" model="ir.ui.view">
<field name="name">payment.order.form.ext1</field>
<field name="model">payment.order</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_payment.view_payment_order_form"/>
<field name="arch" type="xml">
<button name="%(account_payment.action_create_payment_order)d" position="replace">
+ <button name="%(action_create_payment_extension_order)d" string="Select invoices to pay/receive payment" type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/>
+ </button>
+ <button name="cancel" position="after">
+ <button name="cancel_from_done" states="done" type="object" string="Cancel" icon="gtk-cancel"/>
+ </button>
+ <field name="mode" position="after">
<field name="payment_type_name" invisible="1"/>
<field name="type"/>
<field name="create_account_moves"/>
- <group colspan="2" col="1" attrs="{'invisible': [('create_account_moves', '=', 'bank-statement')]}">
- <field name="period_id" attrs="{'required': [('create_account_moves', '!=', 'bank-statement')]}"/>
- </group>
- <button colspan="2" name="%(action_create_payment_extension_order)d" string="Select invoices to pay/receive payment" type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/>
- </button>
- </field>
- </record>
-
- <record id="view_payment_order_form_ext2" model="ir.ui.view">
- <field name="name">payment.order.form.ext2</field>
- <field name="model">payment.order</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account_payment.view_payment_order_form"/>
- <field name="arch" type="xml">
+ <field name="period_id" attrs="{'required': [('create_account_moves', '!=', 'bank-statement')], 'invisible': [('create_account_moves', '=', 'bank-statement')]}"/>
+ </field>
<field name="move_line_id" position="replace">
<group col="6" colspan="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,context)" select="1"/>
@@ -282,22 +104,9 @@
</field>
</record>
- <record id="view_payment_order_form_cancel" model="ir.ui.view">
- <field name="name">payment.order.form.cancel</field>
- <field name="model">payment.order</field>
- <field name="type">form</field>
- <field name="inherit_id" ref="account_payment.view_payment_order_form"/>
- <field name="arch" type="xml">
- <button name="cancel" position="after">
- <button name="cancel_from_done" states="done" type="object" string="Cancel" icon="gtk-cancel"/>
- </button>
- </field>
- </record>
-
<record id="view_payment_line_form_ext1" model="ir.ui.view">
<field name="name">payment.line.ext1</field>
<field name="model">payment.line</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_payment.view_payment_line_form"/>
<field name="arch" type="xml">
<field name="move_line_id" position="replace">
@@ -310,7 +119,6 @@
</field>
</record>
-
<!--
====================================================================================================
PAYABLE PAYMENT ORDER
@@ -321,8 +129,8 @@
<field name="res_model">payment.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
- <field name="domain">[('type','=','payable')]</field>
- <field name="context">{'type':'payable'}</field>
+ <field name="domain">[('type', '=', 'payable')]</field>
+ <field name="context">{'type': 'payable'}</field>
</record>
<!--
@@ -335,8 +143,8 @@
<field name="res_model">payment.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
- <field name="domain">[('type','=','receivable')]</field>
- <field name="context">{'type':'receivable'}</field>
+ <field name="domain">[('type', '=', 'receivable')]</field>
+ <field name="context">{'type': 'receivable'}</field>
</record>
<menuitem action="action_rec_payment_order_tree" id="menu_action_rec_payment_order_form" parent="account_payment.menu_main_payment" sequence="2"/>
@@ -349,11 +157,9 @@
<field name="name">Payments</field>
<field name="model">account.move.line</field>
<field name="field_parent">partner_id</field>
- <field name="type">tree</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
- <tree string="Payments" editable="top"
- colors="grey:reconcile_id!=0;blue:amount_to_pay==0;red:date_maturity<time.strftime('%%Y-%%m-%%d')">
+ <tree string="Payments" editable="top" colors="grey:reconcile_id!=0;blue:amount_to_pay==0;red:date_maturity<time.strftime('%%Y-%%m-%%d')">
<field name="invoice" readonly="1"/>
<field name="partner_id" readonly="1"/>
<field name="account_id" readonly="1"/>
@@ -374,7 +180,6 @@
<record id="view_payments_filter" model="ir.ui.view">
<field name="name">Invoice Payments Select</field>
<field name="model">account.move.line</field>
- <field name="type">search</field>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<search string="Search Invoice Payments">
@@ -404,14 +209,13 @@
</record>
<!-- 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>
<field name="view_type">form</field>
<field name="view_id" ref="view_payments_tree"/>
<field name="search_view_id" ref="view_payments_filter"/>
- <field name="domain">[('account_id.type','in',['receivable','payable']),('invoice','<>',False)]</field>
+ <field name="domain">[('account_id.type', 'in', ['receivable', 'payable']), ('reconcile_id', '=', False)]</field>
</record>
<menuitem name="Invoice payments" parent="account_payment.menu_main_payment" action="action_invoice_payments" id="menu_action_invoice_payments" sequence="4"/>
@@ -423,7 +227,7 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_payments_tree"/>
<field name="search_view_id" ref="view_payments_filter"/>
- <field name="domain">[('account_id.type','in',['receivable','payable']),('invoice','=',False)]</field>
+ <field name="domain">[('account_id.type', 'in', ['receivable', 'payable']), ('reconcile_id', '!=', False)]</field>
</record>
<menuitem name="Done payments" parent="account_payment.menu_main_payment" action="action_done_payments" id="menu_action_done_payments" sequence="5"/>
=== modified file 'account_payment_extension/i18n/fr_BE.po' (properties changed: +x to -x)
=== modified file 'account_payment_extension/i18n/pt_BR.po'
--- account_payment_extension/i18n/pt_BR.po 2012-12-11 05:25:53 +0000
+++ account_payment_extension/i18n/pt_BR.po 2013-08-18 21:37:33 +0000
@@ -48,7 +48,7 @@
#. module: account_payment_extension
#: constraint:ir.actions.act_window:0
msgid "Invalid model name in the action definition."
-msgstr ""
+msgstr "Nome do modelo inválido na ação definida"
#. module: account_payment_extension
#: help:payment.type,code:0
@@ -66,7 +66,7 @@
msgid ""
"You cannot delete payment order(s) which are already confirmed or done!"
msgstr ""
-"You cannot delete payment order(s) which are already confirmed or done!"
+"Você não pode excluir ordens de pagamentos que estão confirmadas ou concluídas!"
#. module: account_payment_extension
#: model:ir.model,name:account_payment_extension.model_payment_order
@@ -81,17 +81,17 @@
#. module: account_payment_extension
#: constraint:ir.ui.view:0
msgid "Invalid XML for View Architecture!"
-msgstr ""
+msgstr "XML Inválido para Arquitetura da Visão"
#. module: account_payment_extension
#: field:payment.mode,require_bank_account:0
msgid "Require Bank Account"
-msgstr "Require Bank Account"
+msgstr "Conta Corrente Requerida"
#. module: account_payment_extension
#: model:ir.actions.wizard,name:account_payment_extension.wizard_populate_statement_ext
msgid "Populate Statement with Payment lines"
-msgstr "Populate Statement with Payment lines"
+msgstr "Importar das Linhas de Pagamento"
#. module: account_payment_extension
#: wizard_field:populate_statement_ext,init,lines:0
@@ -106,7 +106,7 @@
#. module: account_payment_extension
#: constraint:ir.ui.menu:0
msgid "Error ! You can not create recursive Menu."
-msgstr ""
+msgstr "Erro ! Você não pode criar um menu recursivo."
#. module: account_payment_extension
#: model:ir.model,name:account_payment_extension.model_payment_mode
@@ -164,7 +164,7 @@
#: code:addons/account_payment_extension/payment.py:0
#, python-format
msgid "Account move line \"%s\" is not valid"
-msgstr "Account move line \"%s\" is not valid"
+msgstr "Linha de movimentação contábil \"%s\" não é válida"
#. module: account_payment_extension
#: wizard_button:populate_payment_ext,init,end:0
@@ -192,7 +192,7 @@
#. module: account_payment_extension
#: model:ir.actions.wizard,name:account_payment_extension.wizard_populate_payment_ext
msgid "Populate payment to pay"
-msgstr "Povoar Pagamentos para Pagar"
+msgstr "Importar Pagamentos para Pagar"
#. module: account_payment_extension
#: field:res.partner,payment_type_customer:0
@@ -202,7 +202,7 @@
#. module: account_payment_extension
#: help:populate_payment_ext,init,amount:0
msgid "Next step will automatically select payments up to this amount."
-msgstr ""
+msgstr "O próximo passo vai selecionar automaticamente os pagamentos até esse valor."
#. module: account_payment_extension
#: wizard_field:populate_payment_ext,search,entries:0
@@ -319,7 +319,7 @@
#. module: account_payment_extension
#: help:payment.mode,type:0
msgid "Select the Payment Type for the Payment Mode."
-msgstr "Select the Payment Type for the Payment Mode."
+msgstr "Selecione o Tipo de Pagamento para o Modo de Pagamento."
#. module: account_payment_extension
#: view:account.bank.statement:0
@@ -339,25 +339,25 @@
#. module: account_payment_extension
#: help:res.partner,payment_type_customer:0
msgid "Payment type of the customer"
-msgstr "Tipo de Pagamento Cliente"
+msgstr "Tipo de Pagamento do Cliente"
#. module: account_payment_extension
#: model:ir.actions.act_window,name:account_payment_extension.action_pay_payment_order_tree
#: model:ir.ui.menu,name:account_payment_extension.menu_action_pay_payment_order_form
msgid "Pay. payment order"
-msgstr ""
+msgstr "Ordem de Pagamento"
#. module: account_payment_extension
#: model:ir.actions.act_window,name:account_payment_extension.action_invoice_payments
#: model:ir.ui.menu,name:account_payment_extension.menu_action_invoice_payments
msgid "Invoice payments"
-msgstr "Fluxo de Caixa"
+msgstr "Contas a Pagar/Receber"
#. module: account_payment_extension
#: model:ir.actions.act_window,name:account_payment_extension.action_done_payments
#: model:ir.ui.menu,name:account_payment_extension.menu_action_done_payments
msgid "Done payments"
-msgstr "Pagamento Concluídos"
+msgstr "Baixa de Pagar/Receber"
#. module: account_payment_extension
#: field:account.invoice,payment_type:0
@@ -402,6 +402,7 @@
msgid ""
"The Object name must start with x_ and not contain any special character !"
msgstr ""
+"O Nome do objeto deve começar com x_ e não deve conter caracteres especiais !"
#. module: account_payment_extension
#: model:ir.model,name:account_payment_extension.model_account_move_line
@@ -423,7 +424,7 @@
#. module: account_payment_extension
#: view:account.move.line:0
msgid "Narration"
-msgstr ""
+msgstr "Narrativa"
#. module: account_payment_extension
#: model:ir.model,name:account_payment_extension.model_res_partner
@@ -443,7 +444,7 @@
#. module: account_payment_extension
#: sql_constraint:ir.model.fields:0
msgid "Size of the field can never be less than 1 !"
-msgstr ""
+msgstr "O Tamanho do campo numca deve ser menor do que 1!"
#. module: account_payment_extension
#: help:payment.order,create_account_moves:0
=== added file 'account_payment_extension/res_partner.py'
--- account_payment_extension/res_partner.py 1970-01-01 00:00:00 +0000
+++ account_payment_extension/res_partner.py 2013-08-18 21:37:33 +0000
@@ -0,0 +1,83 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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 openerp.osv import orm, fields
+
+
+class res_partner(orm.Model):
+ _inherit = 'res.partner'
+ _columns = {
+ 'payment_type_customer': fields.property(
+ 'payment.type', type='many2one', relation='payment.type',
+ string='Customer Payment Type', method=True, view_load=True,
+ help="Payment type of the customer"),
+ 'payment_type_supplier': fields.property(
+ 'payment.type', type='many2one', relation='payment.type',
+ string='Supplier Payment Type', method=True, view_load=True,
+ help="Payment type of the supplier"),
+ }
+
+
+class res_partner_bank(orm.Model):
+ _inherit = 'res.partner.bank'
+
+ def create(self, cr, uid, vals, context=None):
+ if vals.get('default_bank') and vals.get('partner_id') and \
+ vals.get('state'):
+ sql = """UPDATE res_partner_bank SET
+ default_bank = '0'
+ WHERE
+ partner_id = %i
+ AND default_bank = true
+ AND state='%s'""" % (vals['partner_id'], vals['state'])
+ cr.execute(sql)
+ return super(res_partner_bank, self).create(
+ cr, uid, vals, context=context)
+
+ def write(self, cr, uid, ids, vals, context=None):
+ if 'default_bank' in vals and vals['default_bank']:
+ partner_bank = self.pool.get('res.partner.bank').browse(
+ cr, uid, ids)[0]
+ partner_id = partner_bank.partner_id.id
+ if 'state' in vals and vals['state']:
+ state = vals['state']
+ else:
+ state = partner_bank.state
+ sql = """UPDATE res_partner_bank SET
+ default_bank='0'
+ WHERE
+ partner_id = %i
+ AND default_bank = true
+ AND state = '%s'
+ AND id <> %i""" % (partner_id, state, ids[0])
+ cr.execute(sql)
+ return super(res_partner_bank, self).write(
+ cr, uid, ids, vals, context=context)
+
+ _columns = {
+ 'default_bank': fields.boolean('Default'),
+ }
\ No newline at end of file
=== added file 'account_payment_extension/res_partner_view.xml'
--- account_payment_extension/res_partner_view.xml 1970-01-01 00:00:00 +0000
+++ account_payment_extension/res_partner_view.xml 2013-08-18 21:37:33 +0000
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!--
+ ========================================================================================================
+ PARTNERS - default bank
+ ========================================================================================================
+ -->
+ <record model="ir.ui.view" id="view_partner_form">
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="account.view_partner_property_form"/>
+ <field name="arch" type="xml">
+ <field name="acc_number" position="after">
+ <field name="default_bank"/>
+ </field>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="view_partner_form2">
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="account.view_partner_property_form"/>
+ <field name="arch" type="xml">
+ <tree string="Bank Details" position="inside">
+ <field name="default_bank"/>
+ </tree>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="view_partner_form3">
+ <field name="name">view.partner.form3</field>
+ <field name="model">res.partner.bank</field>
+ <field name="inherit_id" ref="base.view_partner_bank_form"/>
+ <field name="arch" type="xml">
+ <field name="acc_number" position="after">
+ <field name="default_bank"/>
+ </field>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="view_partner_bank_tree">
+ <field name="name">view.partner.bank.tree </field>
+ <field name="model">res.partner.bank</field>
+ <field name="inherit_id" ref="base.view_partner_bank_tree"/>
+ <field name="arch" type="xml">
+ <field name="partner_id" position="before">
+ <field name="default_bank"/>
+ </field>
+ </field>
+ </record>
+
+
+ <!--
+ ====================================================================================================
+ PARTNERS - payment type
+ ====================================================================================================
+ -->
+ <record model="ir.ui.view" id="view_payment_type_res_partner_form1">
+ <field name="name">res.partner.form.payment_type1</field>
+ <field name="model">res.partner</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="account.view_partner_property_form"/>
+ <field name="priority" eval="20"/>
+ <field name="arch" type="xml">
+ <field name="property_account_receivable" position="after">
+ <field name="payment_type_customer" widget="selection"/>
+ </field>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="view_payment_type_res_partner_form2">
+ <field name="name">res.partner.form.payment_type2</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="account.view_partner_property_form"/>
+ <field name="priority" eval="20"/>
+ <field name="arch" type="xml">
+ <field name="property_account_payable" position="after">
+ <field name="payment_type_supplier" widget="selection"/>
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
\ No newline at end of file
=== added directory 'account_payment_extension/test'
=== added file 'account_payment_extension/test/__init__.py'
--- account_payment_extension/test/__init__.py 1970-01-01 00:00:00 +0000
+++ account_payment_extension/test/__init__.py 2013-08-18 21:37:33 +0000
@@ -0,0 +1,26 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com)
+# All Rights Reserved.Jordi Esteve <jesteve@xxxxxxxxxxxxxxx>
+# AvanzOSC, Avanzed Open Source Consulting
+# Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
+# Copyright (C) 2013 Akretion Ltda ME (www.akretion.com) All Rights Reserved
+# Renato Lima <renato.lima@xxxxxxxxxxxxxxx>
+# $Id$
+#
+# 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/>.
+#
+##############################################################################
=== 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-08-18 21:37:33 +0000
@@ -24,6 +24,3 @@
##############################################################################
import account_payment_order
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
=== modified file 'account_payment_extension/wizard/account_payment_order_view.xml'
--- account_payment_extension/wizard/account_payment_order_view.xml 2012-11-25 07:59:40 +0000
+++ account_payment_extension/wizard/account_payment_order_view.xml 2013-08-18 21:37:33 +0000
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
-
+
<record id="view_create_payment_extension_order" model="ir.ui.view">
<field name="name">payment.extension.order.create.form</field>
<field name="model">payment.order.create</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_payment.view_create_payment_order"/>
<field name="arch" type="xml">
<field name="duedate" position="after">
@@ -16,11 +15,11 @@
</field>
</field>
</record>
- <!-- FORM LIST-->
+
+ <!-- FORM LIST-->
<record id="view_create_payment_extension_order_lines" model="ir.ui.view">
<field name="name">payment.extension.order.create.form</field>
<field name="model">payment.order.create</field>
- <field name="type">form</field>
<field name="inherit_id" ref="account_payment.view_create_payment_order_lines"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='entries']/.." position="replace">
@@ -34,7 +33,6 @@
</field>
</record>
-
<!-- ACCION -->
<record id="action_create_payment_extension_order" model="ir.actions.act_window">
<field name="name">Seleccionar facturas a Pagar/Cobrar</field>
@@ -44,8 +42,8 @@
<field name="view_mode">form</field>
<field name="view_id" ref="view_create_payment_extension_order"/>
<field name="target">new</field>
+ <field name="context">{'record_id': active_id}</field>
</record>
-
-
+
</data>
</openerp>
=== modified file 'sale_payment/__init__.py' (properties changed: +x to -x)
=== modified file 'sale_payment/__openerp__.py' (properties changed: +x to -x)
=== modified file 'sale_payment/i18n/ca.po' (properties changed: +x to -x)
=== modified file 'sale_payment/i18n/es.po' (properties changed: +x to -x)
=== modified file 'sale_payment/i18n/fr_BE.po' (properties changed: +x to -x)
=== modified file 'sale_payment/i18n/sale_payment.pot' (properties changed: +x to -x)
=== modified file 'sale_payment/sale_payment.py' (properties changed: +x to -x)
=== modified file 'sale_payment/sale_payment_view.xml' (properties changed: +x to -x)
Follow ups