mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG] account_bank_statement_clear_partner: Migration to 15.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Clear all partners in bank statement lines",
|
||||
"version": "13.0.1.0.0",
|
||||
"version": "15.0.1.0.0",
|
||||
# see https://odoo-community.org/page/development-status
|
||||
"development_status": "Production/Stable",
|
||||
"category": "Invoicing Management",
|
||||
|
||||
@@ -8,6 +8,6 @@ class AccountBankStatementClearPartner(models.Model):
|
||||
_inherit = "account.bank.statement"
|
||||
|
||||
def clear_partners(self):
|
||||
self.mapped("line_ids").filtered(
|
||||
lambda x: not x.journal_entry_ids and not x.account_id
|
||||
).write({"partner_id": False})
|
||||
for line in self.line_ids:
|
||||
if not line.is_reconciled:
|
||||
line.write({"partner_id": False})
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
* João Marques
|
||||
* Pedro M. Baeza
|
||||
* Carlos Roca
|
||||
* César A. Sánchez
|
||||
|
||||
@@ -5,11 +5,39 @@ from odoo.tests import common
|
||||
|
||||
|
||||
class TestAccountBankStatementClearPartner(common.SavepointCase):
|
||||
@classmethod
|
||||
def setup_multi_currency_data(cls, default_values=None, rate2016=3.0, rate2017=2.0):
|
||||
default_values = default_values or {}
|
||||
foreign_currency = cls.env["res.currency"].search(
|
||||
[("active", "=", False)], limit=1
|
||||
)
|
||||
rate1 = cls.env["res.currency.rate"].create(
|
||||
{
|
||||
"name": "2016-01-01",
|
||||
"rate": rate2016,
|
||||
"currency_id": foreign_currency.id,
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
rate2 = cls.env["res.currency.rate"].create(
|
||||
{
|
||||
"name": "2017-01-01",
|
||||
"rate": rate2017,
|
||||
"currency_id": foreign_currency.id,
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
return {
|
||||
"currency": foreign_currency,
|
||||
"rates": rate1 + rate2,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAccountBankStatementClearPartner, cls).setUpClass()
|
||||
cls.partner_1 = cls.env["res.partner"].create({"name": "Partner 1"})
|
||||
cls.partner_2 = cls.env["res.partner"].create({"name": "Partner 2"})
|
||||
cls.currency_data = cls.setup_multi_currency_data()
|
||||
cls.account_type_1 = cls.env["account.account.type"].create(
|
||||
{"name": "Test Account Type 1", "type": "other", "internal_group": "income"}
|
||||
)
|
||||
@@ -25,26 +53,24 @@ class TestAccountBankStatementClearPartner(common.SavepointCase):
|
||||
{
|
||||
"name": "Test Journal 1",
|
||||
"type": "bank",
|
||||
"sequence_id": cls.sequence_1.id,
|
||||
"secure_sequence_id": cls.sequence_1.id,
|
||||
}
|
||||
)
|
||||
cls.statement_1 = cls.env["account.bank.statement"].create(
|
||||
{"name": "Test Bank Statement 1", "journal_id": cls.journal_1.id}
|
||||
)
|
||||
cls.account_move_1 = cls.env["account.move"].create(
|
||||
{"name": "Test Account Move 1", "journal_id": cls.journal_1.id}
|
||||
)
|
||||
cls.account_move_line_1 = cls.env["account.move.line"].create(
|
||||
{"move_id": cls.account_move_1.id, "account_id": cls.account_1.id}
|
||||
)
|
||||
|
||||
cls.currency_2 = cls.currency_data["currency"]
|
||||
line_obj = cls.env["account.bank.statement.line"]
|
||||
cls.st_line_w_partner_not_reconciled = line_obj.create(
|
||||
{
|
||||
"name": "Test Account Bank Statement 1",
|
||||
"statement_id": cls.statement_1.id,
|
||||
"partner_id": cls.partner_1.id,
|
||||
"journal_entry_ids": False,
|
||||
"account_id": False,
|
||||
"payment_ref": "REF-TEST-1",
|
||||
"foreign_currency_id": cls.currency_2.id,
|
||||
"amount": 1250.0,
|
||||
"amount_currency": 2500.0,
|
||||
}
|
||||
)
|
||||
cls.st_line_wo_partner_not_reconciled = line_obj.create(
|
||||
@@ -52,8 +78,7 @@ class TestAccountBankStatementClearPartner(common.SavepointCase):
|
||||
"name": "Test Account Bank Statement 2",
|
||||
"statement_id": cls.statement_1.id,
|
||||
"partner_id": False,
|
||||
"journal_entry_ids": False,
|
||||
"account_id": False,
|
||||
"payment_ref": "REF-TEST-2",
|
||||
}
|
||||
)
|
||||
cls.st_line_w_partner_reconciled = line_obj.create(
|
||||
@@ -61,10 +86,27 @@ class TestAccountBankStatementClearPartner(common.SavepointCase):
|
||||
"name": "Test Account Bank Statement 3",
|
||||
"statement_id": cls.statement_1.id,
|
||||
"partner_id": cls.partner_2.id,
|
||||
"payment_ref": "REF-TEST-3",
|
||||
}
|
||||
)
|
||||
cls.account_move_line_1.write(
|
||||
{"statement_line_id": cls.st_line_w_partner_reconciled.id}
|
||||
|
||||
cls.account_move_1 = cls.env["account.move"].create(
|
||||
{
|
||||
"move_type": "entry",
|
||||
"journal_id": cls.journal_1.id,
|
||||
"invoice_line_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"name": "50 to pay",
|
||||
"account_id": cls.account_1.id,
|
||||
"amount_residual": 1,
|
||||
"statement_line_id": cls.st_line_w_partner_reconciled.id,
|
||||
},
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
def test_bank_statements_clear_partner(self):
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form" />
|
||||
<field name="arch" type="xml">
|
||||
<button name="action_bank_reconcile_bank_statements" position="after">
|
||||
<button name="button_validate_or_action" position="after">
|
||||
<button
|
||||
name="clear_partners"
|
||||
string="Clear partners"
|
||||
|
||||
Reference in New Issue
Block a user