[MIG] Adapt bank statement import to 7.0 API, views

[LIC] Relicense as AGPL
[IMP] Create partners as suppliers if amount < 0
This commit is contained in:
unknown
2013-06-03 11:26:36 +02:00
committed by Holger Brunn
81 changed files with 2022 additions and 2214 deletions

View File

@@ -11,16 +11,16 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
@@ -8,46 +9,40 @@
#
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 Banking',
'version': '0.1.136',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'Banking addons community',
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['base', 'account', 'base_iban', 'account_payment',
'account_iban_preserve_domestic'],
'init_xml': [],
'update_xml': [
'depends': [
'account_voucher',
'account_iban_preserve_domestic',
],
'data': [
'security/ir.model.access.csv',
'data/account_banking_data.xml',
'wizard/bank_import_view.xml',
'account_banking_view.xml',
'account_banking_workflow.xml',
'wizard/banking_transaction_wizard.xml',
'workflow/account_invoice.xml',
],
'demo_xml': [],
'external_dependencies': {
'python' : ['BeautifulSoup'],
},
@@ -106,6 +101,5 @@
+ No special configuration needed for the parsers, new parsers are
recognized and made available at server (re)start.
''',
'active': False,
'installable': False,
'installable': True,
}

File diff suppressed because it is too large Load Diff

View File

@@ -134,16 +134,7 @@
</tree>
</field>
</record>
<record id="view_account_banking_imported_line_search" model="ir.ui.view">
<field name="name">account.banking.imported.line.search</field>
<field name="model">account.bank.imported.line</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Bank Statement files">
<field name="company_id" />
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_banking_imported_files">
<field name="name">Imported Bank Statements Files</field>
<field name="type">ir.actions.act_window</field>
@@ -193,7 +184,12 @@
<field name="model">account.bank.statement</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="period_id" position="replace"/>
<!-- Remove period from bank statement -->
<field name="period_id" position="replace">
<!-- Add invisible column for identification of import file
-->
<field name="banking_id" invisible="True" />
</field>
</field>
</record>
<record id="view_banking_bank_statement_form_1" model="ir.ui.view">
@@ -204,92 +200,52 @@
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<page string="Transactions" position="after">
<page string="Journal Entries" name="move_live_ids">
<field colspan="4" name="move_line_ids" nolabel="1"/>
</page>
</page>
<field name="period_id" position="replace"/>
<xpath expr="/form/notebook/page[@string='Transaction']/field/tree" position="attributes">
<xpath expr="//page[@string='Transactions']/field/tree"
position="attributes">
<attribute name="colors">black:state == 'confirmed';darkmagenta:match_multi == True;crimson:duplicate == True;grey:state == 'draft';</attribute>
</xpath>
<xpath expr="/form/notebook/page[@string='Transaction']/field/tree/field[@name='name']" position="replace">
<field name="name" required="1"/>
</xpath>
<xpath expr="/form/notebook/page[@string='Transaction']/field/form/field[@name='name']" position="replace">
<field name="name" required="1"/>
</xpath>
</data>
</field>
</record>
<record id="view_banking_bank_statement_form_2" model="ir.ui.view">
<field name="name">account.bank.statement.form.banking-2</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[@string='Transaction']/field/tree/field[@name='ref']" position="after">
<field name="period_id"/>
</xpath>
</field>
</record>
<record id="view_banking_bank_statement_form_3" model="ir.ui.view">
<field name="name">account.bank.statement.form.banking-3</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/notebook/page[@string='Transaction']/field/form/field[@name='ref']" position="after">
<field name="period_id"/>
<field name="match_type"/>
<field name="match_multi"/>
<field name="duplicate"/>
</xpath>
</data>
</field>
</record>
<!-- Add invisible column on bank statements tree for identification
of import file
-->
<record id="view_banking_bank_statement_tree_2" model="ir.ui.view">
<field name="name">account.bank.statement.tree.banking-2</field>
<field name="inherit_id" ref="account.view_bank_statement_tree" />
<field name="model">account.bank.statement</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="state" position="after">
<field name="banking_id" invisible="True" />
</field>
</field>
</record>
<xpath expr="//field[@name='line_ids']/tree/field[@name='name']"
position="attributes">
<attribute name="required">1</attribute>
</xpath>
<!-- Add invisible field for identification of import file on bank statements
-->
<record id="view_banking_bank_statement_form_4" model="ir.ui.view">
<field name="name">account.bank.statement.form.banking-4</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="balance_end_real" position="after">
<field name="banking_id" invisible="True"/>
</field>
</field>
</record>
<xpath expr="//field[@name='line_ids']/form//field[@name='name']"
position="attributes">
<attribute name="required">1</attribute>
</xpath>
<!-- Show bank accounts in account_bank_statement_line to enable manual
coupling of bank account numbers to statement lines and harvest info
for future matching in the process.
-->
<record id="view_banking_bank_statement_form_5" model="ir.ui.view">
<field name="name">account.bank.statement.form.banking-5</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='partner_id']" position="after">
<!-- Add invisible field for identification of import file
on bank statements
-->
<field name="balance_end_real" position="after">
<field name="banking_id" invisible="True"/>
</field>
<!-- Show bank accounts in account_bank_statement_line to
enable manualcoupling of bank account numbers to
statement lines and harvest info for future matching
in the process.
-->
<xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']"
position="after">
<!-- TODO set partner_id when partner_bank_id changes -->
<field name="partner_bank_id"/>
</xpath>
<xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after">
<xpath expr="//field[@name='line_ids']/form//field[@name='partner_id']"
position="after">
<field name="partner_bank_id"/>
</xpath>
<xpath expr="//field[@name='line_ids']/tree/field[@name='amount']"
position="after">
<field name="match_type"/>
<field name="residual"/>
<button name="match_wizard" states="draft"
@@ -310,7 +266,9 @@
<field name="invoice_id"/>
<field name="reconcile_id"/>
</xpath>
<xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='amount']" position="after">
<xpath expr="//field[@name='line_ids']/form//field[@name='amount']"
position="after">
<field name="state"/>
<field name="invoice_id"/>
<field name="reconcile_id"/>
@@ -318,69 +276,7 @@
</data>
</field>
</record>
<record id="view_banking_bank_statement_form_6" model="ir.ui.view">
<field name="name">account.bank.statement.form.banking-6</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="model">account.bank.statement</field>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='partner_id']" position="after">
<field name="partner_bank_id"/>
</xpath>
</field>
</record>
<!-- Make buttons on payment order sensitive for extra states,
restore wizard functionality when making payments
-->
<record id="view_banking_payment_order_form_1" model="ir.ui.view">
<field name="name">account.payment.order.form.banking-1</field>
<field name="inherit_id" ref="account_payment.view_payment_order_form" />
<field name="model">payment.order</field>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/group/button[@string='Select Invoices to Pay']"
position="replace">
<button colspan="2" name="%(account_payment.action_create_payment_order)s"
string="Select Invoices to Pay" type="action"
attrs="{'invisible':[('state','!=','draft')]}"
icon="gtk-find"
/>
</xpath>
<xpath expr="/form/group/button[@string='Make Payments']"
position="replace">
<button name="launch_wizard" states="open" string="Make Payments" type="object" icon="gtk-execute"/>
<newline/>
</xpath>
</data>
</field>
</record>
<record id="view_banking_payment_order_tree_1" model="ir.ui.view">
<field name="name">account.payment.order.tree.banking-1</field>
<field name="inherit_id" ref="account_payment.view_payment_order_tree" />
<field name="model">payment.order</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<button string="Make Payments" position="replace">
<button name="launch_wizard" states="open" string="Make Payments" type="object" icon="gtk-execute"/>
</button>
</field>
</record>
<!-- Set trigger on IBAN and acc_number fields in res_partner_bank form -->
<!--record id="view_partner_bank_account_banking_form_1" model="ir.ui.view">
<field name="name">res.partner.bank.form.banking-1</field>
<field name="model">res.partner.bank</field>
<field name="inherit_id" ref="base_iban.view_partner_bank_iban_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="iban" position="replace">
<field name="iban" on_change="onchange_iban(iban)" />
</field>
</field>
</record-->
<record id="view_partner_bank_account_banking_form_2" model="ir.ui.view">
<field name="name">res.partner.bank.form.banking-2</field>
<field name="model">res.partner.bank</field>
@@ -399,53 +295,6 @@
</field>
</record>
<!-- Set trigger on IBAN and acc_number field in res_partner form -->
<!--record id="view_partner_account_banking_form_1" model="ir.ui.view">
<field name="name">res.partner.form.banking-1</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base_iban.view_partner_iban_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="iban" position="replace">
<field name="iban" on_change="onchange_iban(iban)" />
</field>
</field>
</record-->
<record id="view_partner_account_banking_form_2" model="ir.ui.view">
<field name="name">res.partner.form.banking-2</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="priority" eval="24"/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<field name="acc_number" position="attributes">
<attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute>
</field>
<field name="acc_number_domestic" position="attributes">
<attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute>
</field>
</data>
</field>
</record>
<record id="view_partner_account_banking_form_3" model="ir.ui.view">
<field name="name">res.partner.form.banking-3</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="priority" eval="24"/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<field name="acc_number" position="attributes">
<attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute>
</field>
<field name="acc_number_domestic" position="attributes">
<attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute>
</field>
</data>
</field>
</record>
<!-- Set trigger on BIC in res_bank form -->
<record id="view_res_bank_account_banking_form_1" model="ir.ui.view">
<field name="name">res.bank.form.banking-1</field>
@@ -459,54 +308,6 @@
</field>
</record>
<!-- Insert payment_mode.type -->
<record id="view_payment_mode_form_inherit" model="ir.ui.view">
<field name="name">payment.mode.form.inherit</field>
<field name="model">payment.mode</field>
<field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="type"/>
</field>
</field>
</record>
<record id="view_payment_mode_tree_inherit" model="ir.ui.view">
<field name="name">payment.mode.tree.inherit</field>
<field name="model">payment.mode</field>
<field name="inherit_id" ref="account_payment.view_payment_mode_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="type"/>
</field>
</field>
</record>
<!-- basic view for payment mode type -->
<record model="ir.ui.view" id="view_payment_mode_type_form">
<field name="name">view.payment.mode.type.form</field>
<field name="model">payment.mode.type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<field name="name" />
<field name="code" />
<field name="suitable_bank_types"/>
<field name="payment_order_type"/>
<field name="ir_model_id"/>
</form>
</field>
</record>
<!-- fixes https://bugs.launchpad.net/openobject-addons/+bug/903156 for 6.0
Note that 6.1 does not suffer from the problem
-->
<record id="account_payment.action_create_payment_order" model="ir.actions.act_window">
<field name="view_id" ref="account_payment.view_create_payment_order"/>
</record>
<record model="ir.ui.view" id="view_bank_statement_line_tree">
<field name="name">Bank statement line tree view</field>
<field name="model">account.bank.statement.line</field>
@@ -525,25 +326,25 @@
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
<field name="analytic_account_id" groups="analytic.group_analytic_accounting" domain="[('company_id', '=', parent.company_id), ('type', '&lt;&gt;', 'view')]"/>
<field name="amount"/>
<field name="match_type"/>
<field name="residual"/>
<button name="match_wizard" states="draft"
string="Match"
icon="terp-gtk-jump-to-ltr"
type="object"/>
<field name="match_multi" invisible="1"/>
<field name="duplicate" invisible="1"/>
<field name="state"/>
<button name="confirm" states="draft"
string="Confirm transaction"
icon="gtk-ok"
type="object"/>
<button name="cancel" states="confirmed"
string="Cancel transaction"
icon="gtk-cancel"
type="object"/>
<field name="invoice_id"/>
<field name="reconcile_id"/>
<field name="match_type"/>
<field name="residual"/>
<button name="match_wizard" states="draft"
string="Match"
icon="terp-gtk-jump-to-ltr"
type="object"/>
<field name="match_multi" invisible="1"/>
<field name="duplicate" invisible="1"/>
<field name="state"/>
<button name="confirm" states="draft"
string="Confirm transaction"
icon="gtk-ok"
type="object"/>
<button name="cancel" states="confirmed"
string="Cancel transaction"
icon="gtk-cancel"
type="object"/>
<field name="invoice_id"/>
<field name="reconcile_id"/>
</tree>
</field>
</record>

View File

@@ -1,45 +1,42 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# Contributions by Kaspars Vilkens (KNdati):
# lenghty discussions, bugreports and bugfixes
# Refractoring (C) 2011 Therp BV (<http://therp.nl>).
# (C) 2011 Smile (<http://smile.fr>).
# (C) 2011 Therp BV (<http://therp.nl>).
# (C) 2011 Smile (<http://smile.fr>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 osv, fields
import netsvc
import base64
import datetime
from tools import config
from tools.translate import _
from parsers import models
from parsers.convert import *
# from account_banking.struct import struct
from account_banking import sepa
from wizard.banktools import *
import decimal_precision as dp
from openerp.osv import orm, fields
from openerp import netsvc
from openerp.tools.translate import _
from openerp.addons.decimal_precision import decimal_precision as dp
from openerp.addons.account_banking.parsers import models
from openerp.addons.account_banking.parsers import convert
from openerp.addons.account_banking import sepa
from openerp.addons.account_banking.wizard import banktools
bt = models.mem_bank_transaction
class banking_import_transaction(osv.osv):
class banking_import_transaction(orm.Model):
""" orm representation of mem_bank_transaction() for interactive and posthoc
configuration of reconciliation in the bank statement view.
@@ -123,43 +120,6 @@ class banking_import_transaction(osv.osv):
# return move_lines to mix with the rest
return [x for x in invoice.move_id.line_id if x.account_id.reconcile]
def _match_debit_order(
self, cr, uid, trans, log, context=None):
def is_zero(total):
return self.pool.get('res.currency').is_zero(
cr, uid, trans.statement_id.currency, total)
payment_order_obj = self.pool.get('payment.order')
order_ids = payment_order_obj.search(
cr, uid, [('payment_order_type', '=', 'debit'),
('state', '=', 'sent'),
('date_sent', '<=', str2date(trans.execution_date,
'%Y-%m-%d'))
],
limit=0, context=context)
orders = payment_order_obj.browse(cr, uid, order_ids, context)
candidates = [x for x in orders if
is_zero(x.total - trans.transferred_amount)]
if len(candidates) > 0:
# retrieve the common account_id, if any
account_id = False
for line in candidates[0].line_ids[0].debit_move_line_id.move_id.line_id:
if line.account_id.type == 'other':
account_id = line.account_id.id
break
return dict(
move_line_ids = False,
match_type = 'payment_order',
payment_order_ids = [x.id for x in candidates],
account_id = account_id,
partner_id = False,
partner_bank_id = False,
reference = False,
type='general',
)
return False
def _match_invoice(self, cr, uid, trans, move_lines,
partner_ids, bank_account_ids,
log, linked_invoices,
@@ -282,8 +242,8 @@ class banking_import_transaction(osv.osv):
candidates = [
x for x in move_lines
if x.partner_id.id in partner_ids and
(str2date(x.date, '%Y-%m-%d') <=
(str2date(trans.execution_date, '%Y-%m-%d') +
(convert.str2date(x.date, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window))
and (not _cached(x) or _remaining(x))
]
@@ -304,8 +264,8 @@ class banking_import_transaction(osv.osv):
candidates = [
x for x in candidates or move_lines
if (x.invoice and has_id_match(x.invoice, ref, msg) and
str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
(str2date(trans.execution_date, '%Y-%m-%d') +
convert.str2date(x.invoice.date_invoice, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window)
and (not _cached(x) or _remaining(x)))
]
@@ -317,8 +277,8 @@ class banking_import_transaction(osv.osv):
x for x in move_lines
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
trans.transferred_amount)
and str2date(x.date, '%Y-%m-%d') <=
(str2date(trans.execution_date, '%Y-%m-%d') +
and convert.str2date(x.date, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window)
and (not _cached(x) or _remaining(x)))
]
@@ -333,8 +293,8 @@ class banking_import_transaction(osv.osv):
best = [x for x in candidates
if (is_zero(x.move_id, ((x.debit or 0.0) - (x.credit or 0.0)) -
trans.transferred_amount)
and str2date(x.date, '%Y-%m-%d') <=
(str2date(trans.execution_date, '%Y-%m-%d') +
and convert.str2date(x.date, '%Y-%m-%d') <=
(convert.str2date(trans.execution_date, '%Y-%m-%d') +
self.payment_window))
]
if len(best) == 1:
@@ -352,8 +312,8 @@ class banking_import_transaction(osv.osv):
# transfers first
paid = [x for x in move_lines
if x.invoice and has_id_match(x.invoice, ref, msg)
and str2date(x.invoice.date_invoice, '%Y-%m-%d')
<= str2date(trans.execution_date, '%Y-%m-%d')
and convert.str2date(x.invoice.date_invoice, '%Y-%m-%d')
<= convert.str2date(trans.execution_date, '%Y-%m-%d')
and (_cached(x) and not _remaining(x))
]
if paid:
@@ -443,7 +403,7 @@ class banking_import_transaction(osv.osv):
transaction = self.browse(cr, uid, transaction_id, context)
if not transaction.move_line_id:
if transaction.match_type == 'invoice':
raise osv.except_osv(
raise orm.except_orm(
_("Cannot link transaction %s with invoice") %
transaction.statement_line_id.name,
(transaction.invoice_ids and
@@ -453,7 +413,7 @@ class banking_import_transaction(osv.osv):
transaction.statement_line_id.name
)))
else:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot link transaction %s with accounting entry") %
transaction.statement_line_id.name,
(transaction.move_line_ids and
@@ -512,7 +472,6 @@ class banking_import_transaction(osv.osv):
'partner_id': st_line.partner_id and st_line.partner_id.id or False,
'company_id': st_line.company_id.id,
'type':voucher_type,
'company_id': st_line.company_id.id,
'account_id': account_id,
'amount': abs(st_line.amount),
'writeoff_amount': writeoff,
@@ -542,101 +501,6 @@ class banking_import_transaction(osv.osv):
{'voucher_id': voucher_id}, context=context)
transaction.refresh()
def _confirm_storno(
self, cr, uid, transaction_id, context=None):
"""
Creation of the reconciliation has been delegated to
*a* direct debit module, to allow for various direct debit styles
"""
payment_line_pool = self.pool.get('payment.line')
statement_line_pool = self.pool.get('account.bank.statement.line')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_line_id:
raise osv.except_osv(
_("Cannot link with storno"),
_("No direct debit order item"))
reconcile_id = payment_line_pool.debit_storno(
cr, uid,
transaction.payment_line_id.id,
transaction.statement_line_id.amount,
transaction.statement_line_id.currency,
transaction.storno_retry,
context=context)
statement_line_pool.write(
cr, uid, transaction.statement_line_id.id,
{'reconcile_id': reconcile_id}, context=context)
transaction.refresh()
def _confirm_payment_order(
self, cr, uid, transaction_id, context=None):
"""
Creation of the reconciliation has been delegated to
*a* direct debit module, to allow for various direct debit styles
"""
payment_order_obj = self.pool.get('payment.order')
statement_line_pool = self.pool.get('account.bank.statement.line')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_order_id:
raise osv.except_osv(
_("Cannot reconcile"),
_("Cannot reconcile: no direct debit order"))
if transaction.payment_order_id.payment_order_type != 'debit':
raise osv.except_osv(
_("Cannot reconcile"),
_("Reconcile payment order not implemented"))
reconcile_id = payment_order_obj.debit_reconcile_transfer(
cr, uid,
transaction.payment_order_id.id,
transaction.statement_line_id.amount,
transaction.statement_line_id.currency,
context=context)
statement_line_pool.write(
cr, uid, transaction.statement_line_id.id,
{'reconcile_id': reconcile_id}, context=context)
def _confirm_payment(
self, cr, uid, transaction_id, context=None):
"""
Do some housekeeping on the payment line
then pass on to _reconcile_move
"""
transaction = self.browse(cr, uid, transaction_id, context=context)
payment_line_obj = self.pool.get('payment.line')
payment_line_obj.write(
cr, uid, transaction.payment_line_id.id, {
'export_state': 'done',
'date_done': transaction.statement_line_id.date,
}
)
self._confirm_move(cr, uid, transaction_id, context=context)
def _cancel_payment(
self, cr, uid, transaction_id, context=None):
raise osv.except_osv(
_("Cannot unreconcile"),
_("Cannot unreconcile: this operation is not yet supported for "
"match type 'payment'"))
def _cancel_payment_order(
self, cr, uid, transaction_id, context=None):
"""
"""
payment_order_obj = self.pool.get('payment.order')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_order_id:
raise osv.except_osv(
_("Cannot unreconcile"),
_("Cannot unreconcile: no direct debit order"))
if transaction.payment_order_id.payment_order_type != 'debit':
raise osv.except_osv(
_("Cannot unreconcile"),
_("Unreconcile payment order not implemented"))
return payment_order_obj.debit_unreconcile_transfer(
cr, uid, transaction.payment_order_id.id,
transaction.statement_line_id.reconcile_id.id,
transaction.statement_line_id.amount,
transaction.statement_line_id.currency)
def _legacy_do_move_unreconcile(self, cr, uid, move_line_ids, currency, context=None):
"""
Legacy method. Allow for canceling bank statement lines that
@@ -684,7 +548,7 @@ class banking_import_transaction(osv.osv):
def _legacy_clear_up_writeoff(self, cr, uid, transaction, context=None):
"""
Legacy method to support upgrades older installations of the
interactive wizard branch. To be removed after 6.2
interactive wizard branch. To be removed after 7.0
clear up the writeoff move
"""
if transaction.writeoff_move_line_id:
@@ -768,70 +632,10 @@ class banking_import_transaction(osv.osv):
return True
def _cancel_storno(
self, cr, uid, transaction_id, context=None):
"""
TODO: delegate unreconciliation to the direct debit module,
to allow for various direct debit styles
"""
payment_line_obj = self.pool.get('payment.line')
reconcile_obj = self.pool.get('account.move.reconcile')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_line_id:
raise osv.except_osv(
_("Cannot cancel link with storno"),
_("No direct debit order item"))
if not transaction.payment_line_id.storno:
raise osv.except_osv(
_("Cannot cancel link with storno"),
_("The direct debit order item is not marked for storno"))
journal = transaction.statement_line_id.statement_id.journal_id
if transaction.statement_line_id.amount >= 0:
account_id = journal.default_credit_account_id.id
else:
account_id = journal.default_debit_account_id.id
cancel_line = False
move_lines = []
for move in transaction.statement_line_id.move_ids:
# There should usually be just one move, I think
move_lines += move.line_id
for line in move_lines:
if line.account_id.id != account_id:
cancel_line = line
break
if not cancel_line:
raise osv.except_osv(
_("Cannot cancel link with storno"),
_("Line id not found"))
reconcile = cancel_line.reconcile_id or cancel_line.reconcile_partial_id
lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
if len(lines_reconcile) < 3:
# delete the full reconciliation
reconcile_obj.unlink(cr, uid, reconcile.id, context)
else:
# we are left with a partial reconciliation
reconcile_obj.write(
cr, uid, reconcile.id,
{'line_partial_ids':
[(6, 0, [x.id for x in lines_reconcile if x.id != cancel_line.id])],
'line_id': [(6, 0, [])],
}, context)
# redo the original payment line reconciliation with the invoice
payment_line_obj.write(
cr, uid, transaction.payment_line_id.id,
{'storno': False}, context)
payment_line_obj.debit_reconcile(
cr, uid, transaction.payment_line_id.id, context)
cancel_map = {
'storno': _cancel_storno,
'invoice': _cancel_voucher,
'manual': _cancel_voucher,
'move': _cancel_voucher,
'payment_order': _cancel_payment_order,
'payment': _cancel_payment,
}
def cancel(self, cr, uid, ids, context=None):
@@ -841,7 +645,7 @@ class banking_import_transaction(osv.osv):
if not transaction.match_type:
continue
if transaction.match_type not in self.cancel_map:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel type %s" % transaction.match_type),
_("No method found to cancel this type"))
self.cancel_map[transaction.match_type](
@@ -850,11 +654,8 @@ class banking_import_transaction(osv.osv):
return True
confirm_map = {
'storno': _confirm_storno,
'invoice': _confirm_move,
'manual': _confirm_move,
'payment_order': _confirm_payment_order,
'payment': _confirm_payment,
'move': _confirm_move,
}
@@ -865,7 +666,7 @@ class banking_import_transaction(osv.osv):
if not transaction.match_type:
continue
if transaction.match_type not in self.confirm_map:
raise osv.except_osv(
raise orm.except_orm(
_("Cannot reconcile"),
_("Cannot reconcile type %s. No method found to " +
"reconcile this type") %
@@ -873,7 +674,7 @@ class banking_import_transaction(osv.osv):
)
if (transaction.residual and transaction.writeoff_account_id):
if transaction.match_type not in ('invoice', 'move', 'manual'):
raise osv.except_osv(
raise orm.except_orm(
_("Cannot reconcile"),
_("Bank transaction %s: write off not implemented for " +
"this match type.") %
@@ -884,74 +685,8 @@ class banking_import_transaction(osv.osv):
self.confirm_map[transaction.match_type](
self, cr, uid, transaction.id, context)
"""
account_ids = [
x.id for x in bank_account_ids
if x.partner_id.id == move_line.partner_id.id
][0]
"""
return True
def _match_storno(
self, cr, uid, trans, log, context=None):
payment_line_obj = self.pool.get('payment.line')
line_ids = payment_line_obj.search(
cr, uid, [
('order_id.payment_order_type', '=', 'debit'),
('order_id.state', 'in', ['sent', 'done']),
('communication', '=', trans.reference)
], context=context)
# stornos MUST have an exact match
if len(line_ids) == 1:
account_id = payment_line_obj.get_storno_account_id(
cr, uid, line_ids[0], trans.transferred_amount,
trans.statement_id.currency, context=None)
if account_id:
return dict(
account_id = account_id,
match_type = 'storno',
payment_line_id = line_ids[0],
move_line_ids=False,
partner_id=False,
partner_bank_id=False,
reference=False,
type='customer',
)
# TODO log the reason why there is no result for transfers marked
# as storno
return False
def _match_payment(self, cr, uid, trans, payment_lines,
partner_ids, bank_account_ids, log, linked_payments):
'''
Find the payment order belonging to this reference - if there is one
This is the easiest part: when sending payments, the returned bank info
should be identical to ours.
This also means that we do not allow for multiple candidates.
'''
# TODO: Not sure what side effects are created when payments are done
# for credited customer invoices, which will be matched later on too.
digits = dp.get_precision('Account')(cr)[1]
candidates = [x for x in payment_lines
if x.communication == trans.reference
and round(x.amount, digits) == -round(trans.transferred_amount, digits)
and trans.remote_account in (x.bank_id.acc_number,
x.bank_id.acc_number_domestic)
]
if len(candidates) == 1:
candidate = candidates[0]
# Check cache to prevent multiple matching of a single payment
if candidate.id not in linked_payments:
linked_payments[candidate.id] = True
move_info = self._get_move_info(cr, uid, [candidate.move_line_id.id])
move_info.update({
'match_type': 'payment',
'payment_line_id': candidate.id,
})
return move_info
return False
signal_duplicate_keys = [
# does not include float values
# such as transferred_amount
@@ -982,7 +717,7 @@ class banking_import_transaction(osv.osv):
me['transferred_amount'] - trans.transferred_amount):
dupes.append(trans.id)
if len(dupes) < 1:
raise osv.except_osv(_('Cannot check for duplicate'),
raise orm.except_orm(_('Cannot check for duplicate'),
_("Cannot check for duplicate. "
"I can't find myself."))
if len(dupes) > 1:
@@ -1059,6 +794,22 @@ class banking_import_transaction(osv.osv):
retval['invoice_ids'] = [x.invoice.id for x in move_lines]
retval['type'] = type_map[move_lines[0].invoice.type]
return retval
def move_info2values(self, move_info):
vals = {}
vals['match_type'] = move_info['match_type']
vals['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]
vals['invoice_ids'] = [(6, 0, move_info.get('invoice_ids') or [])]
vals['move_line_id'] = (move_info.get('move_line_ids', False) and
len(move_info['move_line_ids']) == 1 and
move_info['move_line_ids'][0]
)
if move_info['match_type'] == 'invoice':
vals['invoice_id'] = (move_info.get('invoice_ids', False) and
len(move_info['invoice_ids']) == 1 and
move_info['invoice_ids'][0]
)
return vals
def match(self, cr, uid, ids, results=None, context=None):
if not ids:
@@ -1069,9 +820,9 @@ class banking_import_transaction(osv.osv):
journal_obj = self.pool.get('account.journal')
move_line_obj = self.pool.get('account.move.line')
payment_line_obj = self.pool.get('payment.line')
has_payment = bool(payment_line_obj)
statement_line_obj = self.pool.get('account.bank.statement.line')
statement_obj = self.pool.get('account.bank.statement')
payment_order_obj = self.pool.get('payment.order')
imported_statement_ids = []
# Results
@@ -1098,14 +849,15 @@ class banking_import_transaction(osv.osv):
# communication. Most likely there are much less sent payments
# than reconciled and open/draft payments.
# Strangely, payment_orders still do not have company_id
cr.execute("SELECT l.id FROM payment_order o, payment_line l "
"WHERE l.order_id = o.id AND "
"o.state = 'sent' AND "
"l.date_done IS NULL"
)
payment_line_ids = [x[0] for x in cr.fetchall()]
if payment_line_ids:
payment_lines = payment_line_obj.browse(cr, uid, payment_line_ids)
if has_payment:
payment_line_ids = payment_line_obj.search(
cr, uid, [
('order_id.state', '=', 'sent'),
('date_done', '=', False)], context=context)
payment_lines = payment_line_obj.browse(
cr, uid, payment_line_ids)
else:
payment_lines = False
# Start the loop over the transactions requested to match
transactions = self.browse(cr, uid, ids, context)
@@ -1123,7 +875,7 @@ class banking_import_transaction(osv.osv):
if (transaction.statement_line_id and
transaction.statement_line_id.state == 'confirmed'):
raise osv.except_osv(
raise orm.except_orm(
_("Cannot perform match"),
_("Cannot perform match on a confirmed transction"))
@@ -1171,7 +923,7 @@ class banking_import_transaction(osv.osv):
account_info = info[transaction.local_account][currency_code]
else:
# Pull account info/currency
account_info = get_company_bank_account(
account_info = banktools.get_company_bank_account(
self.pool, cr, uid, transaction.local_account,
transaction.local_currency, company, results['log']
)
@@ -1228,10 +980,9 @@ class banking_import_transaction(osv.osv):
continue
# Link accounting period
period_id = get_period(
self.pool, cr, uid,
str2date(transaction.effective_date,'%Y-%m-%d'), company,
results['log'])
period_id = banktools.get_period(
self.pool, cr, uid, transaction.effective_date,
company, results['log'])
if not period_id:
results['trans_skipped_cnt'] += 1
if not injected:
@@ -1270,10 +1021,10 @@ class banking_import_transaction(osv.osv):
# rebrowse the current record after writing
transaction = self.browse(cr, uid, transaction.id, context=context)
# Match full direct debit orders
if transaction.type == bt.DIRECT_DEBIT:
if transaction.type == bt.DIRECT_DEBIT and has_payment:
move_info = self._match_debit_order(
cr, uid, transaction, results['log'], context)
if transaction.type == bt.STORNO:
if transaction.type == bt.STORNO and has_payment:
move_info = self._match_storno(
cr, uid, transaction, results['log'], context)
# Allow inclusion of generated bank invoices
@@ -1290,7 +1041,7 @@ class banking_import_transaction(osv.osv):
partner_banks = []
else:
# Link remote partner, import account when needed
partner_banks = get_bank_accounts(
partner_banks = banktools.get_bank_accounts(
self.pool, cr, uid, transaction.remote_account,
results['log'], fail=True
)
@@ -1309,14 +1060,17 @@ class banking_import_transaction(osv.osv):
country_code = company.partner_id.country.code
else:
country_code = None
partner_id = get_or_create_partner(
partner_id = banktools.get_or_create_partner(
self.pool, cr, uid, transaction.remote_owner,
transaction.remote_owner_address,
transaction.remote_owner_postalcode,
transaction.remote_owner_city,
country_code, results['log'], context=context)
country_code, results['log'],
customer=transaction.transferred_amount > 0,
supplier=transaction.transferred_amount < 0,
context=context)
if transaction.remote_account:
partner_bank_id = create_bank_account(
partner_bank_id = banktools.create_bank_account(
self.pool, cr, uid, partner_id,
transaction.remote_account,
transaction.remote_owner,
@@ -1340,6 +1094,10 @@ class banking_import_transaction(osv.osv):
if (not move_info
and transaction.transferred_amount < 0 and payment_lines):
# Link open payment - if any
# Note that _match_payment is defined in the
# account_banking_payment module which should be installed
# automatically if account_payment is. And if account_payment
# is not installed, then payment_lines will be empty.
move_info = self._match_payment(
cr, uid, transaction,
payment_lines, partner_ids,
@@ -1385,28 +1143,12 @@ class banking_import_transaction(osv.osv):
self_values = {}
if move_info:
results['trans_matched_cnt'] += 1
self_values['match_type'] = move_info['match_type']
self_values['payment_line_id'] = move_info.get('payment_line_id', False)
self_values['move_line_ids'] = [(6, 0, move_info.get('move_line_ids') or [])]
self_values['invoice_ids'] = [(6, 0, move_info.get('invoice_ids') or [])]
self_values['payment_order_ids'] = [(6, 0, move_info.get('payment_order_ids') or [])]
self_values['payment_order_id'] = (move_info.get('payment_order_ids', False) and
len(move_info['payment_order_ids']) == 1 and
move_info['payment_order_ids'][0]
)
self_values['move_line_id'] = (move_info.get('move_line_ids', False) and
len(move_info['move_line_ids']) == 1 and
move_info['move_line_ids'][0]
)
if move_info['match_type'] == 'invoice':
self_values['invoice_id'] = (move_info.get('invoice_ids', False) and
len(move_info['invoice_ids']) == 1 and
move_info['invoice_ids'][0]
)
self_values.update(
self.move_info2values(move_info))
# values['match_type'] = move_info['match_type']
values['partner_id'] = move_info['partner_id']
values['partner_bank_id'] = move_info['partner_bank_id']
values['type'] = move_info['type']
# values['match_type'] = move_info['match_type']
else:
values['partner_id'] = values['partner_bank_id'] = False
if not values['partner_id'] and partner_ids and len(partner_ids) == 1:
@@ -1446,34 +1188,6 @@ class banking_import_transaction(osv.osv):
statement_obj.button_dummy(
cr, uid, imported_statement_ids, context=context)
if payment_lines:
# As payments lines are treated as individual transactions, the
# batch as a whole is only marked as 'done' when all payment lines
# have been reconciled.
cr.execute(
"SELECT DISTINCT o.id "
"FROM payment_order o, payment_line l "
"WHERE o.state = 'sent' "
"AND o.id = l.order_id "
"AND o.id NOT IN ("
"SELECT DISTINCT order_id AS id "
"FROM payment_line "
"WHERE date_done IS NULL "
"AND id IN (%s)"
")" % (','.join([str(x) for x in payment_line_ids]))
)
order_ids = [x[0] for x in cr.fetchall()]
if order_ids:
# Use workflow logics for the orders. Recode logic from
# account_payment, in order to increase efficiency.
payment_order_obj.set_done(cr, uid, order_ids,
{'state': 'done'}
)
wf_service = netsvc.LocalService('workflow')
for id in order_ids:
wf_service.trg_validate(
uid, 'payment.order', id, 'done', cr)
def _get_residual(self, cr, uid, ids, name, args, context=None):
"""
Calculate the residual against the candidate reconciliation.
@@ -1518,10 +1232,6 @@ class banking_import_transaction(osv.osv):
elif transaction.match_type == 'invoice':
if transaction.invoice_ids and not transaction.invoice_id:
res[transaction.id] = True
elif transaction.match_type == 'payment_order':
if (transaction.payment_order_ids and not
transaction.payment_order_id):
res[transaction.id] = True
return res
def clear_and_write(self, cr, uid, ids, vals=None, context=None):
@@ -1535,12 +1245,10 @@ class banking_import_transaction(osv.osv):
'invoice_id',
'manual_invoice_id',
'manual_move_line_id',
'payment_line_id',
]] +
[(x, [(6, 0, [])]) for x in [
'move_line_ids',
'invoice_ids',
'payment_order_ids',
]]))
write_vals.update(vals or {})
return self.write(cr, uid, ids, write_vals, context=context)
@@ -1639,29 +1347,22 @@ class banking_import_transaction(osv.osv):
'account.bank.statement.line', 'Statement line',
ondelete='CASCADE'),
'statement_id': fields.many2one(
'account.bank.statement', 'Statement'),
'account.bank.statement', 'Statement',
ondelete='CASCADE'),
'parent_id': fields.many2one(
'banking.import.transaction', 'Split off from this transaction'),
# match fields
'match_type': fields.selection(
[('manual', 'Manual'), ('move','Move'), ('invoice', 'Invoice'),
('payment', 'Payment'), ('payment_order', 'Payment order'),
('storno', 'Storno')],
'Match type'),
], 'Match type'),
'match_multi': fields.function(
_get_match_multi, method=True, string='Multi match',
type='boolean'),
'payment_order_ids': fields.many2many(
'payment.order', 'banking_transaction_payment_order_rel',
'order_id', 'transaction_id', 'Payment orders'),
'payment_order_id': fields.many2one(
'payment.order', 'Payment order to reconcile'),
'move_line_ids': fields.many2many(
'account.move.line', 'banking_transaction_move_line_rel',
'move_line_id', 'transaction_id', 'Matching entries'),
'move_line_id': fields.many2one(
'account.move.line', 'Entry to reconcile'),
'payment_line_id': fields.many2one('payment.line', 'Payment line'),
'invoice_ids': fields.many2many(
'account.invoice', 'banking_transaction_invoice_rel',
'invoice_id', 'transaction_id', 'Matching invoices'),
@@ -1685,7 +1386,7 @@ class banking_import_transaction(osv.osv):
"or reconcile it with the payment(s)"),
),
'writeoff_amount': fields.float('Difference Amount'),
# Legacy field: to be removed after 6.2
# Legacy field: to be removed after 7.0
'writeoff_move_line_id': fields.many2one(
'account.move.line', 'Write off move line'),
'writeoff_analytic_id': fields.many2one(
@@ -1703,7 +1404,8 @@ class banking_import_transaction(osv.osv):
banking_import_transaction()
class account_bank_statement_line(osv.osv):
class account_bank_statement_line(orm.Model):
_inherit = 'account.bank.statement.line'
_columns = {
'import_transaction_id': fields.many2one(
@@ -1722,9 +1424,8 @@ class account_bank_statement_line(osv.osv):
'match_type': fields.related(
'import_transaction_id', 'match_type', type='selection',
selection=[('manual', 'Manual'), ('move','Move'),
('invoice', 'Invoice'), ('payment', 'Payment'),
('payment_order', 'Payment order'),
('storno', 'Storno')],
('invoice', 'Invoice'),
],
string='Match type', readonly=True,),
'state': fields.selection(
[('draft', 'Draft'), ('confirmed', 'Confirmed')], 'State',
@@ -1775,21 +1476,20 @@ class account_bank_statement_line(osv.osv):
"""
statement_pool = self.pool.get('account.bank.statement')
obj_seq = self.pool.get('ir.sequence')
move_pool = self.pool.get('account.move')
import_transaction_obj = self.pool.get('banking.import.transaction')
for st_line in self.browse(cr, uid, ids, context):
if st_line.state != 'draft':
continue
if st_line.duplicate:
raise osv.except_osv(
raise orm.except_orm(
_('Bank transfer flagged as duplicate'),
_("You cannot confirm a bank transfer marked as a "
"duplicate (%s.%s)") %
(st_line.statement_id.name, st_line.name,))
if st_line.analytic_account_id:
if not st_line.statement_id.journal_id.analytic_journal_id:
raise osv.except_osv(
raise orm.except_orm(
_('No Analytic Journal !'),
_("You have to define an analytic journal on the '%s' "
"journal!") % (st_line.statement_id.journal_id.name,))
@@ -1833,7 +1533,6 @@ class account_bank_statement_line(osv.osv):
ids = [ids]
import_transaction_obj = self.pool.get('banking.import.transaction')
move_pool = self.pool.get('account.move')
transaction_cancel_ids = []
set_draft_ids = []
move_unlink_ids = []
# harvest ids for various actions
@@ -1841,7 +1540,7 @@ class account_bank_statement_line(osv.osv):
if st_line.state != 'confirmed':
continue
if st_line.statement_id.state != 'draft':
raise osv.except_osv(
raise orm.except_orm(
_("Cannot cancel bank transaction"),
_("The bank statement that this transaction belongs to has "
"already been confirmed"))
@@ -1876,10 +1575,10 @@ class account_bank_statement_line(osv.osv):
ids = [ids]
for line in self.browse(cr, uid, ids, context=context):
if line.state == 'confirmed':
raise osv.except_osv(
raise orm.except_orm(
_('Confirmed Statement Line'),
_("You cannot delete a confirmed Statement Line"
": '%s'" % line.name))
": '%s'") % line.name)
return super(account_bank_statement_line, self).unlink(
cr, uid, ids, context=context)
@@ -1921,7 +1620,8 @@ class account_bank_statement_line(osv.osv):
account_bank_statement_line()
class account_bank_statement(osv.osv):
class account_bank_statement(orm.Model):
_inherit = 'account.bank.statement'
def _end_balance(self, cursor, user, ids, name, attr, context=None):
@@ -1957,19 +1657,21 @@ class account_bank_statement(osv.osv):
self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
if (not st.journal_id.default_credit_account_id) \
or (not st.journal_id.default_debit_account_id):
raise osv.except_osv(_('Configuration Error !'),
raise orm.except_orm(_('Configuration Error !'),
_('Please verify that an account is defined in the journal.'))
# protect against misguided manual changes
for line in st.move_line_ids:
if line.state != 'valid':
raise osv.except_osv(_('Error !'),
raise orm.except_orm(_('Error !'),
_('The account entries lines are not in valid state.'))
line_obj.confirm(cr, uid, [line.id for line in st.line_ids], context)
st.refresh()
self.log(cr, uid, st.id, _('Statement %s is confirmed, journal '
'items are created.') % (st.name,))
self.message_post(
cr, uid, [st.id],
body=_('Statement %s confirmed, journal items were created.')
% (st.name,), context=context)
return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
@@ -1988,8 +1690,12 @@ class account_bank_statement(osv.osv):
for st in self.browse(cr, uid, ids, context=context):
for line in st.line_ids:
if line.state == 'confirmed':
raise osv.except_osv(_('Confirmed Statement Lines'), _("You cannot delete a Statement with confirmed Statement Lines: '%s'" % st.name))
return super(account_bank_statement,self).unlink(cr, uid, ids, context=context)
raise orm.except_orm(
_('Confirmed Statement Lines'),
_("You cannot delete a Statement with confirmed "
"Statement Lines: '%s'") % st.name)
return super(account_bank_statement, self).unlink(
cr, uid, ids, context=context)
_columns = {
# override this field *only* to replace the

View File

@@ -20,12 +20,5 @@
<record id="base_iban.bank_swift_field" model="res.partner.bank.type.field">
<field eval="False" name="required"/>
</record>
<!-- Add manual bank transfer as default payment option -->
<record model="payment.mode.type" id="account_banking.manual_bank_tranfer">
<field name="name">Manual Bank Transfer</field>
<field name="code">BANKMAN</field>
<field name="suitable_bank_types"
eval="[(6,0,[ref('base.bank_normal'),ref('base_iban.bank_iban'),])]" />
</record>
</data>
</openerp>

View File

@@ -4,16 +4,16 @@
# Copyright (C) 2011 Therp BV (<http://therp.nl>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -1,20 +1,20 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -2,6 +2,5 @@
"access_account_banking_settings","account.banking.account.settings","model_account_banking_account_settings","account.group_account_manager",1,1,1,1
"access_account_banking_settings_user","account.banking.account.settings user","model_account_banking_account_settings","account.group_account_user",1,0,0,0
"access_account_banking_import","account.bankimport","model_account_banking_imported_file","account.group_account_user",1,1,1,1
"access_payment_mode_type","payment.mode.type","model_payment_mode_type","account_payment.group_account_payment",1,1,1,1
"access_banking_import_transaction","Banking addons - Bank import transaction","model_banking_import_transaction","account.group_account_user",1,1,1,1
"access_banking_transaction_wizard","Banking addons - Transaction wizard","model_banking_transaction_wizard","account.group_account_user",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_account_banking_settings account.banking.account.settings model_account_banking_account_settings account.group_account_manager 1 1 1 1
3 access_account_banking_settings_user account.banking.account.settings user model_account_banking_account_settings account.group_account_user 1 0 0 0
4 access_account_banking_import account.bankimport model_account_banking_imported_file account.group_account_user 1 1 1 1
access_payment_mode_type payment.mode.type model_payment_mode_type account_payment.group_account_payment 1 1 1 1
5 access_banking_import_transaction Banking addons - Bank import transaction model_banking_import_transaction account.group_account_user 1 1 1 1
6 access_banking_transaction_wizard Banking addons - Transaction wizard model_banking_transaction_wizard account.group_account_user 1 1 1 1

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,22 +5,20 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 bank_import
import bank_payment_manual
import account_payment_order
import banking_transaction_wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################
@@ -28,19 +28,15 @@ This module contains the business logic of the wizard account_banking_import.
The parsing is done in the parser modules. Every parser module is required to
use parser.models as a mean of communication with the business logic.
'''
from osv import osv, fields
import time
import netsvc
from osv import orm, fields
import base64
import datetime
from tools import config
from tools.translate import _
from account_banking.parsers import models
from account_banking.parsers.convert import *
from account_banking.struct import struct
from account_banking import sepa
from banktools import *
import decimal_precision as dp
from openerp.tools.translate import _
from openerp.addons.account_banking.parsers import models
from openerp.addons.account_banking.parsers import convert
from openerp.addons.account_banking.struct import struct
from openerp.addons.account_banking.wizard import banktools
from openerp.addons.decimal_precision import decimal_precision as dp
bt = models.mem_bank_transaction
@@ -54,7 +50,8 @@ def parser_types(*args, **kwargs):
'''
return models.parser_type.get_parser_types()
class banking_import_line(osv.osv_memory):
class banking_import_line(orm.TransientModel):
_name = 'banking.import.line'
_description = 'Bank import lines'
_columns = {
@@ -85,23 +82,19 @@ class banking_import_line(osv.osv_memory):
'invoice_ids': fields.many2many(
'account.invoice', 'banking_import_line_invoice_rel',
'line_id', 'invoice_id'),
'payment_order_id': fields.many2one('payment.order', 'Payment order'),
'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account'),
'transaction_type': fields.selection([
# TODO: payment terminal etc...
('invoice', 'Invoice payment'),
('payment_order_line', 'Payment from a payment order'),
('payment_order', 'Aggregate payment order'),
('storno', 'Canceled debit order'),
('bank_costs', 'Bank costs'),
('unknown', 'Unknown'),
], 'Transaction type'),
'duplicate': fields.boolean('Duplicate'),
}
banking_import_line()
class banking_import(osv.osv_memory):
class banking_import(orm.TransientModel):
_name = 'account.banking.bank.import'
def import_statements_file(self, cursor, uid, ids, context):
@@ -124,7 +117,7 @@ class banking_import(osv.osv_memory):
parser_code = banking_import.parser
parser = models.create_parser(parser_code)
if not parser:
raise osv.except_osv(
raise orm.except_orm(
_('ERROR!'),
_('Unable to import parser %(parser)s. Parser class not found.') %
{'parser': parser_code}
@@ -138,7 +131,7 @@ class banking_import(osv.osv_memory):
statements = parser.parse(cursor, data)
if any([x for x in statements if not x.is_valid()]):
raise osv.except_osv(
raise orm.except_orm(
_('ERROR!'),
_('The imported statements appear to be invalid! Check your file.')
)
@@ -190,7 +183,7 @@ class banking_import(osv.osv_memory):
else:
# Pull account info/currency
account_info = get_company_bank_account(
account_info = banktools.get_company_bank_account(
self.pool, cursor, uid, statement.local_account,
statement.local_currency, company, results.log
)
@@ -247,7 +240,7 @@ class banking_import(osv.osv_memory):
# matching procedure
statement_ids = statement_obj.search(cursor, uid, [
('name', '=', statement.id),
('date', '=', date2str(statement.date)),
('date', '=', convert.date2str(statement.date)),
])
if statement_ids:
results.log.append(
@@ -258,11 +251,14 @@ class banking_import(osv.osv_memory):
continue
# Get the period for the statement (as bank statement object checks this)
period_ids = period_obj.search(cursor, uid, [('company_id','=',company.id),
('date_start','<=',statement.date),
('date_stop','>=',statement.date),
('special', '=', False)])
period_ids = period_obj.search(
cursor, uid, [
('company_id', '=', company.id),
('date_start', '<=', statement.date),
('date_stop', '>=', statement.date),
('special', '=', False),
], context=context)
if not period_ids:
results.log.append(
_('No period found covering statement date %(date)s, '
@@ -277,7 +273,7 @@ class banking_import(osv.osv_memory):
statement_id = statement_obj.create(cursor, uid, dict(
name = statement.id,
journal_id = account_info.journal_id.id,
date = date2str(statement.date),
date = convert.date2str(statement.date),
balance_start = statement.start_balance,
balance_end_real = statement.end_balance,
balance_end = statement.end_balance,
@@ -305,11 +301,9 @@ class banking_import(osv.osv_memory):
values['local_account'] = statement.local_account
values['local_currency'] = statement.local_currency
transaction_id = import_transaction_obj.create(cursor, uid, values, context=context)
if transaction_id:
transaction_ids.append(transaction_id)
else:
osv.except_osv('Failed to create an import transaction resource','')
transaction_id = import_transaction_obj.create(
cursor, uid, values, context=context)
transaction_ids.append(transaction_id)
results.stat_loaded_cnt += 1
@@ -425,7 +419,6 @@ class banking_import(osv.osv_memory):
'State', readonly=True),
'import_id': fields.many2one(
'account.banking.imported.file', 'Import File'),
# osv_memory does not seem to support one2many
'statement_ids': fields.many2many(
'account.bank.statement', 'rel_wiz_statements', 'wizard_id',
'statement_id', 'Imported Bank Statements'),
@@ -445,7 +438,3 @@ class banking_import(osv.osv_memory):
cr, uid, 'bank.import.transaction', context=c),
'parser': _default_parser_type,
}
banking_import()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,53 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
'''
This module contains a single "wizard" for including a 'sent' state for manual
bank transfers.
'''
import wizard
import pooler
class payment_manual(wizard.interface):
def _action_set_state_sent(self, cursor, uid, data, context):
'''
Set the payment order in state 'sent' to reflect money in transfer.
'''
payment_order_obj = pooler.get_pool(cursor.dbname)\
.get('payment.order')
payment_order_obj.action_sent(cursor, uid, [data['id']], context)
return {}
states= {
'init' : {
'actions': [],
'result': {
'type':'action',
'action': _action_set_state_sent,
'state': 'end'
}
}
}
payment_manual('account_banking.payment_manual')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -2,25 +2,26 @@
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 Therp BV (<http://therp.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
# (C) 2011 Smile (<http://smile.fr>).
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 osv, fields
from osv import orm, fields
from openerp.tools.translate import _
"""
@@ -31,7 +32,8 @@ multiple matches or select a manual match.
"""
class banking_transaction_wizard(osv.osv_memory):
class banking_transaction_wizard(orm.TransientModel):
_name = 'banking.transaction.wizard'
_description = 'Match transaction'
@@ -78,7 +80,7 @@ class banking_transaction_wizard(osv.osv_memory):
cr, uid, ids[0], ['import_transaction_id'],
context=context)['import_transaction_id'][0] # many2one tuple
import_transaction_obj.match(cr, uid, [trans_id], context=context)
return True
return self.create_act_window(cr, uid, ids, context=None)
def write(self, cr, uid, ids, vals, context=None):
"""
@@ -162,7 +164,7 @@ class banking_transaction_wizard(osv.osv_memory):
# transaction_obj.write(
# cr, uid, wiz.import_transaction_id.id,
# { 'invoice_id': False, }, context=context)
osv.except_osv(
orm.except_orm(
_("No entry found for the selected invoice"),
_("No entry found for the selected invoice. " +
"Try manual reconciliation."))
@@ -184,7 +186,7 @@ class banking_transaction_wizard(osv.osv_memory):
move_line_id = line.id
break
if not move_line_id:
osv.except_osv(
orm.except_orm(
_("Cannot select for reconcilion"),
_("No entry found for the selected invoice. "))
else:
@@ -222,7 +224,7 @@ class banking_transaction_wizard(osv.osv_memory):
"""
Just a button that triggers a write.
"""
return True
return self.create_act_window(cr, uid, ids, context=None)
def disable_match(self, cr, uid, ids, context=None):
"""
@@ -255,7 +257,7 @@ class banking_transaction_wizard(osv.osv_memory):
if x['import_transaction_id']]
self.pool.get('banking.import.transaction').clear_and_write(
cr, uid, trans_ids, context=context)
return True
return self.create_act_window(cr, uid, ids, context=None)
def reverse_duplicate(self, cr, uid, ids, context=None):
if isinstance(ids, (int, float)):
@@ -267,7 +269,7 @@ class banking_transaction_wizard(osv.osv_memory):
transaction_obj.write(
cr, uid, wiz['import_transaction_id'][0],
{'duplicate': not wiz['duplicate']}, context=context)
return True
return self.create_act_window(cr, uid, ids, context=None)
def _get_default_match_type(self, cr, uid, context=None):
"""
@@ -320,15 +322,6 @@ class banking_transaction_wizard(osv.osv_memory):
'import_transaction_id', 'writeoff_journal_id',
type='many2one', relation='account.journal',
string='Write-off journal'),
'payment_line_id': fields.related(
'import_transaction_id', 'payment_line_id', string="Matching payment or storno",
type='many2one', relation='payment.line', readonly=True),
'payment_order_ids': fields.related(
'import_transaction_id', 'payment_order_ids', string="Matching payment orders",
type='many2many', relation='payment.order'),
'payment_order_id': fields.related(
'import_transaction_id', 'payment_order_id', string="Payment order to reconcile",
type='many2one', relation='payment.order'),
'invoice_ids': fields.related(
'import_transaction_id', 'invoice_ids', string="Matching invoices",
type='many2many', relation='account.invoice'),

View File

@@ -8,7 +8,6 @@
<field name="arch" type="xml">
<form string="Match transaction">
<!-- fields used for form logic -->
<field name="payment_order_ids" invisible="True"/>
<field name="invoice_ids" invisible="True"/>
<field name="move_line_ids" invisible="True"/>
<field name="match_multi" invisible="True"/>
@@ -36,9 +35,6 @@
<separator string="Multiple matches" colspan="2"/>
<label colspan="2" string="Multiple matches were found for this bank transfer. You must pick one of the matches or select a match manually below." />
</group>
<field name='payment_line_id'
attrs="{'invisible': [('match_type', '!=', 'storno'),('match_type', '!=', 'payment')]}"
/>
<group attrs="{'readonly': [('match_multi', '!=', True)]}" col="8">
<!-- show if we have an invoice type match (but the user may need to select from multiple options)
or whenever there is an invoice_id (e.g. in case of a manual match)
@@ -53,10 +49,6 @@
attrs="{'readonly': [('match_multi', '=', False)], 'invisible': [('match_type', '!=', 'move'),('invoice_id', '=', False)]}"
domain="[('id', 'in', move_line_ids[0][2])]"
/>
<field name='payment_order_id'
attrs="{'readonly': [('match_multi', '=', False)], 'invisible': [('match_type', '!=', 'payment_order')]}"
domain="[('id', 'in', payment_order_ids[0][2])]"
/>
<field name='analytic_account_id' />
</group>
<button colspan="1"

View File

@@ -1,29 +1,27 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 datetime
from tools.translate import _
from account_banking.parsers import convert
from account_banking import sepa
from account_banking.struct import struct
from openerp.tools.translate import _
from openerp.addons.account_banking import sepa
from openerp.addons.account_banking.struct import struct
__all__ = [
'get_period',
@@ -33,54 +31,23 @@ __all__ = [
'create_bank_account',
]
def get_period(pool, cursor, uid, date, company, log):
def get_period(pool, cr, uid, date, company, log=None):
'''
Get a suitable period for the given date range and the given company.
Wrapper over account_period.find() to log exceptions of
missing periods instead of raising.
'''
fiscalyear_obj = pool.get('account.fiscalyear')
period_obj = pool.get('account.period')
if not date:
date = convert.date2str(datetime.datetime.today())
search_date = convert.date2str(date)
fiscalyear_ids = fiscalyear_obj.search(cursor, uid, [
('date_start','<=', search_date), ('date_stop','>=', search_date),
('state','=','draft'), ('company_id','=',company.id)
])
if not fiscalyear_ids:
fiscalyear_ids = fiscalyear_obj.search(cursor, uid, [
('date_start','<=',search_date), ('date_stop','>=',search_date),
('state','=','draft'), ('company_id','=',None)
])
if not fiscalyear_ids:
log.append(
_('No suitable fiscal year found for date %(date)s and company %(company_name)s')
% dict(company_name=company.name, date=date)
)
return False
elif len(fiscalyear_ids) > 1:
log.append(
_('Multiple overlapping fiscal years found for date %(date)s and company %(company_name)s')
% dict(company_name=company.name, date=date)
)
return False
fiscalyear_id = fiscalyear_ids[0]
period_ids = period_obj.search(cursor, uid, [
('date_start','<=',search_date), ('date_stop','>=',search_date),
('fiscalyear_id','=',fiscalyear_id), ('state','=','draft'),
('special', '=', False),
])
if not period_ids:
log.append(_('No suitable period found for date %(date)s and company %(company_name)s')
% dict(company_name=company.name, date=date)
)
return False
if len(period_ids) != 1:
log.append(_('Multiple overlapping periods for date %(date)s and company %(company_name)s')
% dict(company_name=company.name, date=date)
)
return False
context = {'account_period_prefer_normal': True}
if company:
context['company_id'] = company.id
try:
period_ids = pool.get('account.period').find(
cr, uid, dt=date, context=context)
except Exception, e:
if log is None:
raise
else:
log.append(e)
return False
return period_ids[0]
def get_bank_accounts(pool, cursor, uid, account_number, log, fail=False):
@@ -119,7 +86,8 @@ def _has_attr(obj, attr):
return False
def get_or_create_partner(pool, cr, uid, name, address, postal_code, city,
country_code, log, context=None):
country_code, log, supplier=False, customer=False,
context=None):
'''
Get or create the partner belonging to the account holders name <name>
@@ -141,11 +109,11 @@ def get_or_create_partner(pool, cr, uid, name, address, postal_code, city,
cr, uid, [('code', '=', country_code.upper())],
context=context)
country_id = country_ids and country_ids[0] or False
criteria.append(('address.country_id', '=', country_id))
criteria.append(('country_id', '=', country_id))
if city:
criteria.append(('address.city', 'ilike', city))
criteria.append(('city', 'ilike', city))
if postal_code:
criteria.append(('address.zip', 'ilike', postal_code))
criteria.append(('zip', 'ilike', postal_code))
partner_search_ids = partner_obj.search(
cr, uid, criteria, context=context)
key = name.lower()
@@ -164,16 +132,20 @@ def get_or_create_partner(pool, cr, uid, name, address, postal_code, city,
user.company_id.partner_id.country.id or
False
)
partner_id = partner_obj.create(cr, uid, dict(
name=name, active=True,
comment='Generated from Bank Statements Import',
address=[(0,0,{
partner_id = partner_obj.create(
cr, uid, {
'name': name,
'active': True,
'comment': 'Generated from Bank Statements Import',
'street': address and address[0] or '',
'street2': len(address) > 1 and address[1] or '',
'city': city,
'zip': postal_code or '',
'country_id': country_id,
})]), context=context)
'is_company': True,
'supplier': supplier,
'customer': customer,
}, context=context)
else:
if len(partner_ids) > 1:
log.append(

View File

@@ -12,16 +12,16 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -11,23 +11,23 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 Banking PATU module',
'version': '0.62',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'Sami Haahtinen',
'website': 'http://ressukka.net',
'category': 'Account Banking',

View File

@@ -6,16 +6,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -1,31 +1,2 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
# and Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
import abnamro
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,43 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
# and Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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': 'abnamro (NL) Bank Statements Import',
'version': '0.1',
'license': 'GPL-3',
'author': 'Therp BV / EduSense BV',
'website': 'https://launchpad.net/account-banking',
'category': 'Account Banking',
'license': 'AGPL-3',
'author': ['Therp BV', 'EduSense BV'],
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
#'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Import filter for abnamro (NL) bank transaction files (txt/tab format).
@@ -48,6 +38,5 @@ https://launchpad.net/account-banking.
Imported bank transfers are organized in statements covering periods of one week,
even if the imported files cover a different period.
''',
'active': False,
'installable': False,
'installable': True,
}

View File

@@ -1,53 +0,0 @@
##############################################################################
#
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
# and Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'abnamro (NL) Bank Statements Import',
'version': '0.62',
'license': 'GPL-3',
'author': 'Therp BV / EduSense BV',
'website': 'https://launchpad.net/account-banking',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
#'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Import filter for abnamro (NL) bank transaction files (txt/tab format).
No formal specifications of the file layout are released by abnamro. You can
help improve the performance of this import filter on
https://launchpad.net/account-banking.
Imported bank transfers are organized in statements covering periods of one week,
even if the imported files cover a different period.
''',
'active': False,
'installable': True,
}

View File

@@ -1,21 +1,22 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>)
# 2011 Therp BV (<http://therp.nl>)
#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################
@@ -28,11 +29,11 @@ Dutch Banking Tools uses the concept of 'Afschrift' or Bank Statement.
Every transaction is bound to a Bank Statement. As such, this module generates
Bank Statements along with Bank Transactions.
'''
from account_banking.parsers import models
from account_banking.parsers.convert import str2date
from account_banking.sepa import postalcode
from tools.translate import _
from osv import osv
from openerp.addons.account_banking.parsers import models
from openerp.addons.account_banking.parsers.convert import str2date
from openerp.addons.account_banking.sepa import postalcode
from openerp.tools.translate import _
from openerp.osv import orm
import re
import csv
@@ -120,7 +121,7 @@ class transaction(models.mem_bank_transaction):
self.error_message = _('No remote account for transaction type '
'%s') % self.transfer_type
if self.error_message:
raise osv.except_osv(_('Error !'), _(self.error_message))
raise orm.except_orm(_('Error !'), _(self.error_message))
return not self.error_message
def parse_message(self):
@@ -223,7 +224,7 @@ class transaction(models.mem_bank_transaction):
remote_account = account_match.group(1).zfill(10)
remote_owner = account_match.group(2).strip() or ''
else:
raise osv.except_osv(
raise orm.except_orm(
_('Error !'),
_('unable to parse GIRO string: %s') % field)
elif field.startswith('BEA '):

View File

@@ -11,16 +11,16 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -3,48 +3,39 @@
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 Banking NL ClieOp',
'version': '0.92',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
'depends': ['account_banking_payment'],
'data': [
'account_banking_nl_clieop.xml',
'wizard/export_clieop_view.xml',
'data/banking_export_clieop.xml',
'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Module to export payment orders in ClieOp format.
ClieOp format is used by Dutch banks to batch national bank transfers.
This module uses the account_banking logic.
''',
'active': False,
'installable': True,
'installable': False,
}

View File

@@ -4,16 +4,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -4,16 +4,16 @@
# Copyright (C) 2011 Therp BV (<http://therp.nl>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -4,16 +4,16 @@
# Copyright (C) 2011 Therp BV (<http://therp.nl>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -11,16 +11,16 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -3,44 +3,35 @@
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 Banking - Girotel',
'version': '0.62',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
'data': [
#'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Module to import Dutch Girotel format transation files.
This modules contains no logic, just an import filter for account_banking.
''',
'active': False,
'installable': True,
}

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -1,4 +1,2 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
import ing
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -8,39 +8,29 @@
#
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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': 'ING (NL) Bank Statements Import',
'version': '0.1.140',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': ['Smile', 'Therp BV', 'EduSense BV'],
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
],
'demo_xml': [],
'description': '''
Module to import Dutch ING bank format transaction files. The format covered
is the CSV format with either 'dd-mm-yyyy' or 'yyyymmdd' date syntax.
@@ -57,6 +47,5 @@ of one week, even if the imported files cover a different period.
This modules contains no logic, just an import filter for account_banking.
''',
'active': False,
'installable': False,
'installable': True,
}

View File

@@ -1,58 +0,0 @@
##############################################################################
#
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
# and Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'ING (NL) Bank Statements Import',
'version': '0.1.89',
'license': 'GPL-3',
'author': 'Smile / Therp BV / EduSense BV',
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
],
'demo_xml': [],
'description': '''
Module to import Dutch ING bank format transation files (CSV format).
As the ING bank does not provide detailed specification concerning possible
values and their meaning for the fields in the CSV file format, the statements
are parsed according to an educated guess based on incomplete information.
You can contact the banking-addons developers through their launchpad page and
help improve the performance of this import filter on
https://launchpad.net/banking-addons.
Note that imported bank transfers are organized in statements covering periods
of one week, even if the imported files cover a different period.
This modules contains no logic, just an import filter for account_banking.
''',
'active': False,
'installable': True,
}

View File

@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2011 Smile (<http://smile.fr>).
@@ -10,25 +10,25 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 datetime import datetime
from account_banking.parsers import models
from account_banking.parsers.convert import str2date
from account_banking.sepa import postalcode
from tools.translate import _
from openerp.addons.account_banking.parsers import models
from openerp.addons.account_banking.parsers.convert import str2date
from openerp.addons.account_banking.sepa import postalcode
from openerp.tools.translate import _
import re
import csv

View File

@@ -11,16 +11,16 @@
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -1,46 +1,36 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 Banking',
'version': '0.62',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'EduSense BV',
'website': 'http://www.edusense.nl',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
#'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Module to import Dutch Multibank format transation files.
This modules contains no logic, just an import filter for account_banking.
''',
'active': False,
'installable': True,
}

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -13,16 +13,16 @@
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -4,40 +4,28 @@
# and Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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': 'Triodos (NL) Bank Statements Import',
'version': '0.92',
'license': 'GPL-3',
'author': 'Therp BV / EduSense BV',
'license': 'AGPL-3',
'author': ['Therp BV', 'EduSense BV'],
'website': 'https://launchpad.net/account-banking',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
#'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Module to import Dutch Triodos bank format transation files (CSV format).
@@ -53,6 +41,5 @@ of one week, even if the imported files cover a different period.
This modules contains no logic, just an import filter for account_banking.
''',
'active': False,
'installable': False,
'installable': True,
}

View File

@@ -1,58 +0,0 @@
##############################################################################
#
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
# and Therp BV (<http://therp.nl>)
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
# or Therp BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Triodos (NL) Bank Statements Import',
'version': '0.62',
'license': 'GPL-3',
'author': 'Therp BV / EduSense BV',
'website': 'https://launchpad.net/account-banking',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
#'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Module to import Dutch Triodos bank format transation files (CSV format).
As the Triodos bank does not provide detailed specification concerning possible
values and their meaning for the fields in the CSV file format, the statements
are parsed according to an educated guess based on incomplete information.
You can contact the account-banking developers through their launchpad page and
help improve the performance of this import filter on
https://launchpad.net/account-banking.
Note that imported bank transfers are organized in statements covering periods
of one week, even if the imported files cover a different period.
This modules contains no logic, just an import filter for account_banking.
''',
'active': False,
'installable': True,
}

View File

@@ -6,16 +6,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -0,0 +1 @@
import model

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 Banking - Payments',
'version': '0.1.164',
'license': 'AGPL-3',
'author': 'Banking addons community',
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': [
'account_banking',
'account_payment',
],
'data': [
'view/account_payment.xml',
'view/banking_transaction_wizard.xml',
'view/payment_mode_type.xml',
'view/bank_payment_manual.xml',
'data/payment_mode_type.xml',
'workflow/account_payment.xml',
'security/ir.model.access.csv',
],
'description': '''
This addon adds payment infrastructure to the Banking Addons.
* Extends payments for digital banking:
+ Adapted workflow in payments to reflect banking operations
+ Relies on account_payment mechanics to extend with export generators.
- ClieOp3 (NL) payment and direct debit orders files available as
account_banking_nl_clieop
''',
'auto_install': True,
'installable': False,
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Add manual bank transfer as default payment option -->
<record model="payment.mode.type" id="account_banking.manual_bank_tranfer">
<field name="name">Manual Bank Transfer</field>
<field name="code">BANKMAN</field>
<field name="suitable_bank_types"
eval="[(6,0,[ref('base.bank_normal'),ref('base_iban.bank_iban'),])]" />
<field name="ir_model_id"
ref="account_banking_payment.model_payment_manual"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,10 @@
import account_payment
import payment_line
import payment_mode
import payment_mode_type
import payment_order_create
import banking_import_transaction
import account_bank_statement_line
import banking_transaction_wizard
import bank_payment_manual
import banking_import_line

View File

@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 account_bank_statement_line(orm.Model):
_inherit = 'account.bank.statement.line'
_columns = {
'match_type': fields.related(
# Add payment and storno types
'import_transaction_id', 'match_type', type='selection',
selection=[('manual', 'Manual'), ('move','Move'),
('invoice', 'Invoice'), ('payment', 'Payment'),
('payment_order', 'Payment order'),
('storno', 'Storno')],
string='Match type', readonly=True,),
}

View File

@@ -0,0 +1,240 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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
from openerp.tools.translate import _
from openerp import netsvc
class payment_order(orm.Model):
'''
Enable extra states for payment exports
'''
_inherit = 'payment.order'
_columns = {
'date_scheduled': fields.date(
'Scheduled date if fixed',
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
help='Select a date if you have chosen Preferred Date to be fixed.'
),
'reference': fields.char(
'Reference', size=128, required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'mode': fields.many2one(
'payment.mode', 'Payment mode', select=True, required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
help='Select the Payment Mode to be applied.',
),
'state': fields.selection([
('draft', 'Draft'),
('open','Confirmed'),
('cancel','Cancelled'),
('sent', 'Sent'),
('rejected', 'Rejected'),
('done','Done'),
], 'State', select=True
),
'line_ids': fields.one2many(
'payment.line', 'order_id', 'Payment lines',
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'user_id': fields.many2one(
'res.users','User', required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'date_prefered': fields.selection([
('now', 'Directly'),
('due', 'Due date'),
('fixed', 'Fixed date')
], "Preferred date", change_default=True, required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
help=("Choose an option for the Payment Order:'Fixed' stands for a "
"date specified by you.'Directly' stands for the direct "
"execution.'Due date' stands for the scheduled date of "
"execution."
)
),
'payment_order_type': fields.selection(
[('payment', 'Payment'),('debit', 'Direct debit')],
'Payment order type', required=True,
),
'date_sent': fields.date('Send date', readonly=True),
}
_defaults = {
'payment_order_type': 'payment',
}
def launch_wizard(self, cr, uid, ids, context=None):
"""
Search for a wizard to launch according to the type.
If type is manual. just confirm the order.
Previously (pre-v6) in account_payment/wizard/wizard_pay.py
"""
if context == None:
context = {}
result = {}
orders = self.browse(cr, uid, ids, context)
order = orders[0]
# check if a wizard is defined for the first order
if order.mode.type and order.mode.type.ir_model_id:
context['active_ids'] = ids
wizard_model = order.mode.type.ir_model_id.model
wizard_obj = self.pool.get(wizard_model)
wizard_id = wizard_obj.create(cr, uid, {}, context)
result = {
'name': wizard_obj._description or _('Payment Order Export'),
'view_type': 'form',
'view_mode': 'form',
'res_model': wizard_model,
'domain': [],
'context': context,
'type': 'ir.actions.act_window',
'target': 'new',
'res_id': wizard_id,
'nodestroy': True,
}
else:
# should all be manual orders without type or wizard model
for order in orders[1:]:
if order.mode.type and order.mode.type.ir_model_id:
raise orm.except_orm(
_('Error'),
_('You can only combine payment orders of the same type')
)
# process manual payments
wf_service = netsvc.LocalService('workflow')
for order_id in ids:
wf_service.trg_validate(uid, 'payment.order', order_id, 'sent', cr)
return result
def _write_payment_lines(self, cr, uid, ids, **kwargs):
'''
ORM method for setting attributes of corresponding payment.line objects.
Note that while this is ORM compliant, it is also very ineffecient due
to the absence of filters on writes and hence the requirement to
filter on the client(=OpenERP server) side.
'''
if not hasattr(ids, '__iter__'):
ids = [ids]
payment_line_obj = self.pool.get('payment.line')
line_ids = payment_line_obj.search(
cr, uid, [
('order_id', 'in', ids)
])
payment_line_obj.write(cr, uid, line_ids, kwargs)
def set_to_draft(self, cr, uid, ids, *args):
'''
Set both self and payment lines to state 'draft'.
'''
self._write_payment_lines(cr, uid, ids, export_state='draft')
return super(payment_order, self).set_to_draft(
cr, uid, ids, *args
)
def action_sent(self, cr, uid, ids, context=None):
'''
Set both self and payment lines to state 'sent'.
'''
self._write_payment_lines(cr, uid, ids, export_state='sent')
self.write(cr, uid, ids, {
'state': 'sent',
'date_sent': fields.date.context_today(
self, cr, uid, context=context),
}, context=context)
return True
def action_rejected(self, cr, uid, ids, *args):
'''
Set both self and payment lines to state 'rejected'.
'''
self._write_payment_lines(cr, uid, ids, export_state='rejected')
wf_service = netsvc.LocalService('workflow')
for id in ids:
wf_service.trg_validate(uid, 'payment.order', id, 'rejected', cr)
return True
def set_done(self, cr, uid, ids, *args):
'''
Extend standard transition to update children as well.
'''
self._write_payment_lines(
cr, uid, ids,
export_state='done',
date_done=fields.date.context_today(self, cr, uid))
return super(payment_order, self).set_done(
cr, uid, ids, *args
)
"""
Hooks for processing direct debit orders, such as implemented in
account_direct_debit module.
"""
def debit_reconcile_transfer(
self, cr, uid, payment_order_id, amount, currency, context=None):
"""
Reconcile the payment order if the amount is correct. Return the
id of the reconciliation.
"""
raise orm.except_orm(
_("Cannot reconcile"),
_("Cannot reconcile debit order: "+
"Not implemented."))
def debit_unreconcile_transfer(
self, cr, uid, payment_order_id, reconcile_id, amount, currency,
context=None):
""" Unreconcile the payment_order if at all possible """
raise orm.except_orm(
_("Cannot unreconcile"),
_("Cannot unreconcile debit order: "+
"Not implemented."))

View File

@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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/>.
#
##############################################################################
'''
This module contains a single "wizard" for including a 'sent' state for manual
bank transfers.
'''
from openerp.osv import orm, fields
from openerp import netsvc
class payment_manual(orm.TransientModel):
_name = 'payment.manual'
_description = 'Set payment orders to \'sent\' manually'
def default_get(self, cr, uid, fields_list, context=None):
if context and context.get('active_ids'):
payment_order_obj = self.pool.get('payment.order')
wf_service = netsvc.LocalService('workflow')
for order_id in context['active_ids']:
wf_service.trg_validate(
uid, 'payment.order', order_id, 'sent', cr)
return super(payment_manual, self).default_get(
cr, uid, fields_list, context=None)
_columns = {
# dummy field, to trigger a call to default_get
'name': fields.char('Name', size=1),
}

View File

@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 banking_import_line(orm.TransientModel):
_inherit = 'banking.import.line'
_columns = {
'payment_order_id': fields.many2one(
'payment.order', 'Payment order'),
'transaction_type': fields.selection([
# Add payment order related transaction types
('invoice', 'Invoice payment'),
('payment_order_line', 'Payment from a payment order'),
('payment_order', 'Aggregate payment order'),
('storno', 'Canceled debit order'),
('bank_costs', 'Bank costs'),
('unknown', 'Unknown'),
], 'Transaction type'),
}

View File

@@ -0,0 +1,388 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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
from openerp import netsvc
from openerp.tools.translate import _
from openerp.addons.decimal_precision import decimal_precision as dp
class banking_import_transaction(orm.Model):
_inherit = 'banking.import.transaction'
def _match_debit_order(
self, cr, uid, trans, log, context=None):
def is_zero(total):
return self.pool.get('res.currency').is_zero(
cr, uid, trans.statement_id.currency, total)
payment_order_obj = self.pool.get('payment.order')
order_ids = payment_order_obj.search(
cr, uid, [('payment_order_type', '=', 'debit'),
('state', '=', 'sent'),
('date_sent', '<=', trans.execution_date),
],
limit=0, context=context)
orders = payment_order_obj.browse(cr, uid, order_ids, context)
candidates = [x for x in orders if
is_zero(x.total - trans.transferred_amount)]
if len(candidates) > 0:
# retrieve the common account_id, if any
account_id = False
for line in candidates[0].line_ids[0].debit_move_line_id.move_id.line_id:
if line.account_id.type == 'other':
account_id = line.account_id.id
break
return dict(
move_line_ids = False,
match_type = 'payment_order',
payment_order_ids = [x.id for x in candidates],
account_id = account_id,
partner_id = False,
partner_bank_id = False,
reference = False,
type='general',
)
return False
def _match_storno(
self, cr, uid, trans, log, context=None):
payment_line_obj = self.pool.get('payment.line')
line_ids = payment_line_obj.search(
cr, uid, [
('order_id.payment_order_type', '=', 'debit'),
('order_id.state', 'in', ['sent', 'done']),
('communication', '=', trans.reference)
], context=context)
# stornos MUST have an exact match
if len(line_ids) == 1:
account_id = payment_line_obj.get_storno_account_id(
cr, uid, line_ids[0], trans.transferred_amount,
trans.statement_id.currency, context=None)
if account_id:
return dict(
account_id = account_id,
match_type = 'storno',
payment_line_id = line_ids[0],
move_line_ids=False,
partner_id=False,
partner_bank_id=False,
reference=False,
type='customer',
)
# TODO log the reason why there is no result for transfers marked
# as storno
return False
def _match_payment(self, cr, uid, trans, payment_lines,
partner_ids, bank_account_ids, log, linked_payments):
'''
Find the payment order belonging to this reference - if there is one
This is the easiest part: when sending payments, the returned bank info
should be identical to ours.
This also means that we do not allow for multiple candidates.
'''
# TODO: Not sure what side effects are created when payments are done
# for credited customer invoices, which will be matched later on too.
digits = dp.get_precision('Account')(cr)[1]
candidates = [
x for x in payment_lines
if x.communication == trans.reference
and round(x.amount, digits) == -round(
trans.transferred_amount, digits)
and trans.remote_account in (x.bank_id.acc_number,
x.bank_id.acc_number_domestic)
]
if len(candidates) == 1:
candidate = candidates[0]
# Check cache to prevent multiple matching of a single payment
if candidate.id not in linked_payments:
linked_payments[candidate.id] = True
move_info = self._get_move_info(
cr, uid, [candidate.move_line_id.id])
move_info.update({
'match_type': 'payment',
'payment_line_id': candidate.id,
})
return move_info
return False
def _confirm_storno(
self, cr, uid, transaction_id, context=None):
"""
Creation of the reconciliation has been delegated to
*a* direct debit module, to allow for various direct debit styles
"""
payment_line_pool = self.pool.get('payment.line')
statement_line_pool = self.pool.get('account.bank.statement.line')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_line_id:
raise orm.except_orm(
_("Cannot link with storno"),
_("No direct debit order item"))
reconcile_id = payment_line_pool.debit_storno(
cr, uid,
transaction.payment_line_id.id,
transaction.statement_line_id.amount,
transaction.statement_line_id.currency,
transaction.storno_retry,
context=context)
statement_line_pool.write(
cr, uid, transaction.statement_line_id.id,
{'reconcile_id': reconcile_id}, context=context)
transaction.refresh()
def _confirm_payment_order(
self, cr, uid, transaction_id, context=None):
"""
Creation of the reconciliation has been delegated to
*a* direct debit module, to allow for various direct debit styles
"""
payment_order_obj = self.pool.get('payment.order')
statement_line_pool = self.pool.get('account.bank.statement.line')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_order_id:
raise orm.except_orm(
_("Cannot reconcile"),
_("Cannot reconcile: no direct debit order"))
if transaction.payment_order_id.payment_order_type != 'debit':
raise orm.except_orm(
_("Cannot reconcile"),
_("Reconcile payment order not implemented"))
reconcile_id = payment_order_obj.debit_reconcile_transfer(
cr, uid,
transaction.payment_order_id.id,
transaction.statement_line_id.amount,
transaction.statement_line_id.currency,
context=context)
statement_line_pool.write(
cr, uid, transaction.statement_line_id.id,
{'reconcile_id': reconcile_id}, context=context)
def _confirm_payment(
self, cr, uid, transaction_id, context=None):
"""
Do some housekeeping on the payment line
then pass on to _reconcile_move
"""
transaction = self.browse(cr, uid, transaction_id, context=context)
payment_line_obj = self.pool.get('payment.line')
payment_line_obj.write(
cr, uid, transaction.payment_line_id.id, {
'export_state': 'done',
'date_done': transaction.statement_line_id.date,
}
)
self._confirm_move(cr, uid, transaction_id, context=context)
# Check if the payment order is 'done'
order_id = transaction.payment_line_id.order_id.id
other_lines = payment_line_obj.search(
cr, uid, [
('order_id', '=', order_id),
('date_done', '=', False),
], context=context)
if not other_lines:
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(
uid, 'payment.order', order_id, 'done', cr)
def _cancel_payment(
self, cr, uid, transaction_id, context=None):
"""
Do not support cancelling individual lines yet, because the workflow
of the payment order does not support reopening.
"""
raise orm.except_orm(
_("Cannot unreconcile"),
_("Cannot unreconcile: this operation is not yet supported for "
"match type 'payment'"))
def _cancel_payment_order(
self, cr, uid, transaction_id, context=None):
"""
"""
payment_order_obj = self.pool.get('payment.order')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_order_id:
raise orm.except_orm(
_("Cannot unreconcile"),
_("Cannot unreconcile: no direct debit order"))
if transaction.payment_order_id.payment_order_type != 'debit':
raise orm.except_orm(
_("Cannot unreconcile"),
_("Unreconcile payment order not implemented"))
return payment_order_obj.debit_unreconcile_transfer(
cr, uid, transaction.payment_order_id.id,
transaction.statement_line_id.reconcile_id.id,
transaction.statement_line_id.amount,
transaction.statement_line_id.currency)
def _cancel_storno(
self, cr, uid, transaction_id, context=None):
"""
TODO: delegate unreconciliation to the direct debit module,
to allow for various direct debit styles
"""
payment_line_obj = self.pool.get('payment.line')
reconcile_obj = self.pool.get('account.move.reconcile')
transaction = self.browse(cr, uid, transaction_id, context=context)
if not transaction.payment_line_id:
raise orm.except_orm(
_("Cannot cancel link with storno"),
_("No direct debit order item"))
if not transaction.payment_line_id.storno:
raise orm.except_orm(
_("Cannot cancel link with storno"),
_("The direct debit order item is not marked for storno"))
journal = transaction.statement_line_id.statement_id.journal_id
if transaction.statement_line_id.amount >= 0:
account_id = journal.default_credit_account_id.id
else:
account_id = journal.default_debit_account_id.id
cancel_line = False
move_lines = []
for move in transaction.statement_line_id.move_ids:
# There should usually be just one move, I think
move_lines += move.line_id
for line in move_lines:
if line.account_id.id != account_id:
cancel_line = line
break
if not cancel_line:
raise orm.except_orm(
_("Cannot cancel link with storno"),
_("Line id not found"))
reconcile = cancel_line.reconcile_id or cancel_line.reconcile_partial_id
lines_reconcile = reconcile.line_id or reconcile.line_partial_ids
if len(lines_reconcile) < 3:
# delete the full reconciliation
reconcile_obj.unlink(cr, uid, reconcile.id, context)
else:
# we are left with a partial reconciliation
reconcile_obj.write(
cr, uid, reconcile.id,
{'line_partial_ids':
[(6, 0, [x.id for x in lines_reconcile
if x.id != cancel_line.id])],
'line_id': [(6, 0, [])],
}, context)
# redo the original payment line reconciliation with the invoice
payment_line_obj.write(
cr, uid, transaction.payment_line_id.id,
{'storno': False}, context)
payment_line_obj.debit_reconcile(
cr, uid, transaction.payment_line_id.id, context)
_columns = {
'match_type': fields.selection(
# Add payment and storno types
[
('manual', 'Manual'),
('move','Move'),
('invoice', 'Invoice'),
('payment', 'Payment'),
('payment_order', 'Payment order'),
('storno', 'Storno'),
],
'Match type'),
'payment_order_ids': fields.many2many(
'payment.order', 'banking_transaction_payment_order_rel',
'order_id', 'transaction_id', 'Payment orders'),
'payment_order_id': fields.many2one(
'payment.order', 'Payment order to reconcile'),
'payment_line_id': fields.many2one('payment.line', 'Payment line'),
}
def _get_match_multi(self, cr, uid, ids, name, args, context=None):
if not ids:
return {}
res = super(banking_import_transaction, self)._get_match_multi(
cr, uid, ids, name, args, context=context)
for transaction in self.browse(cr, uid, ids, context):
if transaction.match_type == 'payment_order':
if (transaction.payment_order_ids and not
transaction.payment_order_id):
res[transaction.id] = True
return res
def clear_and_write(self, cr, uid, ids, vals=None, context=None):
super(banking_import_transaction, self).clear_and_write(
cr, uid, ids, vals=vals, context=context)
return self.write(
cr, uid, ids, {
'payment_line_id': False,
'payment_order_ids': [(6, 0, [])],
},
context=context)
def move_info2values(self, move_info):
vals = super(banking_import_transaction, self).move_info2values(
move_info)
vals['payment_line_id'] = move_info.get('payment_line_id', False)
vals['payment_order_ids'] = [
(6, 0, move_info.get('payment_order_ids') or [])]
vals['payment_order_id'] = (
move_info.get('payment_order_ids', False) and
len(move_info['payment_order_ids']) == 1 and
move_info['payment_order_ids'][0]
)
return vals
def match(self, cr, uid, ids, results=None, context=None):
res = super(banking_import_transaction, self).match(
cr, uid, ids, results=results, context=context)
return res
def __init__(self, pool, cr):
"""
Updating the function maps to handle the match types that this
module adds. While creating the map in the super object was
straightforward, the fact that these are now functions rather than
method requires the awkward way of updating it with the methods'
function objects.
As noted above, another implication is that any addon that inherits
one of these methods needs to overwrite the entry in the function
maps in the same way as is done below.
"""
super(banking_import_transaction, self).__init__(pool, cr)
self.confirm_map.update({
'storno': self._confirm_storno.__func__,
'payment_order': self._confirm_payment_order.__func__,
'payment': self._confirm_payment.__func__,
})
self.cancel_map.update({
'storno': self._cancel_storno.__func__,
'payment_order': self._cancel_payment_order.__func__,
'payment': self._cancel_payment.__func__,
})

View File

@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 banking_transaction_wizard(orm.TransientModel):
_inherit = 'banking.transaction.wizard'
_columns = {
'payment_line_id': fields.related(
'import_transaction_id', 'payment_line_id',
string="Matching payment or storno",
type='many2one', relation='payment.line',
readonly=True),
'payment_order_ids': fields.related(
'import_transaction_id', 'payment_order_ids',
string="Matching payment orders",
type='many2many', relation='payment.order'),
'payment_order_id': fields.related(
'import_transaction_id', 'payment_order_id',
string="Payment order to reconcile",
type='many2one', relation='payment.order'),
}

View File

@@ -0,0 +1,218 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 payment_line(orm.Model):
'''
Add extra export_state and date_done fields; make destination bank account
mandatory, as it makes no sense to send payments into thin air.
Edit: Payments can be by cash too, which is prohibited by mandatory bank
accounts.
'''
_inherit = 'payment.line'
_columns = {
# New fields
'export_state': fields.selection([
('draft', 'Draft'),
('open','Confirmed'),
('cancel','Cancelled'),
('sent', 'Sent'),
('rejected', 'Rejected'),
('done','Done'),
], 'State', select=True
),
'msg': fields.char('Message', size=255, required=False, readonly=True),
# Redefined fields: added states
'date_done': fields.datetime('Date Confirmed', select=True,
readonly=True),
'name': fields.char(
'Your Reference', size=64, required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'communication': fields.char(
'Communication', size=64, required=False,
help=("Used as the message between ordering customer and current "
"company. Depicts 'What do you want to say to the recipient"
" about this order ?'"
),
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'communication2': fields.char(
'Communication 2', size=128,
help='The successor message of Communication.',
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'move_line_id': fields.many2one(
'account.move.line', 'Entry line',
domain=[('reconcile_id','=', False),
('account_id.type', '=','payable')
],
help=('This Entry Line will be referred for the information of '
'the ordering customer.'
),
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'amount_currency': fields.float(
'Amount in Partner Currency', digits=(16,2),
required=True,
help='Payment amount in the partner currency',
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'currency': fields.many2one(
'res.currency', 'Partner Currency', required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'bank_id': fields.many2one(
'res.partner.bank', 'Destination Bank account',
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'order_id': fields.many2one(
'payment.order', 'Order', required=True,
ondelete='cascade', select=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'partner_id': fields.many2one(
'res.partner', string="Partner", required=True,
help='The Ordering Customer',
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'date': fields.date(
'Payment Date',
help=("If no payment date is specified, the bank will treat this "
"payment line directly"
),
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
'state': fields.selection([
('normal','Free'),
('structured','Structured')
], 'Communication Type', required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
'done': [('readonly', True)]
},
),
}
_defaults = {
'export_state': 'draft',
'date_done': False,
'msg': '',
}
def fields_get(self, cr, uid, fields=None, context=None):
res = super(payment_line, self).fields_get(cr, uid, fields, context)
if 'communication' in res:
res['communication'].setdefault('states', {})
res['communication']['states']['structured'] = [('required', True)]
if 'communication2' in res:
res['communication2'].setdefault('states', {})
res['communication2']['states']['structured'] = [('readonly', True)]
res['communication2']['states']['normal'] = [('readonly', False)]
return res
"""
Hooks for processing direct debit orders, such as implemented in
account_direct_debit module.
"""
def get_storno_account_id(self, cr, uid, payment_line_id, amount,
currency_id, context=None):
"""
Hook for verifying a match of the payment line with the amount.
Return the account associated with the storno.
Used in account_banking interactive mode
:param payment_line_id: the single payment line id
:param amount: the (signed) amount debited from the bank account
:param currency: the bank account's currency *browse object*
:return: an account if there is a full match, False otherwise
:rtype: database id of an account.account resource.
"""
return False
def debit_storno(self, cr, uid, payment_line_id, amount,
currency_id, storno_retry=True, context=None):
"""
Hook for handling a canceled item of a direct debit order.
Presumably called from a bank statement import routine.
Decide on the direction that the invoice's workflow needs to take.
You may optionally return an incomplete reconcile for the caller
to reconcile the now void payment.
:param payment_line_id: the single payment line id
:param amount: the (negative) amount debited from the bank account
:param currency: the bank account's currency *browse object*
:param boolean storno_retry: whether the storno is considered fatal \
or not.
:return: an incomplete reconcile for the caller to fill
:rtype: database id of an account.move.reconcile resource.
"""
return False

View File

@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 payment_mode(orm.Model):
''' Restoring the payment type from version 5,
used to select the export wizard (if any) '''
_inherit = "payment.mode"
def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
""" Reinstates functional code for suitable bank type filtering.
Current code in account_payment is disfunctional.
"""
res = []
payment_mode = self.browse(
cr, uid, payment_mode_id, context)
if (payment_mode and payment_mode.type and
payment_mode.type.suitable_bank_types):
res = [type.code for type in payment_mode.type.suitable_bank_types]
return res
_columns = {
'type': fields.many2one(
'payment.mode.type', 'Payment type',
help='Select the Payment Type for the Payment Mode.'
),
}

View File

@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# 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 payment_mode_type(orm.Model):
_name = 'payment.mode.type'
_description = 'Payment Mode Type'
_columns = {
'name': fields.char(
'Name', size=64, required=True,
help='Payment Type'
),
'code': fields.char(
'Code', size=64, required=True,
help='Specify the Code for Payment Type'
),
# Setting suitable_bank_types to required pending
# https://bugs.launchpad.net/openobject-addons/+bug/786845
'suitable_bank_types': fields.many2many(
'res.partner.bank.type',
'bank_type_payment_type_rel',
'pay_type_id','bank_type_id',
'Suitable bank types', required=True),
'ir_model_id': fields.many2one(
'ir.model', 'Payment wizard',
help=('Select the Payment Wizard for payments of this type. '
'Leave empty for manual processing'),
domain=[('osv_memory', '=', True)],
),
'payment_order_type': fields.selection(
[('payment', 'Payment'),('debit', 'Direct debit')],
'Payment order type', required=True,
),
}
_defaults = {
'payment_order_type': 'payment',
}

View File

@@ -2,35 +2,33 @@
##############################################################################
#
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
#
# All other contributions are (C) by their respective contributors
#
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 datetime
from osv import osv
from account_banking.struct import struct
from account_banking.parsers import convert
from datetime import datetime
from openerp.osv import orm, fields
from openerp.misc import DEFAULT_SERVER_DATE_FORMAT
today = datetime.date.today
def str2date(str):
dt = convert.str2date(str, '%Y-%m-%d')
return datetime.date(dt.year, dt.month, dt.day)
class payment_order_create(osv.osv_memory):
class payment_order_create(orm.TransientModel):
_inherit = 'payment.order.create'
def create_payment(self, cr, uid, ids, context=None):
@@ -57,8 +55,9 @@ class payment_order_create(osv.osv_memory):
### account banking
# t = None
# line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context)
_today = today()
line2bank = line_obj.line2bank(
cr, uid, line_ids, payment.mode.id, context)
_today = fields.date.context_today(self, cr, uid, context=context)
### end account banking
## Finally populate the current payment with new lines:
@@ -69,16 +68,18 @@ class payment_order_create(osv.osv_memory):
elif payment.date_prefered == 'due':
### account_banking
# date_to_pay = line.date_maturity
date_to_pay = line.date_maturity and \
str2date(line.date_maturity) > _today\
and line.date_maturity or False
date_to_pay = (
line.date_maturity
if line.date_maturity and line.date_maturity > _today
else False)
### end account banking
elif payment.date_prefered == 'fixed':
### account_banking
# date_to_pay = payment.date_planned
date_to_pay = payment.date_planned and \
str2date(payment.date_planned) > _today\
and payment.date_planned or False
date_to_pay = (
payment.date_planned
if payment.date_planned and payment.date_planned > _today
else False)
### end account banking
### account_banking
@@ -107,7 +108,7 @@ class payment_order_create(osv.osv_memory):
amount_currency = line.amount_to_pay
### end account_banking
payment_obj.create(cr, uid,{
payment_obj.create(cr, uid, {
'move_line_id': line.id,
'amount_currency': amount_currency,
'bank_id': line2bank.get(line.id),
@@ -123,5 +124,3 @@ class payment_order_create(osv.osv_memory):
'currency': line.invoice and line.invoice.currency_id.id or line.journal_id.currency.id or line.journal_id.company_id.currency_id.id,
}, context=context)
return {'type': 'ir.actions.act_window_close'}
payment_order_create()

View File

@@ -0,0 +1,2 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_payment_mode_type","payment.mode.type","model_payment_mode_type","account_payment.group_account_payment",1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_payment_mode_type payment.mode.type model_payment_mode_type account_payment.group_account_payment 1 1 1 1

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Make buttons on payment order sensitive for extra states,
restore wizard functionality when making payments
-->
<record id="view_banking_payment_order_form_1" model="ir.ui.view">
<field name="name">account.payment.order.form.banking-1</field>
<field name="inherit_id" ref="account_payment.view_payment_order_form" />
<field name="model">payment.order</field>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/group/button[@string='Select Invoices to Pay']"
position="replace">
<button colspan="2" name="%(account_payment.action_create_payment_order)s"
string="Select Invoices to Pay" type="action"
attrs="{'invisible':[('state','!=','draft')]}"
icon="gtk-find"
/>
</xpath>
<xpath expr="/form/group/button[@string='Make Payments']"
position="replace">
<button name="launch_wizard" states="open" string="Make Payments" type="object" icon="gtk-execute"/>
<newline/>
</xpath>
</data>
</field>
</record>
<record id="view_banking_payment_order_tree_1" model="ir.ui.view">
<field name="name">account.payment.order.tree.banking-1</field>
<field name="inherit_id" ref="account_payment.view_payment_order_tree" />
<field name="model">payment.order</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<button string="Make Payments" position="replace">
<button name="launch_wizard" states="open" string="Make Payments" type="object" icon="gtk-execute"/>
</button>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_payment_manual_form" model="ir.ui.view">
<field name="name">Form for manual payment wizard</field>
<field name="model">payment.manual</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<label string="Payment order(s) have been set to 'sent'"/>
<button special="cancel" icon="gtk-ok" string="OK"/>
</form>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="transaction_wizard">
<field name="name">transaction.wizard</field>
<field name="model">banking.transaction.wizard</field>
<field name="inherit_id"
ref="account_banking.transaction_wizard_first" />
<field name="type">form</field>
<field name="arch" type="xml">
<field name="invoice_ids" position="before">
<field name="payment_order_ids" invisible="True"/>
</field>
<xpath expr="//group/separator[@string='Multiple matches']/.."
position="after">
<field name='payment_line_id'
attrs="{'invisible': [
('match_type', '!=', 'storno'),
('match_type', '!=', 'payment')]
}" />
</xpath>
<field name="move_line_id" position="after">
<field name='payment_order_id'
attrs="{'readonly': [
('match_multi', '=', False)],
'invisible': [
('match_type', '!=', 'payment_order')]}"
domain="[('id', 'in', payment_order_ids[0][2])]"
/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Add the payment mode type to the payment mode views -->
<record id="view_payment_mode_form_inherit" model="ir.ui.view">
<field name="name">payment.mode.form.inherit</field>
<field name="model">payment.mode</field>
<field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="type"/>
</field>
</field>
</record>
<record id="view_payment_mode_tree_inherit" model="ir.ui.view">
<field name="name">payment.mode.tree.inherit</field>
<field name="model">payment.mode</field>
<field name="inherit_id" ref="account_payment.view_payment_mode_tree"/>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="type"/>
</field>
</field>
</record>
<!-- basic view for payment mode type -->
<record model="ir.ui.view" id="view_payment_mode_type_form">
<field name="name">view.payment.mode.type.form</field>
<field name="model">payment.mode.type</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<field name="name" />
<field name="code" />
<field name="suitable_bank_types"/>
<field name="payment_order_type"/>
<field name="ir_model_id"/>
</form>
</field>
</record>
</data>
</openerp>

View File

@@ -1,20 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) EduSense BV <http://www.edusense.nl>
All rights reserved.
The licence is in the file __terp__.py
-->
<openerp>
<data>
<!-- New activity for workflow payment order: sent -->
<record id="act_sent" model="workflow.activity">
<record id="account_banking.act_sent" model="workflow.activity">
<field name="name">sent</field>
<field name="wkf_id" ref="account_payment.wkf_payment_order"/>
<field name="action">action_sent()</field>
<field name="kind">function</field>
</record>
<!-- New activity for workflow payment order: rejected -->
<record id="act_rejected" model="workflow.activity">
<record id="account_banking.act_rejected" model="workflow.activity">
<field name="name">rejected</field>
<field name="wkf_id" ref="account_payment.wkf_payment_order"/>
<field name="action">action_rejected()
@@ -22,21 +17,21 @@ write({'state':'rejected'})</field>
<field name="kind">function</field>
</record>
<!-- Add new transition sent -> done -->
<record id="trans_sent_done" model="workflow.transition">
<field name="act_from" ref="act_sent"/>
<record id="account_banking.trans_sent_done" model="workflow.transition">
<field name="act_from" ref="account_banking.act_sent"/>
<field name="act_to" ref="account_payment.act_done"/>
<field name="signal">done</field>
</record>
<!-- Add new transition sent -> rejected -->
<record id="trans_sent_rejected" model="workflow.transition">
<field name="act_from" ref="act_sent"/>
<field name="act_to" ref="act_rejected"/>
<record id="account_banking.trans_sent_rejected" model="workflow.transition">
<field name="act_from" ref="account_banking.act_sent"/>
<field name="act_to" ref="account_banking.act_rejected"/>
<field name="signal">rejected</field>
</record>
<!-- Rewrite existing open -> done transition to include 'sent' -->
<record id="account_payment.trans_open_done" model="workflow.transition">
<field name="act_from" ref="account_payment.act_open"/>
<field name="act_to" ref="act_sent"/>
<field name="act_to" ref="account_banking.act_sent"/>
<field name="signal">sent</field>
</record>
</data>

View File

@@ -26,15 +26,13 @@
'website': 'http://www.credativ.co.uk',
'category': 'Account Banking',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
'data': [
'account_banking_uk_hsbc.xml',
'hsbc_clientid_view.xml',
'data/banking_export_hsbc.xml',
'wizard/export_hsbc_view.xml',
'security/ir.model.access.csv',
],
'demo_xml': [],
'description': '''
Module to import HSBC format transation files (S.W.I.F.T MT940) and to export payments for HSBC.net (PAYMUL).
@@ -47,6 +45,5 @@
Initial release of this module was co-sponsored by Canonical.
''',
'active': False,
'installable': False,
'installable': True,
}

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -6,16 +6,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -6,16 +6,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -5,16 +5,16 @@
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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/>.
#
##############################################################################

View File

@@ -4,43 +4,35 @@
# Copyright (C) 2011 Smile (<http://smile.fr>).
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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': 'Direct Debit',
'version': '6.1.1.134',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'Therp BV / Smile',
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['account_banking'],
'init_xml': [],
'update_xml': [
'data': [
'view/account_payment.xml',
'view/account_invoice.xml',
'workflow/account_invoice.xml',
'workflow/account_payment.xml',
'data/account_payment_term.xml',
],
'demo_xml': [],
'description': '''
This module adds support for direct debit orders, analogous to payment orders.
A new entry in the Accounting/Payment menu allow you to create a direct debit
@@ -57,6 +49,5 @@ of modules helps you to provide support for communications with your local
banking institutions. The banking addons are a continuation of Account Banking
Framework by Edusense BV. See https://launchpad.net/banking-addons.
''',
'active': False,
'installable': False,
}

View File

@@ -4,41 +4,30 @@
# 2011 Smile BV (<http://smile.fr>).
# All Rights Reserved
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract EduSense BV
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# 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 General Public License for more details.
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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 Invoice Selection Shortcut',
'version': '6.1.1.134',
'license': 'GPL-3',
'license': 'AGPL-3',
'author': 'Smile / Therp BV',
'website': 'https://launchpad.net/banking-addons',
'category': 'Banking addons',
'depends': ['account_payment'],
'init_xml': [],
'update_xml': [
],
'demo_xml': [],
'description': '''
When composing a payment order, select all candidates by default (in the second step of the "Select invoices to pay" wizard).
''',
'active': False,
'installable': False,
}