1) Add 4 new modules to handle payment mode and bank accounts:

- account_payment_partner
    - account_payment_sale
    - account_payment_sale_stock
    - account_payment_purchase

2) Filter the selection of invoices per payment mode.
    Add active field on payment.mode and payment.mode.type.
    Add menu entry for Payment Types.

3) Small code clean-up in the SEPA modules (views, 'state' field on SEPA file objects)

4) Code enhancement in the file account_banking_payment/model/account_payment.py (PEP-8, _prepare_* functions, support for payment lines with move_line_id = False)
This commit is contained in:
unknown
2014-06-25 11:19:35 +02:00
committed by Stefan Rijnhart
45 changed files with 1328 additions and 123 deletions

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# PAIN base module for OpenERP

View File

@@ -3,7 +3,7 @@
#
# 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
@@ -63,11 +63,11 @@ class payment_order(orm.Model):
),
'state': fields.selection([
('draft', 'Draft'),
('open','Confirmed'),
('cancel','Cancelled'),
('open', 'Confirmed'),
('cancel', 'Cancelled'),
('sent', 'Sent'),
('rejected', 'Rejected'),
('done','Done'),
('done', 'Done'),
], 'State', select=True
),
'line_ids': fields.one2many(
@@ -81,7 +81,7 @@ class payment_order(orm.Model):
},
),
'user_id': fields.many2one(
'res.users','User', required=True,
'res.users', 'User', required=True,
states={
'sent': [('readonly', True)],
'rejected': [('readonly', True)],
@@ -98,18 +98,19 @@ class payment_order(orm.Model):
'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 "
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."
)
)
),
'date_sent': fields.date('Send date', readonly=True),
}
def _write_payment_lines(self, cr, uid, ids, **kwargs):
'''
ORM method for setting attributes of corresponding payment.line objects.
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.
@@ -143,7 +144,7 @@ class payment_order(orm.Model):
cr, uid, ids, *args
)
def debit_reconcile_transfer(self, cr, uid, payment_order_id,
def debit_reconcile_transfer(self, cr, uid, payment_order_id,
amount, currency, context=None):
"""
During import of bank statements, create the reconcile on the transfer
@@ -163,10 +164,10 @@ class payment_order(orm.Model):
if line.account_id.type == 'other' and not line.reconcile_id:
line_ids.append(line.id)
if self.pool.get('res.currency').is_zero(
cr, uid, currency,
move_line_obj.get_balance(cr, uid, line_ids) - amount):
cr, uid, currency,
move_line_obj.get_balance(cr, uid, line_ids) - amount):
reconcile_id = self.pool.get('account.move.reconcile').create(
cr, uid,
cr, uid,
{'type': 'auto', 'line_id': [(6, 0, line_ids)]},
context)
# set direct debit order to finished state
@@ -175,8 +176,9 @@ class payment_order(orm.Model):
uid, 'payment.order', payment_order_id, 'done', cr)
return reconcile_id
def debit_unreconcile_transfer(self, cr, uid, payment_order_id, reconcile_id,
amount, currency, context=None):
def debit_unreconcile_transfer(
self, cr, uid, payment_order_id, reconcile_id, amount, currency,
context=None):
"""
Due to a cancelled bank statements import, unreconcile the move on
the transfer account. Delegate the conditions to the workflow.
@@ -194,12 +196,12 @@ class payment_order(orm.Model):
if state != 'sent':
raise orm.except_orm(
_("Cannot unreconcile"),
_("Cannot unreconcile payment order: "+
_("Cannot unreconcile payment order: "
"Workflow will not allow it."))
return True
def test_undo_done(self, cr, uid, ids, context=None):
"""
"""
Called from the workflow. Used to unset done state on
payment orders that were reconciled with bank transfers
which are being cancelled.
@@ -213,14 +215,72 @@ class payment_order(orm.Model):
for order in self.browse(cr, uid, ids, context=context):
for order_line in order.line_ids:
if order_line.transit_move_line_id.move_id:
for line in order_line.transit_move_line_id.move_id.line_id:
for line in \
order_line.transit_move_line_id.move_id.line_id:
if (line.account_id.type == 'other' and
line.reconcile_id):
return False
return True
def _prepare_transfer_move(
self, cr, uid, order, line, labels, context=None):
vals = {
'journal_id': order.mode.transfer_journal_id.id,
'name': '%s %s' % (labels[order.payment_order_type],
line.move_line_id
and line.move_line_id.move_id.name
or line.communication),
'ref': '%s %s' % (order.payment_order_type[:3].upper(),
line.move_line_id
and line.move_line_id.move_id.name
or line.communication),
}
return vals
def _prepare_move_line_transfer_account(
self, cr, uid, order, line, move_id, labels, context=None):
vals = {
'name': _('%s for %s') % (
labels[order.payment_order_type],
line.move_line_id and (line.move_line_id.invoice
and line.move_line_id.invoice.number
or line.move_line_id.name)
or line.communication),
'move_id': move_id,
'partner_id': False,
'account_id': order.mode.transfer_account_id.id,
'credit': (order.payment_order_type == 'payment'
and line.amount or 0.0),
'debit': (order.payment_order_type == 'debit'
and line.amount or 0.0),
'date': fields.date.context_today(
self, cr, uid, context=context),
}
return vals
def _update_move_line_partner_account(
self, cr, uid, order, line, vals, context=None):
vals.update({
'partner_id': line.partner_id.id,
'account_id': (line.move_line_id
and line.move_line_id.account_id.id
or False),
# if not line.move_line_id, the field 'account_id' must be set by
# another module that inherit this function, like for example in
# the module purchase_payment_order
'credit': (order.payment_order_type == 'debit'
and line.amount or 0.0),
'debit': (order.payment_order_type == 'payment'
and line.amount or 0.0),
})
return vals
def action_sent_no_move_line_hook(self, cr, uid, pay_line, context=None):
"""This function is designed to be inherited"""
return
def action_sent(self, cr, uid, ids, context=None):
"""
"""
Create the moves that pay off the move lines from
the debit order. This happens when the debit order file is
generated.
@@ -233,63 +293,35 @@ class payment_order(orm.Model):
'debit': _('Direct debit order'),
}
for order in self.browse(cr, uid, ids, context=context):
if not order.mode.transfer_journal_id or not order.mode.transfer_account_id:
if not order.mode.transfer_journal_id \
or not order.mode.transfer_account_id:
continue
for line in order.line_ids:
# basic checks
if not line.move_line_id:
if line.move_line_id and line.move_line_id.reconcile_id:
raise orm.except_orm(
_('Error'),
_('No move line provided for line %s') % line.name)
if line.move_line_id.reconcile_id:
raise orm.except_orm(
_('Error'),
_('Move line %s has already been paid/reconciled') %
line.move_line_id.name
)
_('Move line %s has already been paid/reconciled')
% line.move_line_id.name)
move_id = account_move_obj.create(cr, uid, {
'journal_id': order.mode.transfer_journal_id.id,
'name': '%s %s' % (labels[order.payment_order_type],
line.move_line_id.move_id.name),
'ref': '%s%s' % (order.payment_order_type[:3].upper(),
line.move_line_id.move_id.name),
}, context=context)
move_id = account_move_obj.create(
cr, uid, self._prepare_transfer_move(
cr, uid, order, line, labels, context=context),
context=context)
# TODO: take multicurrency into account
# create the debit move line on the transfer account
vals = {
'name': _('%s for %s') % (
labels[order.payment_order_type],
line.move_line_id.invoice and
line.move_line_id.invoice.number or
line.move_line_id.name),
'move_id': move_id,
'partner_id': False,
'account_id': order.mode.transfer_account_id.id,
'credit': (order.payment_order_type == 'payment'
and line.amount or 0.0),
'debit': (order.payment_order_type == 'debit'
and line.amount or 0.0),
'date': fields.date.context_today(
self, cr, uid, context=context),
}
transfer_move_line_id = account_move_line_obj.create(
cr, uid, vals, context=context)
# create the debit move line on the receivable account
vals.update({
'partner_id': line.partner_id.id,
'account_id': line.move_line_id.account_id.id,
'credit': (order.payment_order_type == 'debit'
and line.amount or 0.0),
'debit': (order.payment_order_type == 'payment'
and line.amount or 0.0),
})
# create the debit move line on the transfer account
ml_vals = self._prepare_move_line_transfer_account(
cr, uid, order, line, move_id, labels, context=context)
account_move_line_obj.create(cr, uid, ml_vals, context=context)
# create the debit move line on the partner account
self._update_move_line_partner_account(
cr, uid, order, line, ml_vals, context=context)
reconcile_move_line_id = account_move_line_obj.create(
cr, uid, vals, context=context)
cr, uid, ml_vals, context=context)
# register the debit move line on the payment line
# and call reconciliation on it
payment_line_obj.write(
@@ -297,16 +329,18 @@ class payment_order(orm.Model):
{'transit_move_line_id': reconcile_move_line_id},
context=context)
payment_line_obj.debit_reconcile(
cr, uid, line.id, context=context)
if line.move_line_id:
payment_line_obj.debit_reconcile(
cr, uid, line.id, context=context)
else:
self.action_sent_no_move_line_hook(
cr, uid, line, context=context)
account_move_obj.post(cr, uid, [move_id], context=context)
# State field is written by act_sent_wait
self.write(cr, uid, ids, {
'date_sent': fields.date.context_today(
self, cr, uid, context=context),
}, context=context)
'date_sent': fields.date.context_today(
self, cr, uid, context=context),
}, context=context)
return True

View File

@@ -21,6 +21,15 @@
<field name="country" ref="base.fr"/>
</record>
<record id="bank_societe_generale" model="res.bank">
<field name="name">Société Générale</field>
<field name="bic">SOGEFRPPXXX</field>
<field name="street">1 avenue du Roi Fabien 1er</field>
<field name="zip">75008</field>
<field name="city">Paris</field>
<field name="country" ref="base.fr"/>
</record>
<record id="main_company_iban" model="res.partner.bank">
<field name="acc_number">FR76 4242 4242 4242 4242 4242 424</field>
<field name="state">iban</field>
@@ -30,6 +39,15 @@
<field name="bank_bic">PSSTFRPPXXX</field>
</record>
<record id="main_company_iban2" model="res.partner.bank">
<field name="acc_number">FR20 1242 1242 1242 1242 1242 124</field>
<field name="state">iban</field>
<field name="bank" ref="bank_societe_generale"/>
<field name="partner_id" ref="base.main_partner" />
<field name="bank_name">Société Générale</field>
<field name="bank_bic">SOGEFRPPXXX</field>
</record>
<record id="res_partner_12_iban" model="res.partner.bank">
<field name="acc_number">FR66 1212 1212 1212 1212 1212 121</field>
<field name="state">iban</field>
@@ -39,5 +57,22 @@
<field name="bank_bic">FTNOFRP1XXX</field>
</record>
<record id="payment_mode_2" model="payment.mode">
<field name="name">Credit Trf Banque Postale</field>
<field name="journal" ref="account.bank_journal"/>
<field name="bank_id" ref="main_company_iban"/>
<field name="company_id" ref="base.main_company"/>
<field name="type" ref="account_banking_payment_export.manual_bank_tranfer"/>
</record>
<record id="payment_mode_3" model="payment.mode">
<field name="name">Credit Trf Société Générale</field>
<field name="journal" ref="account.bank_journal"/>
<field name="bank_id" ref="main_company_iban2"/>
<field name="company_id" ref="base.main_company"/>
<field name="type" ref="account_banking_payment_export.manual_bank_tranfer"/>
</record>
</data>
</openerp>

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import account_move_line
from . import account_payment
from . import bank_payment_manual

View File

@@ -37,6 +37,9 @@ class payment_order(orm.Model):
'Payment order type', required=True,
readonly=True, states={'draft': [('readonly', False)]},
),
'mode_type': fields.related(
'mode', 'type', type='many2one', relation='payment.mode.type',
string='Payment Type'),
}
_defaults = {

View File

@@ -53,4 +53,9 @@ class payment_mode(orm.Model):
'type', 'payment_order_type', readonly=True, type='selection',
selection=[('payment', 'Payment'), ('debit', 'Direct debit')],
string="Payment Order Type"),
'active': fields.boolean('Active'),
}
_defaults = {
'active': True,
}

View File

@@ -53,10 +53,12 @@ class payment_mode_type(orm.Model):
[('payment', 'Payment'), ('debit', 'Direct debit')],
'Payment order type', required=True,
),
'active': fields.boolean('Active'),
}
_defaults = {
'payment_order_type': 'payment',
'active': True,
}
def _auto_init(self, cr, context=None):

View File

@@ -9,12 +9,13 @@
<field name="inherit_id" ref="account_payment.view_payment_order_form" />
<field name="model">payment.order</field>
<field name="arch" type="xml">
<data>
<xpath expr="//button[@string='Make Payments']"
position="attributes">
<attribute name="name">launch_wizard</attribute>
</xpath>
</data>
<xpath expr="//button[@string='Make Payments']"
position="attributes">
<attribute name="name">launch_wizard</attribute>
</xpath>
<field name="mode" position="after">
<field name="mode_type" invisible="1"/>
</field>
</field>
</record>

View File

@@ -11,6 +11,7 @@
<field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="active"/>
<field name="type"/>
</field>
</field>

View File

@@ -18,14 +18,42 @@
<field name="name">view.payment.mode.type.form</field>
<field name="model">payment.mode.type</field>
<field name="arch" type="xml">
<form string="Payment mode">
<field name="name" />
<field name="code" />
<field name="suitable_bank_types"/>
<field name="ir_model_id"/>
<form string="Payment Type" version="7.0">
<group name="main">
<field name="name"/>
<field name="code"/>
<field name="active"/>
<field name="ir_model_id"/>
<field name="suitable_bank_types"/>
</group>
</form>
</field>
</record>
<record id="view_payment_mode_type_tree" model="ir.ui.view">
<field name="name">view.payment.mode.type.tree</field>
<field name="model">payment.mode.type</field>
<field name="arch" type="xml">
<tree string="Payment Types">
<field name="name"/>
<field name="code"/>
<field name="active"/>
<field name="ir_model_id"/>
</tree>
</field>
</record>
<record id="action_payment_mode_type" model="ir.actions.act_window">
<field name="name">Payment Type</field>
<field name="res_model">payment.mode.type</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'active_test': False}</field>
</record>
<menuitem id="menu_payment_mode_type"
action="action_payment_mode_type"
parent="account.menu_configuration_misc" />
</data>
</openerp>

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# SEPA Credit Transfer module for OpenERP

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# SEPA Credit Transfer module for OpenERP
@@ -81,7 +82,6 @@ class banking_export_sepa(orm.Model):
'state': fields.selection([
('draft', 'Draft'),
('sent', 'Sent'),
('done', 'Reconciled'),
], 'State', readonly=True),
}

View File

@@ -11,28 +11,24 @@
<field name="name">account.banking.export.sepa.form</field>
<field name="model">banking.export.sepa</field>
<field name="arch" type="xml">
<form string="SEPA Credit Transfer">
<form string="SEPA Credit Transfer" version="7.0">
<header>
<field name="state" widget="statusbar"/>
</header>
<notebook>
<page string="General Information">
<field name="total_amount" />
<field name="nb_transactions" />
<field name="batch_booking" />
<field name="charge_bearer"/>
<field name="create_date" />
<newline />
<field name="file" filename="filename"/>
<field name="filename" invisible="True"/>
<group name="main">
<field name="total_amount" />
<field name="nb_transactions" />
<field name="batch_booking" />
<field name="charge_bearer"/>
<field name="create_date" />
<field name="file" filename="filename"/>
<field name="filename" invisible="True"/>
</group>
</page>
<page string="Payment Orders">
<field name="payment_order_ids" colspan="4" nolabel="1">
<tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment Orders">
<field name="reference"/>
<field name="date_created"/>
<field name="date_done"/>
<field name="total"/>
<field name="state"/>
</tree>
</field>
<field name="payment_order_ids" nolabel="1"/>
</page>
</notebook>
</form>
@@ -48,6 +44,7 @@
<field name="filename"/>
<field name="create_date"/>
<field name="nb_transactions"/>
<field name="state"/>
</tree>
</field>
</record>

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# SEPA Direct Debit module for OpenERP

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# SEPA Direct Debit module for OpenERP
@@ -89,7 +90,6 @@ class banking_export_sdd(orm.Model):
'state': fields.selection([
('draft', 'Draft'),
('sent', 'Sent'),
('done', 'Reconciled'),
], 'State', readonly=True),
}

View File

@@ -11,28 +11,24 @@
<field name="name">account.banking.export.sdd.form</field>
<field name="model">banking.export.sdd</field>
<field name="arch" type="xml">
<form string="SEPA Direct Debit">
<form string="SEPA Direct Debit" version="7.0">
<header>
<field name="state" widget="statusbar"/>
</header>
<notebook>
<page string="General Information">
<field name="total_amount" />
<field name="nb_transactions" />
<field name="batch_booking" />
<field name="charge_bearer"/>
<field name="create_date" />
<newline />
<field name="file" filename="filename"/>
<field name="filename" invisible="True"/>
<group name="main">
<field name="total_amount" />
<field name="nb_transactions" />
<field name="batch_booking" />
<field name="charge_bearer"/>
<field name="create_date" />
<field name="file" filename="filename"/>
<field name="filename" invisible="True"/>
</group>
</page>
<page string="Payment Orders">
<field name="payment_order_ids" colspan="4" nolabel="1">
<tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment Orders">
<field name="reference"/>
<field name="date_created"/>
<field name="date_done"/>
<field name="total"/>
<field name="state"/>
</tree>
</field>
<field name="payment_order_ids" nolabel="1"/>
</page>
</notebook>
</form>
@@ -48,6 +44,7 @@
<field name="filename"/>
<field name="create_date"/>
<field name="nb_transactions"/>
<field name="state"/>
</tree>
</field>
</record>

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# SEPA Direct Debit module for OpenERP

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Partner module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import model

View File

@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Partner module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Account Payment Partner',
'version': '0.1',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': 'Adds payment mode on partners and invoices',
'description': """
Account Payment Partner
=======================
This module adds severals fields :
* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners,
* the *Payment Mode* on Invoices.
On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will
be filtered per Payment Mode.
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com>
for any help or question about this module.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['account_banking_payment_export'],
'data': [
'view/partner.xml',
'view/account_invoice.xml',
],
'demo': ['demo/partner_demo.xml'],
'active': False,
}

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!-- Camptocamp -->
<record id="supplier_payment_mode_12" model="ir.property" forcecreate="True">
<field name="name">supplier_payment_mode_12</field>
<field name="fields_id"
search="[('model','=','res.partner'),('name','=','supplier_payment_mode')]"/>
<field name="value"
eval="'payment.mode,'+str(ref('account_banking_payment_export.payment_mode_2'))"/>
<field name="company_id" ref="base.main_company"/>
<field name="res_id" ref="base.res_partner_12"/>
</record>
<record id="customer_payment_mode_12" model="ir.property" forcecreate="True">
<field name="name">customer_payment_mode_12</field>
<field name="fields_id"
search="[('model','=','res.partner'),('name','=','customer_payment_mode')]"/>
<field name="value"
eval="'payment.mode,'+str(ref('account_banking_payment_export.payment_mode_2'))"/>
<field name="company_id" ref="base.main_company"/>
<field name="res_id" ref="base.res_partner_12"/>
</record>
<!-- Agrolait -->
<record id="customer_payment_mode_2" model="ir.property" forcecreate="True">
<field name="name">customer_payment_mode_2</field>
<field name="fields_id"
search="[('model','=','res.partner'),('name','=','customer_payment_mode')]"/>
<field name="value"
eval="'payment.mode,'+str(ref('account_banking_payment_export.payment_mode_3'))"/>
<field name="company_id" ref="base.main_company"/>
<field name="res_id" ref="base.res_partner_2"/>
</record>
<!-- Asustek -->
<record id="supplier_payment_mode_1" model="ir.property" forcecreate="True">
<field name="name">supplier_payment_mode_1</field>
<field name="fields_id"
search="[('model','=','res.partner'),('name','=','supplier_payment_mode')]"/>
<field name="value"
eval="'payment.mode,'+str(ref('account_banking_payment_export.payment_mode_2'))"/>
<field name="company_id" ref="base.main_company"/>
<field name="res_id" ref="base.res_partner_1"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,57 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_payment_partner
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-09 23:22+0000\n"
"PO-Revision-Date: 2014-06-09 23:22+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_payment_partner
#: field:res.partner,customer_payment_mode:0
msgid "Customer Payment Mode"
msgstr ""
#. module: account_payment_partner
#: model:ir.model,name:account_payment_partner.model_account_invoice
msgid "Invoice"
msgstr ""
#. module: account_payment_partner
#: model:ir.model,name:account_payment_partner.model_res_partner
msgid "Partner"
msgstr ""
#. module: account_payment_partner
#: field:account.invoice,payment_mode_id:0
msgid "Payment Mode"
msgstr ""
#. module: account_payment_partner
#: help:res.partner,customer_payment_mode:0
msgid "Select the default payment mode for this customer."
msgstr ""
#. module: account_payment_partner
#: help:res.partner,supplier_payment_mode:0
msgid "Select the default payment mode for this supplier."
msgstr ""
#. module: account_payment_partner
#: field:res.partner,supplier_payment_mode:0
msgid "Supplier Payment Mode"
msgstr ""
#. module: account_payment_partner
#: model:ir.model,name:account_payment_partner.model_payment_order_create
msgid "payment.order.create"
msgstr ""

View File

@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Partner module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import partner
from . import account_invoice
from . import payment_order_create

View File

@@ -0,0 +1,56 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Partner module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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_invoice(orm.Model):
_inherit = 'account.invoice'
_columns = {
'payment_mode_id': fields.many2one(
'payment.mode', 'Payment Mode'),
}
def onchange_partner_id(
self, cr, uid, ids, type, partner_id, date_invoice=False,
payment_term=False, partner_bank_id=False, company_id=False):
res = super(account_invoice, self).onchange_partner_id(
cr, uid, ids, type, partner_id, date_invoice=date_invoice,
payment_term=payment_term, partner_bank_id=partner_bank_id,
company_id=company_id)
if partner_id:
partner = self.pool['res.partner'].browse(cr, uid, partner_id)
if type == 'in_invoice':
res['value']['payment_mode_id'] = \
partner.supplier_payment_mode.id or False
elif type == 'out_invoice':
res['value'].update({
'payment_mode_id':
partner.customer_payment_mode.id or False,
'partner_bank_id':
partner.customer_payment_mode and
partner.customer_payment_mode.bank_id.id or False,
})
else:
res['value']['payment_mode_id'] = False
return res

View File

@@ -0,0 +1,44 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Partner module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class res_partner(orm.Model):
_inherit = 'res.partner'
_columns = {
'supplier_payment_mode': fields.property(
'payment.mode', type='many2one', relation='payment.mode',
string='Supplier Payment Mode', view_load=True,
help="Select the default payment mode for this supplier."),
'customer_payment_mode': fields.property(
'payment.mode', type='many2one', relation='payment.mode',
string='Customer Payment Mode', view_load=True,
help="Select the default payment mode for this customer."),
}
def _commercial_fields(self, cr, uid, context=None):
res = super(res_partner, self)._commercial_fields(
cr, uid, context=context)
res += ['supplier_payment_mode', 'customer_payment_mode']
return res

View File

@@ -0,0 +1,39 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Partner module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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
class payment_order_create(orm.TransientModel):
_inherit = 'payment.order.create'
def extend_payment_order_domain(
self, cr, uid, payment_order, domain, context=None):
super(payment_order_create, self).extend_payment_order_domain(
cr, uid, payment_order, domain, context=context)
domain += [
'|', '|',
('invoice', '=', False),
('invoice.payment_mode_id', '=', False),
('invoice.payment_mode_id', '=', payment_order.mode.id)
]
return True

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="invoice_form" model="ir.ui.view">
<field name="name">account_payment_partner.invoice_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<field name="partner_bank_id" position="after">
<field name="payment_mode_id"/>
</field>
</field>
</record>
<record id="invoice_supplier_form" model="ir.ui.view">
<field name="name">account_payment_partner.invoice_supplier_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form" />
<field name="arch" type="xml">
<field name="partner_bank_id" position="after">
<field name="payment_mode_id"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_partner_property_form" model="ir.ui.view">
<field name="name">account_partner_payment.partner_form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form" />
<field name="arch" type="xml">
<field name="property_payment_term" position="after">
<field name="customer_payment_mode"
attrs="{'invisible': [('customer', '=', False)]}"/>
</field>
<field name="property_supplier_payment_term" position="after">
<field name="supplier_payment_mode"
attrs="{'invisible': [('supplier', '=', False)]}"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Purchase module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import model

View File

@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Purchase module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Account Payment Purchase',
'version': '1.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': "Adds Bank Account and Payment Mode on Purchase Orders",
'description': """
Account Payment Purchase
========================
This modules adds 2 fields on purchase orders : *Bank Account* and *Payment
Mode*. These fields are copied from partner to purchase order and then from
purchase order to supplier invoice.
This module is similar to the *purchase_payment* module ; the main difference
is that it doesn't depend on the *account_payment_extension* module (it's not
the only module to conflict with *account_payment_extension* ; all the SEPA
modules in the banking addons conflict with *account_payment_extension*, cf
banking-addons-70/account_banking_payment_export/__openerp__.py).
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com>
for any help or question about this module.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['purchase', 'account_payment_partner'],
'conflicts': ['purchase_payment'],
'data': [
'view/purchase.xml',
],
'installable': True,
'active': False,
}

View File

@@ -0,0 +1,42 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_payment_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-09 23:23+0000\n"
"PO-Revision-Date: 2014-06-09 23:23+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_payment_purchase
#: field:purchase.order,payment_mode_id:0
msgid "Payment Mode"
msgstr ""
#. module: account_payment_purchase
#: model:ir.model,name:account_payment_purchase.model_stock_picking
msgid "Picking List"
msgstr ""
#. module: account_payment_purchase
#: model:ir.model,name:account_payment_purchase.model_purchase_order
msgid "Purchase Order"
msgstr ""
#. module: account_payment_purchase
#: help:purchase.order,supplier_partner_bank_id:0
msgid "Select the bank account of your supplier on which your company should send the payment. This field is copied from the partner and will be copied to the supplier invoice."
msgstr ""
#. module: account_payment_purchase
#: field:purchase.order,supplier_partner_bank_id:0
msgid "Supplier Bank Account"
msgstr ""

View File

@@ -0,0 +1,42 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_payment_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-02-24 23:09+0000\n"
"PO-Revision-Date: 2014-02-24 23:09+0000\n"
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_payment_purchase
#: field:purchase.order,payment_mode_type:0
msgid "Payment Type"
msgstr "Type de Paiement"
#. module: account_payment_purchase
#: model:ir.model,name:account_payment_purchase.model_purchase_order
msgid "Purchase Order"
msgstr "Bon de commande"
#. module: account_payment_purchase
#: help:purchase.order,supplier_partner_bank:0
msgid "Select the bank account of your supplier on which your company should send the payment. This field is copied from the partner and will be copied to the supplier invoice."
msgstr "Selectionnez le compte bancaire du fournisseur sur lequel votre société devra effectuer le règlement. Ce champ est copié depuis le partenaire et sera recopié sur la facture fournisseur."
#. module: account_payment_purchase
#: field:purchase.order,supplier_partner_bank:0
msgid "Supplier Bank Account"
msgstr "Compte bancaire du fournisseur"
#. module: account_payment_purchase
#: model:ir.model,name:account_payment_purchase.model_stock_picking
msgid "Picking List"
msgstr "Bon de livraison"

View File

@@ -0,0 +1,24 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Purchase module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import purchase
from . import stock

View File

@@ -0,0 +1,82 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Purchase module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 purchase_order(orm.Model):
_inherit = "purchase.order"
_columns = {
'supplier_partner_bank_id': fields.many2one(
'res.partner.bank', 'Supplier Bank Account',
help="Select the bank account of your supplier on which "
"your company should send the payment. This field is copied "
"from the partner and will be copied to the supplier invoice."),
'payment_mode_id': fields.many2one(
'payment.mode', 'Payment Mode'),
}
def _get_default_supplier_partner_bank(
self, cr, uid, partner, context=None):
'''This function is designed to be inherited'''
if partner.bank_ids:
return partner.bank_ids[0].id
else:
return False
def onchange_partner_id(self, cr, uid, ids, partner_id):
res = super(purchase_order, self).onchange_partner_id(
cr, uid, ids, partner_id)
if partner_id:
partner = self.pool['res.partner'].browse(
cr, uid, partner_id)
res['value'].update({
'supplier_partner_bank_id':
self._get_default_supplier_partner_bank(
cr, uid, partner),
'payment_mode_id':
partner.supplier_payment_mode.id or False,
})
else:
res['value'].update({
'supplier_partner_bank_id': False,
'payment_mode_id': False,
})
return res
def action_invoice_create(self, cr, uid, ids, context=None):
"""Copy bank partner + payment type from PO to invoice"""
# as of OpenERP 7.0, there is no _prepare function for
# the invoice (the _prepare function only exists for invoice lines)
res = super(purchase_order, self).action_invoice_create(
cr, uid, ids, context=context)
for order in self.browse(cr, uid, ids, context=context):
for invoice in order.invoice_ids:
if invoice.state == 'draft':
invoice.write({
'partner_bank_id':
order.supplier_partner_bank_id.id or False,
'payment_mode_id':
order.payment_mode_id.id or False,
}, context=context)
return res

View File

@@ -0,0 +1,42 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Purchase module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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
class stock_picking(orm.Model):
_inherit = "stock.picking"
def _prepare_invoice(
self, cr, uid, picking, partner, inv_type, journal_id,
context=None):
"""Copy bank partner and payment type from PO to invoice"""
invoice_vals = super(stock_picking, self)._prepare_invoice(
cr, uid, picking, partner, inv_type, journal_id, context=context)
if picking.purchase_id:
invoice_vals.update({
'partner_bank_id':
picking.purchase_id.supplier_partner_bank.id or False,
'payment_mode_type':
picking.purchase_id.payment_mode_type.id or False,
})
return invoice_vals

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="purchase_order_form" model="ir.ui.view">
<field name="name">account_payment_purchase.purchase_order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<field name="payment_term_id" position="after">
<field name="payment_mode_id"/>
<field name="supplier_partner_bank_id"
domain="[('partner_id', '=', partner_id)]" />
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import model

View File

@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Account Payment Sale',
'version': '1.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': "Adds Payment Mode on Sale Orders",
'description': """
Account Payment Sale
====================
This modules adds one field on sale orders : *Payment Mode*.
This field is copied from partner to sale order and then from sale order to
customer invoice.
This module is similar to the *sale_payment* module ; the main difference is
that it doesn't depend on the *account_payment_extension* module (it's not the
only module to conflict with *account_payment_extension* ; all the SEPA
modules in the banking addons conflict with *account_payment_extension*, cf
banking-addons-70/account_banking_payment_export/__openerp__.py).
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com>
for any help or question about this module.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['sale', 'account_payment_partner'],
'conflicts': ['sale_payment'],
'data': [
'view/sale.xml',
],
'installable': True,
'active': False,
}

View File

@@ -0,0 +1,27 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_payment_sale
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-06-09 23:24+0000\n"
"PO-Revision-Date: 2014-06-09 23:24+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_payment_sale
#: field:sale.order,payment_mode_id:0
msgid "Payment Mode"
msgstr ""
#. module: account_payment_sale
#: model:ir.model,name:account_payment_sale.model_sale_order
msgid "Sales Order"
msgstr ""

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import sale

View File

@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 sale_order(orm.Model):
_inherit = "sale.order"
_columns = {
'payment_mode_id': fields.many2one(
'payment.mode', 'Payment Mode'),
}
def onchange_partner_id(self, cr, uid, ids, part, context=None):
res = super(sale_order, self).onchange_partner_id(
cr, uid, ids, part, context=context)
if part:
partner = self.pool['res.partner'].browse(
cr, uid, part, context=context)
res['value']['payment_mode_id'] = \
partner.customer_payment_mode.id or False,
else:
res['value']['payment_mode_id'] = False
return res
def _prepare_invoice(self, cr, uid, order, lines, context=None):
"""Copy bank partner from sale order to invoice"""
invoice_vals = super(sale_order, self)._prepare_invoice(
cr, uid, order, lines, context=context)
invoice_vals.update({
'payment_mode_id': order.payment_mode_id.id or False,
'partner_bank_id': order.payment_mode_id and
order.payment_mode_id.bank_id.id or False,
})
return invoice_vals

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_order_form" model="ir.ui.view">
<field name="name">account_payment_sale.sale_order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="payment_term" position="after">
<field name="payment_mode_id"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale Stock module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import model

View File

@@ -0,0 +1,46 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale Stock module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Account Payment Sale Stock',
'version': '1.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': "Manage Payment Mode when invoicing from picking",
'description': """
Account Payment Sale Stock
==========================
This modules copies *Payment Mode* from Sale Order to Invoice when the
Invoice is generated from the Picking.
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com>
for any help or question about this module.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['sale_stock', 'account_payment_sale'],
'conflicts': ['account_payment_extension'],
'data': [],
'auto_install': True,
'active': False,
}

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale Stock module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 . import stock

View File

@@ -0,0 +1,43 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Payment Sale Stock module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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
class stock_picking(orm.Model):
_inherit = "stock.picking"
def _prepare_invoice(
self, cr, uid, picking, partner, inv_type, journal_id,
context=None):
"""Copy payment mode from sale order to invoice"""
invoice_vals = super(stock_picking, self)._prepare_invoice(
cr, uid, picking, partner, inv_type, journal_id, context=context)
if picking.sale_id:
invoice_vals.update({
'partner_bank_id':
picking.sale_id.payment_mode_id and
picking.sale_id.payment_mode_id.bank_id.id or False,
'payment_mode_id':
picking.sale_id.payment_mode_id.id or False,
})
return invoice_vals