[MIG] account_move_transactionid_import to 12.0

This commit is contained in:
Thierry Ducrest
2019-07-11 15:09:49 +02:00
committed by Yannick Vaucher
parent 56c29255fe
commit 99825230fe
15 changed files with 166 additions and 164 deletions

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import parser

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
'name': "Journal Entry transactionID import",
'version': '9.0.1.0.0',
'version': '12.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'maintainer': 'Camptocamp',
'category': 'Finance',
@@ -15,14 +14,8 @@
'data': [
'data/completion_rule_data.xml'
],
'test': [
'test/sale.yml',
'test/completion_transactionid_test.yml',
'test/invoice.yml',
'test/completion_invoice_transactionid_test.yml',
],
'website': 'http://www.camptocamp.com',
'installable': False,
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
}

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import account_journal

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# © 2011-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import fields, models
from odoo import fields, models
class AccountJournal(models.Model):

View File

@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# © 2011-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import _, fields, models
from openerp.addons.account_move_base_import.models.account_move import \
from odoo import _, fields, models
from odoo.addons.account_move_base_import.models.account_move import \
ErrorTooManyPartner
@@ -41,8 +40,7 @@ class AccountMoveCompletionRule(models.Model):
_('Line named "%s" was matched by more than '
'one partner.') % line.name)
if len(sales) == 1:
sale = sales[0]
res['partner_id'] = sale.partner_id.id
res['partner_id'] = sales[0].partner_id.id
return res
def get_from_transaction_id_and_invoice(self, line):

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import transactionid_file_parser

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# © 2011-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import datetime
from openerp.tools import ustr
from openerp.addons.account_move_base_import.parser.file_parser import (
from odoo.tools import ustr
from odoo.addons.account_move_base_import.parser.file_parser import (
FileParser, float_or_zero
)
@@ -30,7 +29,7 @@ class TransactionIDFileParser(FileParser):
'amount': float_or_zero,
'commission_amount': float_or_zero,
}
super(TransactionIDFileParser, self).__init__(
super().__init__(
profile, extra_fields=conversion_dict, ftype=ftype, header=header,
**kwargs)

View File

@@ -0,0 +1,2 @@
* Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
* Matthieu Dietrich <matthieu.dietrich@camptocamp.com>

View File

@@ -0,0 +1,4 @@
This module extends the functionality of
account_move_base_import, in order to add both importation
and auto-completion for the "transaction_ref" field added in
base_transaction_id.

View File

@@ -1,44 +0,0 @@
-
In order to test the banking framework, I first need to create a journal
-
!record {model: account.journal, id: account.bank_journal}:
used_for_completion: True
rule_ids:
- bank_statement_completion_rule_trans_id_invoice
-
Now I create a move. I create statment lines separately because I need
to find each one by XML id
-
!record {model: account.move, id: move_invoice_transactionid_test1}:
name: Move with transaction ID
journal_id: account.bank_journal
company_id: base.main_company
-
I create a move line for a SO with transaction ID
-
!record {model: account.move.line, id: move_line_invoice_transactionid}:
name: Test autocompletion based on invoice with transaction ID
account_id: account.a_sale
move_id: move_invoice_transactionid_test1
transaction_ref: XXX77Z
date_maturity: !eval time.strftime('%Y-%m-%d')
credit: 0.0
-
and add the correct amount
-
!python {model: account.move.line}: |
context['check_move_validity'] = False
model.write(cr, uid, [ref('move_line_invoice_transactionid')],
{'credit': 450.0},
context)
-
I run the auto complete
-
!python {model: account.move}: |
result = self.button_auto_completion(cr, uid, [ref("move_invoice_transactionid_test1")])
-
Now I can check that all is nice and shiny, line 1. I expect the invoice has been
recognised from the transaction ID.
-
!assert {model: account.move.line, id: move_line_invoice_transactionid, string: Check completion by Invoice transaction ID}:
- partner_id.name == u'Agrolait'

View File

@@ -1,48 +0,0 @@
-
In order to test the banking framework, I first need to create a journal
-
!record {model: account.journal, id: account.bank_journal}:
used_for_completion: True
rule_ids:
- bank_statement_completion_rule_4
- account_move_base_import.bank_statement_completion_rule_4
- account_move_base_import.bank_statement_completion_rule_5
- account_move_base_import.bank_statement_completion_rule_2
- account_move_base_import.bank_statement_completion_rule_3
-
Now I create a move. I create statment lines separately because I need
to find each one by XML id
-
!record {model: account.move, id: move_transactionid_test1}:
name: Move with transaction ID
journal_id: account.bank_journal
company_id: base.main_company
-
I create a move line for a SO with transaction ID
-
!record {model: account.move.line, id: move_line_transactionid}:
name: Test autocompletion based on SO with transaction ID
account_id: account.a_sale
move_id: move_transactionid_test1
transaction_ref: XXX66Z
date_maturity: !eval "'%s-01-06' %(datetime.now().year)"
credit: 0.0
-
and add the correct amount
-
!python {model: account.move.line}: |
context['check_move_validity'] = False
model.write(cr, uid, [ref('move_line_transactionid')],
{'credit': 118.4},
context)
-
I run the auto complete
-
!python {model: account.move}: |
result = self.button_auto_completion(cr, uid, [ref("move_transactionid_test1")])
-
Now I can check that all is nice and shiny, line 1. I expect the SO has been
recognised from the transaction ID.
-
!assert {model: account.move.line, id: move_line_transactionid, string: Check completion by SO transaction ID}:
- partner_id.name == u'Agrolait'

View File

@@ -1,25 +0,0 @@
-
I create a new invoice with transaction ID
-
!record {model: account.invoice, id: invoice_with_transaction_id}:
company_id: base.main_company
currency_id: base.EUR
partner_id: base.res_partner_2
transaction_id: XXX77Z
invoice_line_ids:
- name: '[PCSC234] PC Assemble SC234'
price_unit: 450.0
quantity: 1.0
product_id: product.product_product_3
uom_id: product.product_uom_unit
journal_id: account.bank_journal
reference_type: none
-
I confirm the Invoice
-
!workflow {model: account.invoice, action: invoice_open, ref: invoice_with_transaction_id}
-
I check that the invoice state is "Open"
-
!assert {model: account.invoice, id: invoice_with_transaction_id}:
- state == 'open'

View File

@@ -1,21 +0,0 @@
-
I import account minimal data
-
!python {model: account.invoice}: |
openerp.tools.convert_file(cr,
'account',
openerp.modules.get_module_resource(
'account',
'test',
'account_minimal_test.xml'),
{}, 'init', False, 'test')
-
I create a new Sale Order with transaction ID
-
!record {model: sale.order, id: so_with_transaction_id}:
partner_id: base.res_partner_2
note: Invoice after delivery
transaction_id: XXX66Z
order_line:
- product_id: product.product_product_7
product_uom_qty: 8

View File

@@ -0,0 +1 @@
from . import test_completion_transaction_id

View File

@@ -0,0 +1,147 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from datetime import datetime
from odoo.modules import get_resource_path
from odoo.tests import SingleTransactionCase
from odoo.tools import convert_file
class TestCompletionTransactionId(SingleTransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
convert_file(
cls.cr,
'account',
get_resource_path('account', 'test', 'account_minimal_test.xml'),
{},
'init',
False,
'test',
)
cls.partner = cls.env.ref('base.res_partner_2')
cls.journal = cls.env.ref('account.bank_journal')
cls.journal.used_for_completion = True
cls.move = cls.env['account.move'].create(
{'name': 'Move with transaction ID', 'journal_id': cls.journal.id}
)
cls.move_line = cls.env['account.move.line'].create(
{
'name': 'Test autocompletion on invoice with transaction ID',
'account_id': cls.env.ref('account.a_sale').id,
'move_id': cls.move.id,
'transaction_ref': 'XXX66Z',
'date_maturity': '{}-01-06'.format(datetime.now().year),
'credit': 0.0,
}
)
def test_sale_order_transaction_id(self):
self.move_line.transaction_ref = 'XXX66Z'
self.journal.rule_ids = [
(
4,
self.env.ref(
'account_move_transactionid_import.'
'bank_statement_completion_rule_4'
).id,
False,
),
(
4,
self.env.ref(
'account_move_base_import.bank_statement_completion_rule_2'
).id,
False,
),
(
4,
self.env.ref(
'account_move_base_import.bank_statement_completion_rule_3'
).id,
False,
),
(
4,
self.env.ref(
'account_move_base_import.bank_statement_completion_rule_4'
).id,
False,
),
(
4,
self.env.ref(
'account_move_base_import.bank_statement_completion_rule_5'
).id,
False,
),
]
self.move_line.with_context({'check_move_validity': False}).write(
{'credit': 118.4}
)
so = self.env['sale.order'].create(
{
'partner_id': self.partner.id,
'note': 'Invoice after delivery',
'transaction_id': 'XXX66Z',
'order_line': [
(
0,
0,
{
'product_id': self.env.ref(
'product.product_product_7'
).id,
'product_uom_qty': 8,
},
)
],
}
)
self.assertEqual(so.transaction_id, 'XXX66Z')
self.move.button_auto_completion()
self.assertEqual(self.move_line.partner_id.name, self.partner.name)
def test_new_invoice_with_transaction_id(self):
self.move_line.transaction_ref = 'XXX77Z'
self.move_line.partner_id = None
self.journal.rule_ids = [
(
4,
self.env.ref(
'account_move_transactionid_import.'
'bank_statement_completion_rule_trans_id_invoice'
).id,
False,
)
]
invoice = self.env['account.invoice'].create(
{
'currency_id': self.env.ref('base.EUR').id,
'partner_id': self.partner.id,
'transaction_id': 'XXX77Z',
'reference_type': None,
'journal_id': self.journal.id,
'invoice_line_ids': [
(
0,
0,
{
'name': '[PCSC234] PC Assemble SC234',
'price_unit': 450.0,
'quantity': 1.0,
'product_id': self.env.ref(
'product.product_product_3'
).id,
'uom_id': self.env.ref('uom.product_uom_unit').id,
'account_id': self.env.ref('account.a_sale').id,
},
)
],
}
)
invoice.action_invoice_open()
self.assertEqual(invoice.state, 'open')
self.move.button_auto_completion()
self.assertEqual(self.move_line.partner_id, self.partner)