mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[MIG] account_move_base_import: Migration to 14.0
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
{
|
{
|
||||||
"name": "Journal Entry base import",
|
"name": "Journal Entry base import",
|
||||||
"version": "13.0.1.0.0",
|
"version": "14.0.1.0.0",
|
||||||
"author": "Akretion,Camptocamp,Odoo Community Association (OCA)",
|
"author": "Akretion,Camptocamp,Odoo Community Association (OCA)",
|
||||||
"category": "Finance",
|
"category": "Finance",
|
||||||
"depends": ["account"],
|
"depends": ["account"],
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ class AccountJournal(models.Model):
|
|||||||
|
|
||||||
def _prepare_counterpart_line(self, move, amount, date):
|
def _prepare_counterpart_line(self, move, amount, date):
|
||||||
if amount > 0.0:
|
if amount > 0.0:
|
||||||
account_id = self.default_debit_account_id.id
|
account_id = self.default_account_id.id
|
||||||
credit = 0.0
|
credit = 0.0
|
||||||
debit = amount
|
debit = amount
|
||||||
else:
|
else:
|
||||||
account_id = self.default_credit_account_id.id
|
account_id = self.default_account_id.id
|
||||||
credit = -amount
|
credit = -amount
|
||||||
debit = 0.0
|
debit = 0.0
|
||||||
counterpart_values = {
|
counterpart_values = {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class AccountMoveCompletionRule(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
invoices = inv_obj.search(
|
invoices = inv_obj.search(
|
||||||
[(number_field, "=", line.name.strip()), ("type", "in", type_domain)]
|
[(number_field, "=", line.name.strip()), ("move_type", "in", type_domain)]
|
||||||
)
|
)
|
||||||
if invoices:
|
if invoices:
|
||||||
if len(invoices) == 1:
|
if len(invoices) == 1:
|
||||||
@@ -169,6 +169,7 @@ class AccountMoveCompletionRule(models.Model):
|
|||||||
res = {}
|
res = {}
|
||||||
partner_obj = self.env["res.partner"]
|
partner_obj = self.env["res.partner"]
|
||||||
or_regex = ".*;? *%s *;?.*" % line.name
|
or_regex = ".*;? *%s *;?.*" % line.name
|
||||||
|
self.env["res.partner"].flush(["bank_statement_label"])
|
||||||
sql = "SELECT id from res_partner" " WHERE bank_statement_label ~* %s"
|
sql = "SELECT id from res_partner" " WHERE bank_statement_label ~* %s"
|
||||||
self.env.cr.execute(sql, (or_regex,))
|
self.env.cr.execute(sql, (or_regex,))
|
||||||
partner_ids = self.env.cr.fetchall()
|
partner_ids = self.env.cr.fetchall()
|
||||||
@@ -207,6 +208,7 @@ class AccountMoveCompletionRule(models.Model):
|
|||||||
# to:
|
# to:
|
||||||
# http://www.postgresql.org/docs/9.0/static/functions-matching.html
|
# http://www.postgresql.org/docs/9.0/static/functions-matching.html
|
||||||
# in chapter 9.7.3.6. Limits and Compatibility
|
# in chapter 9.7.3.6. Limits and Compatibility
|
||||||
|
self.env["res.partner"].flush(["name"])
|
||||||
sql = r"""
|
sql = r"""
|
||||||
SELECT id FROM (
|
SELECT id FROM (
|
||||||
SELECT id,
|
SELECT id,
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class FileParser(AccountMoveImportParser):
|
|||||||
csv_file = tempfile.NamedTemporaryFile()
|
csv_file = tempfile.NamedTemporaryFile()
|
||||||
csv_file.write(self.filebuffer)
|
csv_file.write(self.filebuffer)
|
||||||
csv_file.flush()
|
csv_file.flush()
|
||||||
with open(csv_file.name, "rU") as fobj:
|
with open(csv_file.name, "r") as fobj:
|
||||||
reader = UnicodeDictReader(
|
reader = UnicodeDictReader(
|
||||||
fobj, fieldnames=self.fieldnames, dialect=self.dialect
|
fobj, fieldnames=self.fieldnames, dialect=self.dialect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import base64
|
import base64
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
from openerp import _, fields
|
from odoo import _, fields
|
||||||
|
|
||||||
|
|
||||||
def UnicodeDictReader(utf8_data, **kwargs):
|
def UnicodeDictReader(utf8_data, **kwargs):
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_account_bank_st_cmpl_user,account.move.completion.rule.user,model_account_move_completion_rule,account.group_account_user,1,0,0,0
|
access_account_bank_st_cmpl_user,account.move.completion.rule.user,model_account_move_completion_rule,account.group_account_user,1,0,0,0
|
||||||
access_account_bank_st_cmpl_manager,account.move.completion.rule.manager,model_account_move_completion_rule,account.group_account_manager,1,1,1,1
|
access_account_bank_st_cmpl_manager,account.move.completion.rule.manager,model_account_move_completion_rule,account.group_account_manager,1,1,1,1
|
||||||
|
access_credit_statement_mport_user,credit.statement.import.rule.user,model_credit_statement_import,account.group_account_user,1,1,1,1
|
||||||
|
|||||||
|
@@ -5,9 +5,10 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from odoo import fields, tools
|
import odoo.tests
|
||||||
from odoo.modules import get_resource_path
|
from odoo import fields
|
||||||
from odoo.tests import common
|
|
||||||
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
name_completion_case = namedtuple(
|
name_completion_case = namedtuple(
|
||||||
"name_completion_case", ["partner_name", "line_label", "should_match"]
|
"name_completion_case", ["partner_name", "line_label", "should_match"]
|
||||||
@@ -39,24 +40,16 @@ NAMES_COMPLETION_CASES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class BaseCompletion(common.TransactionCase):
|
@odoo.tests.tagged("post_install", "-at_install")
|
||||||
def setUp(self):
|
class BaseCompletion(AccountTestInvoicingCommon):
|
||||||
super().setUp()
|
@classmethod
|
||||||
tools.convert_file(
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
self.cr,
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
"account",
|
cls.account_move_obj = cls.env["account.move"]
|
||||||
get_resource_path("account", "test", "account_minimal_test.xml"),
|
cls.account_move_line_obj = cls.env["account.move.line"]
|
||||||
{},
|
cls.journal = cls.company_data["default_journal_bank"]
|
||||||
"init",
|
cls.partner = cls.env.ref("base.res_partner_12")
|
||||||
False,
|
cls.account_id = cls.journal.default_account_id.id
|
||||||
"test",
|
|
||||||
)
|
|
||||||
self.account_move_obj = self.env["account.move"]
|
|
||||||
self.account_move_line_obj = self.env["account.move.line"]
|
|
||||||
self.company_a = self.browse_ref("base.main_company")
|
|
||||||
self.journal = self.browse_ref("account.bank_journal")
|
|
||||||
self.partner = self.browse_ref("base.res_partner_12")
|
|
||||||
self.account_id = self.ref("account.a_recv")
|
|
||||||
|
|
||||||
def test_name_completion(self):
|
def test_name_completion(self):
|
||||||
"""Test complete partner_id from statement line label
|
"""Test complete partner_id from statement line label
|
||||||
@@ -73,7 +66,7 @@ class BaseCompletion(common.TransactionCase):
|
|||||||
"rule_ids": [(6, 0, [self.completion_rule_id])],
|
"rule_ids": [(6, 0, [self.completion_rule_id])],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# Create a bank statement
|
# Create an account move
|
||||||
self.move = self.account_move_obj.create(
|
self.move = self.account_move_obj.create(
|
||||||
{"date": fields.Date.today(), "journal_id": self.journal.id}
|
{"date": fields.Date.today(), "journal_id": self.journal.id}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,37 +7,31 @@ import base64
|
|||||||
import os
|
import os
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
from odoo import fields, tools
|
import odoo.tests
|
||||||
|
from odoo import fields
|
||||||
from odoo.modules import get_resource_path
|
from odoo.modules import get_resource_path
|
||||||
from odoo.tests import common
|
|
||||||
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
|
|
||||||
class TestCodaImport(common.TransactionCase):
|
@odoo.tests.tagged("post_install", "-at_install")
|
||||||
def setUp(self):
|
class TestCodaImport(AccountTestInvoicingCommon):
|
||||||
super().setUp()
|
@classmethod
|
||||||
self.company_a = self.browse_ref("base.main_company")
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
tools.convert_file(
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
self.cr,
|
cls.account_move_obj = cls.env["account.move"]
|
||||||
"account",
|
cls.account_move_line_obj = cls.env["account.move.line"]
|
||||||
get_resource_path("account", "test", "account_minimal_test.xml"),
|
cls.journal = cls.company_data["default_journal_bank"]
|
||||||
{},
|
cls.partner = cls.env.ref("base.res_partner_12")
|
||||||
"init",
|
cls.account_id = cls.journal.default_account_id.id
|
||||||
False,
|
cls.import_wizard_obj = cls.env["credit.statement.import"]
|
||||||
"test",
|
cls.journal.write(
|
||||||
)
|
|
||||||
self.account_move_obj = self.env["account.move"]
|
|
||||||
self.account_move_line_obj = self.env["account.move.line"]
|
|
||||||
self.account_id = self.ref("account.a_recv")
|
|
||||||
self.journal = self.browse_ref("account.bank_journal")
|
|
||||||
self.import_wizard_obj = self.env["credit.statement.import"]
|
|
||||||
self.partner = self.browse_ref("base.res_partner_12")
|
|
||||||
self.journal.write(
|
|
||||||
{
|
{
|
||||||
"used_for_import": True,
|
"used_for_import": True,
|
||||||
"import_type": "generic_csvxls_so",
|
"import_type": "generic_csvxls_so",
|
||||||
"partner_id": self.partner.id,
|
"partner_id": cls.partner.id,
|
||||||
"commission_account_id": self.account_id,
|
"commission_account_id": cls.account_id,
|
||||||
"receivable_account_id": self.account_id,
|
"receivable_account_id": cls.account_id,
|
||||||
"create_counterpart": True,
|
"create_counterpart": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,195 +1,51 @@
|
|||||||
# Copyright 2019 Camptocamp SA
|
# Copyright 2019 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||||
|
import odoo.tests
|
||||||
from odoo import fields
|
from odoo import fields
|
||||||
from odoo.modules import get_resource_path
|
|
||||||
from odoo.tests import SingleTransactionCase
|
from odoo.addons.account.tests.common import TestAccountReconciliationCommon
|
||||||
from odoo.tools import convert_file
|
|
||||||
|
|
||||||
|
|
||||||
class TestInvoice(SingleTransactionCase):
|
@odoo.tests.tagged("post_install", "-at_install")
|
||||||
def setUp(self):
|
class TestInvoice(TestAccountReconciliationCommon):
|
||||||
super().setUp()
|
@classmethod
|
||||||
self.account_move_obj = self.env["account.move"]
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
self.account_move_line_obj = self.env["account.move.line"]
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
self.company_a = self.env.ref("base.main_company")
|
cls.account_move_obj = cls.env["account.move"]
|
||||||
self.partner = self.env.ref("base.res_partner_12")
|
cls.account_move_line_obj = cls.env["account.move.line"]
|
||||||
|
cls.journal = cls.company_data["default_journal_bank"]
|
||||||
|
cls.account_id = cls.journal.default_account_id.id
|
||||||
|
|
||||||
def test_01_partner(self):
|
def test_all_completion_rules(self):
|
||||||
# I fill in the field Bank Statement Label in a Partner
|
# I fill in the field Bank Statement Label in a Partner
|
||||||
self.partner_4 = self.env.ref("base.res_partner_4")
|
self.partner_4 = self.env.ref("base.res_partner_4")
|
||||||
self.partner_4.bank_statement_label = "XXX66Z"
|
self.partner_4.bank_statement_label = "XXX66Z"
|
||||||
self.assertEqual(self.partner_4.bank_statement_label, "XXX66Z")
|
self.assertEqual(self.partner_4.bank_statement_label, "XXX66Z")
|
||||||
|
|
||||||
def test_02_invoice(self):
|
self.invoice_for_completion_1 = self._create_invoice(
|
||||||
convert_file(
|
date_invoice=fields.Date.today(), auto_validate=True
|
||||||
self.cr,
|
|
||||||
"account",
|
|
||||||
get_resource_path("account", "test", "account_minimal_test.xml"),
|
|
||||||
{},
|
|
||||||
"init",
|
|
||||||
False,
|
|
||||||
"test",
|
|
||||||
)
|
)
|
||||||
self.journal = self.env.ref("account.bank_journal")
|
|
||||||
self.account_id = self.env.ref("account.a_recv")
|
|
||||||
# I create a customer Invoice to be found by the completion.
|
|
||||||
product_3 = self.env.ref("product.product_product_3")
|
|
||||||
self.invoice_for_completion_1 = (
|
|
||||||
self.env["account.move"]
|
|
||||||
.with_context(default_type="out_invoice")
|
|
||||||
.create(
|
|
||||||
{
|
|
||||||
"currency_id": self.env.ref("base.EUR").id,
|
|
||||||
"type": "out_invoice",
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "[PCSC234] PC Assemble SC234",
|
|
||||||
"product_id": product_3.id,
|
|
||||||
"price_unit": 210.0,
|
|
||||||
"quantity": 1.0,
|
|
||||||
"product_uom_id": self.env.ref(
|
|
||||||
"uom.product_uom_unit"
|
|
||||||
).id,
|
|
||||||
"account_id": self.env.ref("account.a_sale").id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
"journal_id": self.journal.id,
|
|
||||||
"partner_id": self.partner.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# I confirm the Invoice
|
|
||||||
self.invoice_for_completion_1.post()
|
|
||||||
# I check that the invoice state is "Open"
|
|
||||||
self.assertEqual(self.invoice_for_completion_1.state, "posted")
|
self.assertEqual(self.invoice_for_completion_1.state, "posted")
|
||||||
# I check that it is given the number "TBNK/%Y/0001"
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.invoice_for_completion_1.name,
|
self.invoice_for_completion_1.name,
|
||||||
fields.Date.today().strftime("TBNK/%Y/0001"),
|
fields.Date.today().strftime("INV/%Y/%m/0001"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_03_supplier_invoice(self):
|
self.demo_invoice_0 = self._create_invoice(
|
||||||
# I create a demo invoice
|
move_type="in_invoice", auto_validate=True
|
||||||
product_delivery = self.env.ref("product.product_delivery_01")
|
|
||||||
product_order = self.env.ref("product.product_order_01")
|
|
||||||
exp_account = self.env.ref("account.a_expense")
|
|
||||||
demo_invoice_0 = (
|
|
||||||
self.env["account.move"]
|
|
||||||
.with_context(default_type="in_invoice")
|
|
||||||
.create(
|
|
||||||
{
|
|
||||||
"partner_id": self.partner.id,
|
|
||||||
"invoice_payment_term_id": self.env.ref(
|
|
||||||
"account.account_payment_term_advance"
|
|
||||||
).id,
|
|
||||||
"type": "in_invoice",
|
|
||||||
"invoice_date": fields.Date.today().replace(day=1),
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"price_unit": 10.0,
|
|
||||||
"quantity": 1.0,
|
|
||||||
"product_id": product_delivery.id,
|
|
||||||
"product_uom_id": self.env.ref(
|
|
||||||
"uom.product_uom_unit"
|
|
||||||
).id,
|
|
||||||
"name": product_delivery.name,
|
|
||||||
"account_id": exp_account.id,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"price_unit": 4.0,
|
|
||||||
"quantity": 1.0,
|
|
||||||
"product_id": product_order.id,
|
|
||||||
"name": product_order.name,
|
|
||||||
"product_uom_id": self.env.ref(
|
|
||||||
"uom.product_uom_unit"
|
|
||||||
).id,
|
|
||||||
"account_id": exp_account.id,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
self.demo_invoice_0.ref = "T2S12345"
|
||||||
|
|
||||||
# I check that my invoice is a supplier invoice
|
self.refund_for_completion_1 = self._create_invoice(
|
||||||
self.assertEqual(demo_invoice_0.type, "in_invoice", msg="Check invoice type")
|
move_type="out_refund", date_invoice=fields.Date.today(), auto_validate=True
|
||||||
# I add a reference to an existing supplier invoice
|
|
||||||
demo_invoice_0.write({"ref": "T2S12345"})
|
|
||||||
# I check a second time that my invoice is still a supplier invoice
|
|
||||||
self.assertEqual(demo_invoice_0.type, "in_invoice", msg="Check invoice type 2")
|
|
||||||
# Now I confirm it
|
|
||||||
demo_invoice_0.post()
|
|
||||||
# I check that the supplier number is there
|
|
||||||
self.assertEqual(demo_invoice_0.ref, "T2S12345", msg="Check supplier number")
|
|
||||||
# I check a third time that my invoice is still a supplier invoice
|
|
||||||
self.assertEqual(demo_invoice_0.type, "in_invoice", msg="Check invoice type 3")
|
|
||||||
|
|
||||||
def test_04_refund(self):
|
|
||||||
# I create a "child" partner, to use in the invoice
|
|
||||||
# (and have a different commercial_partner_id than itself)
|
|
||||||
res_partner_12_child = self.env["res.partner"].create(
|
|
||||||
{
|
|
||||||
"name": "Child Partner",
|
|
||||||
"is_company": False,
|
|
||||||
"parent_id": self.partner.id,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
# I create a customer refund to be found by the completion.
|
|
||||||
product_3 = self.env.ref("product.product_product_3")
|
|
||||||
self.refund_for_completion_1 = (
|
|
||||||
self.env["account.move"]
|
|
||||||
.with_context(default_type="out_refund")
|
|
||||||
.create(
|
|
||||||
{
|
|
||||||
"currency_id": self.env.ref("base.EUR").id,
|
|
||||||
"invoice_line_ids": [
|
|
||||||
(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
{
|
|
||||||
"name": "[PCSC234] PC Assemble SC234",
|
|
||||||
"product_id": product_3.id,
|
|
||||||
"price_unit": 210.0,
|
|
||||||
"quantity": 1.0,
|
|
||||||
"product_uom_id": self.env.ref(
|
|
||||||
"uom.product_uom_unit"
|
|
||||||
).id,
|
|
||||||
"account_id": self.env.ref("account.a_sale").id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
"journal_id": self.env.ref("account.expenses_journal").id,
|
|
||||||
"partner_id": res_partner_12_child.id,
|
|
||||||
"type": "out_refund",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# I confirm the refund
|
|
||||||
self.refund_for_completion_1.post()
|
|
||||||
|
|
||||||
# I check that the refund state is "Open"
|
|
||||||
self.assertEqual(self.refund_for_completion_1.state, "posted")
|
|
||||||
# I check that it is given the number "RTEXJ/%Y/0001"
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.refund_for_completion_1.name,
|
self.refund_for_completion_1.name,
|
||||||
fields.Date.today().strftime("RTEXJ/%Y/0001"),
|
fields.Date.today().strftime("RINV/%Y/%m/0001"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_05_completion(self):
|
|
||||||
# In order to test the banking framework, I first need to create a
|
# In order to test the banking framework, I first need to create a
|
||||||
# journal
|
# journal
|
||||||
self.journal = self.env.ref("account.bank_journal")
|
|
||||||
completion_rule_4 = self.env.ref(
|
completion_rule_4 = self.env.ref(
|
||||||
"account_move_base_import.bank_statement_completion_rule_4"
|
"account_move_base_import.bank_statement_completion_rule_4"
|
||||||
)
|
)
|
||||||
@@ -230,7 +86,7 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
.create(
|
.create(
|
||||||
{
|
{
|
||||||
"name": "\\",
|
"name": "\\",
|
||||||
"account_id": self.env.ref("account.a_sale").id,
|
"account_id": self.company_data["default_account_receivable"].id,
|
||||||
"move_id": move_test1.id,
|
"move_id": move_test1.id,
|
||||||
"date_maturity": fields.Date.from_string("2013-12-20"),
|
"date_maturity": fields.Date.from_string("2013-12-20"),
|
||||||
"credit": 0.0,
|
"credit": 0.0,
|
||||||
@@ -244,7 +100,7 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
.create(
|
.create(
|
||||||
{
|
{
|
||||||
"name": "\\",
|
"name": "\\",
|
||||||
"account_id": self.env.ref("account.a_expense").id,
|
"account_id": self.company_data["default_account_expense"].id,
|
||||||
"move_id": move_test1.id,
|
"move_id": move_test1.id,
|
||||||
"date_maturity": fields.Date.from_string("2013-12-19"),
|
"date_maturity": fields.Date.from_string("2013-12-19"),
|
||||||
"debit": 0.0,
|
"debit": 0.0,
|
||||||
@@ -258,7 +114,7 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
.create(
|
.create(
|
||||||
{
|
{
|
||||||
"name": "\\",
|
"name": "\\",
|
||||||
"account_id": self.env.ref("account.a_expense").id,
|
"account_id": self.company_data["default_account_expense"].id,
|
||||||
"move_id": move_test1.id,
|
"move_id": move_test1.id,
|
||||||
"date_maturity": fields.Date.from_string("2013-12-19"),
|
"date_maturity": fields.Date.from_string("2013-12-19"),
|
||||||
"debit": 0.0,
|
"debit": 0.0,
|
||||||
@@ -271,8 +127,8 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
.with_context(check_move_validity=False)
|
.with_context(check_move_validity=False)
|
||||||
.create(
|
.create(
|
||||||
{
|
{
|
||||||
"name": "Test autocompletion based on Partner Name Azure Interior",
|
"name": "Test autocompletion based on Partner Name Deco Addict",
|
||||||
"account_id": self.env.ref("account.a_sale").id,
|
"account_id": self.company_data["default_account_receivable"].id,
|
||||||
"move_id": move_test1.id,
|
"move_id": move_test1.id,
|
||||||
"date_maturity": fields.Date.from_string("2013-12-17"),
|
"date_maturity": fields.Date.from_string("2013-12-17"),
|
||||||
"credit": 0.0,
|
"credit": 0.0,
|
||||||
@@ -286,7 +142,7 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
.create(
|
.create(
|
||||||
{
|
{
|
||||||
"name": "XXX66Z",
|
"name": "XXX66Z",
|
||||||
"account_id": self.env.ref("account.a_sale").id,
|
"account_id": self.company_data["default_account_receivable"].id,
|
||||||
"move_id": move_test1.id,
|
"move_id": move_test1.id,
|
||||||
"date_maturity": "2013-12-24",
|
"date_maturity": "2013-12-24",
|
||||||
"debit": 0.0,
|
"debit": 0.0,
|
||||||
@@ -295,13 +151,13 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
)
|
)
|
||||||
# and add the correct name
|
# and add the correct name
|
||||||
move_line_ci.with_context(check_move_validity=False).write(
|
move_line_ci.with_context(check_move_validity=False).write(
|
||||||
{"name": fields.Date.today().strftime("TBNK/%Y/0001"), "credit": 210.0}
|
{"name": fields.Date.today().strftime("INV/%Y/%m/0001"), "credit": 210.0}
|
||||||
)
|
)
|
||||||
move_line_si.with_context(check_move_validity=False).write(
|
move_line_si.with_context(check_move_validity=False).write(
|
||||||
{"name": "T2S12345", "debit": 65.0}
|
{"name": "T2S12345", "debit": 65.0}
|
||||||
)
|
)
|
||||||
move_line_cr.with_context(check_move_validity=False).write(
|
move_line_cr.with_context(check_move_validity=False).write(
|
||||||
{"name": fields.Date.today().strftime("RTEXJ/%Y/0001"), "debit": 210.0}
|
{"name": fields.Date.today().strftime("RINV/%Y/%m/0001"), "debit": 210.0}
|
||||||
)
|
)
|
||||||
move_line_partner_name.with_context(check_move_validity=False).write(
|
move_line_partner_name.with_context(check_move_validity=False).write(
|
||||||
{"credit": 600.0}
|
{"credit": 600.0}
|
||||||
@@ -316,25 +172,29 @@ class TestInvoice(SingleTransactionCase):
|
|||||||
# I Use _ref, because ref conflicts with the field ref of the
|
# I Use _ref, because ref conflicts with the field ref of the
|
||||||
# statement line
|
# statement line
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
move_line_ci.partner_id, self.partner, msg="Check completion by CI number"
|
move_line_ci.partner_id.id,
|
||||||
|
self.partner_agrolait_id,
|
||||||
|
msg="Check completion by CI number",
|
||||||
)
|
)
|
||||||
# Line 2. I expect the Supplier invoice number to be recognised. The
|
# Line 2. I expect the Supplier invoice number to be recognised. The
|
||||||
# supplier invoice was created by the account module demo data, and we
|
# supplier invoice was created by the account module demo data, and we
|
||||||
# confirmed it here.
|
# confirmed it here.
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
move_line_si.partner_id, self.partner, msg="Check completion by SI number"
|
move_line_si.partner_id.id,
|
||||||
|
self.partner_agrolait_id,
|
||||||
|
msg="Check completion by SI number",
|
||||||
)
|
)
|
||||||
# Line 3. I expect the Customer refund number to be recognised. It
|
# Line 3. I expect the Customer refund number to be recognised. It
|
||||||
# should be the commercial partner, and not the regular partner.
|
# should be the commercial partner, and not the regular partner.
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
move_line_cr.partner_id,
|
move_line_cr.partner_id.id,
|
||||||
self.partner,
|
self.partner_agrolait_id,
|
||||||
msg="Check completion by CR number and commercial partner",
|
msg="Check completion by CR number and commercial partner",
|
||||||
)
|
)
|
||||||
# Line 4. I check that the partner name has been recognised.
|
# Line 4. I check that the partner name has been recognised.
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
move_line_partner_name.partner_id.name,
|
move_line_partner_name.partner_id.name,
|
||||||
"Azure Interior",
|
"Deco Addict",
|
||||||
msg="Check completion by partner name",
|
msg="Check completion by partner name",
|
||||||
)
|
)
|
||||||
# Line 5. I check that the partner special label has been recognised.
|
# Line 5. I check that the partner special label has been recognised.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<field name="journal_id" position="after">
|
<field name="journal_id" position="after">
|
||||||
<field name="used_for_completion" invisible="1" />
|
<field name="used_for_completion" invisible="1" />
|
||||||
</field>
|
</field>
|
||||||
<button name="action_duplicate" position="after">
|
<button name="action_reverse" position="after">
|
||||||
<button
|
<button
|
||||||
name="button_auto_completion"
|
name="button_auto_completion"
|
||||||
string="Auto Completion"
|
string="Auto Completion"
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
<menuitem
|
<menuitem
|
||||||
string="Move Completion Rule"
|
name="Move Completion Rule"
|
||||||
action="action_move_completion_rule_tree"
|
action="action_move_completion_rule_tree"
|
||||||
id="menu_action_move_completion_rule_tree_menu"
|
id="menu_action_move_completion_rule_tree_menu"
|
||||||
parent="account.account_management_menu"
|
parent="account.account_management_menu"
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class CreditPartnerStatementImporter(models.TransientModel):
|
|||||||
moves |= journal.with_context(
|
moves |= journal.with_context(
|
||||||
file_name=importer.file_name
|
file_name=importer.file_name
|
||||||
).multi_move_import(importer.input_statement, ftype.replace(".", ""))
|
).multi_move_import(importer.input_statement, ftype.replace(".", ""))
|
||||||
xmlid = ("account", "action_move_journal_line")
|
action = action = self.env["ir.actions.actions"]._for_xml_id(
|
||||||
action = self.env["ir.actions.act_window"].for_xml_id(*xmlid)
|
"account.action_move_journal_line")
|
||||||
if len(moves) > 1:
|
if len(moves) > 1:
|
||||||
action["domain"] = [("id", "in", moves.ids)]
|
action["domain"] = [("id", "in", moves.ids)]
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user