mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_order
This commit is contained in:
@@ -21,22 +21,22 @@ This modules is part of the OCA/bank-payment suite.
|
||||
Configuration
|
||||
=============
|
||||
|
||||
This module adds several options on Payment Modes, cf Accounting > Configuration > Management > Payment Modes.
|
||||
This module adds several options on Payment Modes, cf Invoicing/Accounting > Configuration > Management > Payment Modes.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
You can create a Payment Order via the menu Accounting > Payments > Payment Orders and then select the move lines to pay.
|
||||
You can create a Payment Order via the menu Invoicing/Accounting > Payments > Payment Orders and then select the move lines to pay.
|
||||
|
||||
You can create a Debit Order via the menu Accounting > Payments > Debit Orders and then select the move lines to debit.
|
||||
You can create a Debit Order via the menu Invoicing/Accounting > Payments > Debit Orders and then select the move lines to debit.
|
||||
|
||||
This module also adds a button *Add to Payment Order* on supplier invoices and a button *Add to Debit Order* on customer invoices.
|
||||
|
||||
You can print a Payment Order via the menu Accounting > Payments > Payment Orders and then select the payment oder to print.
|
||||
You can print a Payment Order via the menu Invoicing/Accounting > Payments > Payment Orders and then select the payment oder to print.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/173/10.0
|
||||
:target: https://runbot.odoo-community.org/runbot/173/11.0
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
@@ -75,12 +75,12 @@ Contributors
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://odoo-community.org
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit http://odoo-community.org.
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2009 EduSense BV (<http://www.edusense.nl>)
|
||||
# © 2011-2013 Therp BV (<http://therp.nl>)
|
||||
# © 2013-2014 ACSONE SA (<http://acsone.eu>).
|
||||
# © 2011-2013 Therp BV (<https://therp.nl>)
|
||||
# © 2013-2014 ACSONE SA (<https://acsone.eu>).
|
||||
# © 2014-2016 Tecnativa - Pedro M. Baeza
|
||||
# © 2016 Akretion (<http://www.akretion.com>).
|
||||
# © 2016 Aselcis (<http://www.aselcis.com>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# © 2016 Akretion (<https://www.akretion.com>).
|
||||
# © 2016 Aselcis (<https://www.aselcis.com>).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Payment Order',
|
||||
'version': '10.0.1.3.2',
|
||||
'version': '11.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': "ACSONE SA/NV, "
|
||||
"Therp BV, "
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2015-2016 Akretion (http://www.akretion.com/)
|
||||
© 2015-2016 Akretion (https://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2014 ACSONE SA (<http://acsone.eu>).
|
||||
# © 2013-2014 ACSONE SA (<https://acsone.eu>).
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
@@ -89,15 +89,15 @@ class AccountPaymentLine(models.Model):
|
||||
bplo = self.env['bank.payment.line']
|
||||
values = []
|
||||
for field in bplo.same_fields_payment_line_and_bank_payment_line():
|
||||
values.append(unicode(self[field]))
|
||||
values.append(str(self[field]))
|
||||
# Don't group the payment lines that are attached to the same supplier
|
||||
# but to move lines with different accounts (very unlikely),
|
||||
# for easier generation/comprehension of the transfer move
|
||||
values.append(unicode(self.move_line_id.account_id or False))
|
||||
values.append(str(self.move_line_id.account_id or False))
|
||||
# Don't group the payment lines that use a structured communication
|
||||
# otherwise it would break the structured communication system !
|
||||
if self.communication_type != 'normal':
|
||||
values.append(unicode(self.id))
|
||||
values.append(str(self.id))
|
||||
hashcode = '-'.join(values)
|
||||
return hashcode
|
||||
|
||||
@@ -113,7 +113,7 @@ class AccountPaymentLine(models.Model):
|
||||
if self.move_line_id:
|
||||
vals = self.move_line_id._prepare_payment_line_vals(self.order_id)
|
||||
vals.pop('order_id')
|
||||
for field, value in vals.iteritems():
|
||||
for field, value in vals.items():
|
||||
self[field] = value
|
||||
else:
|
||||
self.partner_id = False
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2009 EduSense BV (<http://www.edusense.nl>)
|
||||
# © 2011-2013 Therp BV (<http://therp.nl>)
|
||||
# © 2011-2013 Therp BV (<https://therp.nl>)
|
||||
# © 2014-2016 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
@@ -29,7 +29,10 @@ class AccountPaymentMode(models.Model):
|
||||
('any', 'Any'),
|
||||
], string='Payment Mode on Invoice', default='same')
|
||||
default_journal_ids = fields.Many2many(
|
||||
'account.journal', string="Journals Filter")
|
||||
'account.journal',
|
||||
string="Journals Filter",
|
||||
domain="[('company_id', '=', company_id)]"
|
||||
)
|
||||
default_invoice = fields.Boolean(
|
||||
string='Linked to an Invoice or Refund', default=False)
|
||||
default_target_move = fields.Selection([
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2009 EduSense BV (<http://www.edusense.nl>)
|
||||
# © 2011-2013 Therp BV (<http://therp.nl>)
|
||||
# © 2011-2013 Therp BV (<https://therp.nl>)
|
||||
# © 2016 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2016 Akretion (Alexis de Lattre - alexis.delattre@akretion.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import base64
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
@@ -15,6 +16,15 @@ class AccountPaymentOrder(models.Model):
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'id desc'
|
||||
|
||||
def domain_journal_id(self):
|
||||
if not self.payment_mode_id:
|
||||
return [('id', '=', False)]
|
||||
if self.payment_mode_id.bank_account_link == 'fixed':
|
||||
return [('id', '=', self.payment_mode_id.fixed_journal_id.id)]
|
||||
elif self.payment_mode_id.bank_account_link == 'variable':
|
||||
jrl_ids = self.payment_mode_id.variable_journal_ids.ids
|
||||
return [('id', 'in', jrl_ids)]
|
||||
|
||||
name = fields.Char(
|
||||
string='Number', readonly=True, copy=False) # v8 field : name
|
||||
payment_mode_id = fields.Many2one(
|
||||
@@ -38,6 +48,7 @@ class AccountPaymentOrder(models.Model):
|
||||
journal_id = fields.Many2one(
|
||||
'account.journal', string='Bank Journal', ondelete='restrict',
|
||||
readonly=True, states={'draft': [('readonly', False)]},
|
||||
domain=domain_journal_id,
|
||||
track_visibility='onchange')
|
||||
# The journal_id field is only required at confirm step, to
|
||||
# allow auto-creation of payment order from invoice
|
||||
@@ -161,18 +172,13 @@ class AccountPaymentOrder(models.Model):
|
||||
|
||||
@api.onchange('payment_mode_id')
|
||||
def payment_mode_id_change(self):
|
||||
journal_id = False
|
||||
domain = self.domain_journal_id()
|
||||
res = {'domain': {
|
||||
'journal_id': "[('id', '=', False)]",
|
||||
}}
|
||||
if self.payment_mode_id:
|
||||
if self.payment_mode_id.bank_account_link == 'fixed':
|
||||
journal_id = self.payment_mode_id.fixed_journal_id.id
|
||||
res['domain']['journal_id'] = "[('id', '=', %d)]" % journal_id
|
||||
elif self.payment_mode_id.bank_account_link == 'variable':
|
||||
jrl_ids = self.payment_mode_id.variable_journal_ids.ids
|
||||
res['domain']['journal_id'] = "[('id', 'in', %s)]" % jrl_ids
|
||||
self.journal_id = journal_id
|
||||
'journal_id': domain
|
||||
}}
|
||||
journals = self.env['account.journal'].search(domain)
|
||||
if len(journals) == 1:
|
||||
self.journal_id = journals
|
||||
if self.payment_mode_id.default_date_prefered:
|
||||
self.date_prefered = self.payment_mode_id.default_date_prefered
|
||||
return res
|
||||
@@ -289,7 +295,7 @@ class AccountPaymentOrder(models.Model):
|
||||
'total': payline.amount_currency,
|
||||
}
|
||||
# Create bank payment lines
|
||||
for paydict in group_paylines.values():
|
||||
for paydict in list(group_paylines.values()):
|
||||
# Block if a bank payment line is <= 0
|
||||
if paydict['total'] <= 0:
|
||||
raise UserError(_(
|
||||
@@ -323,7 +329,7 @@ class AccountPaymentOrder(models.Model):
|
||||
'res_model': 'account.payment.order',
|
||||
'res_id': self.id,
|
||||
'name': filename,
|
||||
'datas': payment_file_str.encode('base64'),
|
||||
'datas': base64.b64encode(payment_file_str),
|
||||
'datas_fname': filename,
|
||||
})
|
||||
simplified_form_view = self.env.ref(
|
||||
@@ -472,7 +478,7 @@ class AccountPaymentOrder(models.Model):
|
||||
else:
|
||||
trfmoves[hashcode] = bline
|
||||
|
||||
for hashcode, blines in trfmoves.iteritems():
|
||||
for hashcode, blines in trfmoves.items():
|
||||
mvals = self._prepare_move(blines)
|
||||
total_company_currency = total_payment_currency = 0
|
||||
for bline in blines:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
@@ -52,9 +52,11 @@ class BankPaymentLine(models.Model):
|
||||
string='Communication', required=True,
|
||||
readonly=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
related='order_id.payment_mode_id.company_id', store=True,
|
||||
readonly=True)
|
||||
company_currency_id = fields.Many2one(
|
||||
'res.currency',
|
||||
related='order_id.payment_mode_id.company_id.currency_id',
|
||||
readonly=True, store=True)
|
||||
|
||||
@@ -77,6 +79,9 @@ class BankPaymentLine(models.Model):
|
||||
for bline in self:
|
||||
amount_currency = sum(
|
||||
bline.mapped('payment_line_ids.amount_currency'))
|
||||
import logging
|
||||
logging.info(bline.company_id)
|
||||
logging.info(bline.company_currency_id)
|
||||
amount_company_currency = bline.currency_id.with_context(
|
||||
date=bline.date).compute(
|
||||
amount_currency, bline.company_currency_id)
|
||||
@@ -101,7 +106,7 @@ class BankPaymentLine(models.Model):
|
||||
if self.order_id.payment_mode_id.move_option == 'date':
|
||||
hashcode = self.date
|
||||
else:
|
||||
hashcode = unicode(self.id)
|
||||
hashcode = str(self.id)
|
||||
return hashcode
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Acsone SA/NV (<https://www.acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.tools.misc import formatLang
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
|
||||
<template id="print_account_payment_order_document">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
|
||||
<!-- QWeb Report -->
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_payment_mode
|
||||
from . import test_bank
|
||||
from . import test_payment_order
|
||||
|
||||
15
account_payment_order/tests/test_bank.py
Normal file
15
account_payment_order/tests/test_bank.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Creu Blanca
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class TestBank(TransactionCase):
|
||||
|
||||
def test_bank(self):
|
||||
bank = self.env['res.bank'].search([], limit=1)
|
||||
self.assertTrue(bank)
|
||||
with self.assertRaises(ValidationError):
|
||||
bank.bic = "TEST"
|
||||
65
account_payment_order/tests/test_payment_mode.py
Normal file
65
account_payment_order/tests/test_payment_mode.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Creu Blanca
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class TestPaymentMode(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPaymentMode, self).setUp()
|
||||
|
||||
# Company
|
||||
self.company = self.env.ref('base.main_company')
|
||||
|
||||
self.journal_c1 = self.env['account.journal'].create({
|
||||
'name': 'Journal 1',
|
||||
'code': 'J1',
|
||||
'type': 'bank',
|
||||
'company_id': self.company.id,
|
||||
})
|
||||
|
||||
self.account = self.env['account.account'].search([
|
||||
('reconcile', '=', True),
|
||||
('company_id', '=', self.company.id)
|
||||
], limit=1)
|
||||
|
||||
self.manual_out = self.env.ref(
|
||||
'account.account_payment_method_manual_out')
|
||||
|
||||
self.payment_mode_c1 = self.env['account.payment.mode'].create({
|
||||
'name': 'Direct Debit of suppliers from Bank 1',
|
||||
'bank_account_link': 'variable',
|
||||
'payment_method_id': self.manual_out.id,
|
||||
'company_id': self.company.id,
|
||||
'fixed_journal_id': self.journal_c1.id,
|
||||
'variable_journal_ids': [(6, 0, [self.journal_c1.id])]
|
||||
})
|
||||
|
||||
def test_constrains(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write({
|
||||
'generate_move': True,
|
||||
'offsetting_account': False
|
||||
})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write({
|
||||
'generate_move': True,
|
||||
'offsetting_account': 'bank_account',
|
||||
'move_option': False
|
||||
})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write({
|
||||
'generate_move': True,
|
||||
'offsetting_account': 'transfer_account',
|
||||
'transfer_account_id': False
|
||||
})
|
||||
with self.assertRaises(ValidationError):
|
||||
self.payment_mode_c1.write({
|
||||
'generate_move': True,
|
||||
'offsetting_account': 'transfer_account',
|
||||
'transfer_account_id': self.account.id,
|
||||
'transfer_journal_id': False
|
||||
})
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
from openerp.exceptions import UserError
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class TestPaymentOrder(TransactionCase):
|
||||
@@ -17,7 +18,7 @@ class TestPaymentOrder(TransactionCase):
|
||||
[('user_type_id', '=', self.env.ref(
|
||||
'account.data_account_type_payable').id)],
|
||||
limit=1).id
|
||||
invoice_line_account = self.env['account.account'].search(
|
||||
self.invoice_line_account = self.env['account.account'].search(
|
||||
[('user_type_id', '=', self.env.ref(
|
||||
'account.data_account_type_expenses').id)],
|
||||
limit=1).id
|
||||
@@ -36,20 +37,61 @@ class TestPaymentOrder(TransactionCase):
|
||||
'price_unit': 100.0,
|
||||
'invoice_id': invoice.id,
|
||||
'name': 'product that cost 100',
|
||||
'account_id': invoice_line_account,
|
||||
'account_id': self.invoice_line_account,
|
||||
})
|
||||
|
||||
return invoice
|
||||
|
||||
def test_creation(self):
|
||||
# Open invoice
|
||||
self.invoice.action_invoice_open()
|
||||
mode = self.env.ref('account_payment_mode.payment_mode_outbound_ct1')
|
||||
order = self.env['account.payment.order'].create({
|
||||
'payment_type': 'outbound',
|
||||
'payment_mode_id': self.env.ref(
|
||||
'account_payment_mode.payment_mode_outbound_dd1').id
|
||||
})
|
||||
bank_journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')], limit=1)
|
||||
mode.variable_journal_ids = bank_journal
|
||||
order.payment_mode_id = mode.id
|
||||
order.payment_mode_id_change()
|
||||
self.assertEqual(order.journal_id.id, bank_journal.id)
|
||||
|
||||
self.assertEqual(len(order.payment_line_ids), 0)
|
||||
line_create = self.env['account.payment.line.create'].with_context(
|
||||
active_model='account.payment.order',
|
||||
active_id=order.id
|
||||
).create({})
|
||||
line_create.date_type = 'move'
|
||||
line_create.move_date = datetime.now()
|
||||
line_create.payment_mode = 'any'
|
||||
line_create.move_line_filters_change()
|
||||
line_create.populate()
|
||||
line_create.create_payment_lines()
|
||||
line_create_due = self.env['account.payment.line.create'].with_context(
|
||||
active_model='account.payment.order',
|
||||
active_id=order.id
|
||||
).create({})
|
||||
line_create_due.date_type = 'due'
|
||||
line_create_due.due_date = datetime.now()
|
||||
line_create_due.populate()
|
||||
line_create_due.create_payment_lines()
|
||||
self.assertGreater(len(order.payment_line_ids), 0)
|
||||
|
||||
def test_cancel_payment_order(self):
|
||||
# Open invoice
|
||||
self.invoice.action_invoice_open()
|
||||
# Add to payment order
|
||||
self.invoice.create_account_payment_line()
|
||||
# Add to payment order using the wizard
|
||||
self.env['account.invoice.payment.line.multi'].with_context(
|
||||
active_model='account.invoice',
|
||||
active_ids=self.invoice.ids
|
||||
).create({}).run()
|
||||
|
||||
payment_order = self.env['account.payment.order'].search([])
|
||||
self.assertEqual(len(payment_order.ids), 1)
|
||||
bank_journal = self.env['account.journal'].search(
|
||||
[('type', '=', 'bank')])
|
||||
[('type', '=', 'bank')], limit=1)
|
||||
# Set journal to allow cancelling entries
|
||||
bank_journal.update_posted = True
|
||||
|
||||
@@ -57,19 +99,19 @@ class TestPaymentOrder(TransactionCase):
|
||||
'journal_id': bank_journal.id
|
||||
})
|
||||
|
||||
self.assertEquals(len(payment_order.payment_line_ids), 1)
|
||||
self.assertEquals(len(payment_order.bank_line_ids), 0)
|
||||
self.assertEqual(len(payment_order.payment_line_ids), 1)
|
||||
self.assertEqual(len(payment_order.bank_line_ids), 0)
|
||||
|
||||
# Open payment order
|
||||
payment_order.draft2open()
|
||||
|
||||
self.assertEquals(len(payment_order.bank_line_ids), 1)
|
||||
self.assertEqual(payment_order.bank_line_count, 1)
|
||||
|
||||
# Generate and upload
|
||||
payment_order.open2generated()
|
||||
payment_order.generated2uploaded()
|
||||
|
||||
self.assertEquals(payment_order.state, 'uploaded')
|
||||
self.assertEqual(payment_order.state, 'uploaded')
|
||||
with self.assertRaises(UserError):
|
||||
payment_order.unlink()
|
||||
|
||||
@@ -77,9 +119,9 @@ class TestPaymentOrder(TransactionCase):
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
bank_line.unlink()
|
||||
|
||||
payment_order.action_done_cancel()
|
||||
self.assertEquals(payment_order.state, 'cancel')
|
||||
self.assertEqual(payment_order.state, 'cancel')
|
||||
payment_order.cancel2draft()
|
||||
|
||||
payment_order.unlink()
|
||||
self.assertEquals(len(self.env['account.payment.order'].search([])), 0)
|
||||
self.assertEqual(len(self.env['account.payment.order'].search([])), 0)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2016 Akretion (http://www.akretion.com/)
|
||||
© 2016 Akretion (https://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
@@ -15,7 +15,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<group name="payments" position="inside">
|
||||
<field name="partner_bank_id"
|
||||
domain="[('partner_id', '=', partner_id)]"/>
|
||||
domain="[('partner_id', '=', partner_id),
|
||||
'|',('company_id', '=', company_id),('company_id', '=', False)]]"/>
|
||||
<field name="bank_payment_line_id"/>
|
||||
</group>
|
||||
</field>
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
<field name="currency_id"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="partner_bank_id"
|
||||
domain="[('partner_id', '=', partner_id)]"
|
||||
domain="[('partner_id', '=', partner_id),
|
||||
'|',('company_id', '=', company_id),('company_id', '=', False)]]"
|
||||
attrs="{'required': [('bank_account_required', '=', True)]}"/>
|
||||
<field name="bank_account_required" invisible="1"/>
|
||||
<field name="communication_type"/>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!--
|
||||
© 2015-2016 Akretion (http://www.akretion.com/)
|
||||
© 2015-2016 Akretion (https://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<record id="bank_payment_line_form" model="ir.ui.view">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2016 Akretion (<http://www.akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# © 2016 Akretion (<https://www.akretion.com>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, api
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2009 EduSense BV (<http://www.edusense.nl>)
|
||||
# © 2011-2013 Therp BV (<http://therp.nl>)
|
||||
# © 2014-2015 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# © 2015-2016 Akretion (<http://www.akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# © 2011-2013 Therp BV (<https://therp.nl>)
|
||||
# © 2014-2015 ACSONE SA/NV (<https://acsone.eu>)
|
||||
# © 2015-2016 Akretion (<https://www.akretion.com>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2013-2016 Akretion (http://www.akretion.com)
|
||||
© 2013-2016 Akretion (https://www.akretion.com)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
<odoo>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user