[12.0][MIG] account_move_so_import: migrate

pull/283/head
Iryna Vyshnevska 2019-07-10 19:53:00 +03:00 committed by OCA-git-bot
parent f42e553855
commit 50372dedfc
8 changed files with 85 additions and 74 deletions

View File

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

View File

@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# Copyright 2011-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
'name': "Journal Entry Sale Order completion",
'version': '9.0.1.0.0',
'version': '12.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'maintainer': 'Camptocamp',
'category': 'Finance',
@ -13,10 +12,7 @@
'data': [
'data/completion_rule_data.xml',
],
'test': [
'test/completion_so_test.yml'],
'installable': False,
'images': [],
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
}

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# Copyright 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 \
from odoo import _, fields, models
from odoo.addons.account_move_base_import.models.account_move \
import ErrorTooManyPartner
@ -16,7 +15,7 @@ class AccountMoveCompletionRule(models.Model):
('get_from_name_and_so', 'From line name (based on SO number)')
])
# Should be private but data are initialised with no update XML
# Should be private but data are initialized with no update XML
def get_from_name_and_so(self, line):
"""
Match the partner based on the SO number and the reference of the

View File

@ -0,0 +1,3 @@
* Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
* Leonardo Pistone <leonardo.pistone@camptocamp.com>
* Matthieu Dietrich <matthieu.dietrich@camptocamp.com>

View File

@ -0,0 +1,4 @@
This module extends the functionality of account_move_base_import
to add support for completion rules based on Sale Orders. This was initially
part of the module account_statement_base_completion, but is now separate to
keep dependencies separate.

View File

@ -1,59 +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')
-
In order to test the banking framework for Sale Orders, I first need to
create a profile
-
!record {model: account.journal, id: account.bank_journal}:
used_for_completion: True
rule_ids:
- 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
- bank_statement_completion_rule_1
-
Now I create a statement. I create statment lines separately because I need
to find each one by XML id
-
!record {model: account.move, id: move_test_sale1}:
name: Statement for SO
journal_id: account.bank_journal
company_id: base.main_company
-
I create a move line for a SO
-
!record {model: account.move.line, id: move_line_so}:
name: SO007
account_id: account.a_sale
move_id: move_test_sale1
date_maturity: '2013-12-20'
credit: 0.0
-
and add the correct name
-
!python {model: account.move.line}: |
context['check_move_validity'] = False
model.write(cr, uid, [ref('move_line_so')],
{'credit': 14981.0},
context)
-
I run the auto complete
-
!python {model: account.move}: |
result = self.button_auto_completion(cr, uid, [ref("move_test_sale1")])
-
Now I can check that all is nice and shiny, line 1. I expect the Sale Order
Number to be recognised.
-
!assert {model: account.move.line, id: move_line_so, string: Check completion by SO number}:
- partner_id.name == u'China Export'

View File

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

View File

@ -0,0 +1,70 @@
# Copyright 2011-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo.tests.common import SavepointCase
class TestCompliteSO(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.partner = cls.env.ref('base.res_partner_1')
p = cls.env.ref('product.product_product_6')
cls.order = cls.env['sale.order'].create({
'name': 'Test order',
'partner_id': cls.partner.id,
'order_line': [(0, 0, {'name': 'Test autocomplet',
'product_id': p.id,
'product_uom_qty': 2,
'qty_to_invoice': 2,
'qty_delivered': 2,
'product_uom': p.uom_id.id,
'price_unit': p.list_price})],
})
rule_ids = cls.env.ref('account_move_base_import.'
'bank_statement_completion_rule_5')
rule_ids += cls.env.ref('account_move_base_import.'
'bank_statement_completion_rule_4')
rule_ids += cls.env.ref('account_move_base_import.'
'bank_statement_completion_rule_3')
rule_ids += cls.env.ref('account_move_base_import.'
'bank_statement_completion_rule_2')
rule_ids += cls.env.ref('account_move_so_import.'
'bank_statement_completion_rule_1')
# create journal with profile
cls.journal = cls.env['account.journal'].create({
'name': 'Company Bank journal',
'type': 'bank',
'code': 'BNKFB',
'rule_ids': [
(4, comp_rule.id, False) for comp_rule in rule_ids
],
'used_for_completion': True,
})
cls.move = cls.env['account.move'].create(
{'name': 'Test move', 'journal_id': cls.journal.id}
)
cls.account_payable = cls.env['account.account'].search([
('user_type_id', '=',
cls.env.ref('account.data_account_type_payable').id),
], limit=1)
def test_completion_so(self):
self.order.action_confirm()
aml = self.env['account.move.line'].create(
{
'name': self.order.name,
'account_id': self.account_payable.id,
'move_id': self.move.id,
'credit': 0.0,
}
)
aml.with_context(check_move_validity=False).write({
'credit': 1,
})
self.assertFalse(self.move.partner_id)
self.move.button_auto_completion()
self.assertEqual(self.move.partner_id, self.partner,)