[MIG] account_move_batch_validate: Migration to 11.0

This commit is contained in:
oleksandrpaziuk
2018-01-09 20:09:13 +02:00
committed by Iryna Vushnevska
parent 16f6d8b37e
commit 4f837b2a36
12 changed files with 47 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp SA, 2017 ACSONE
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp SA, 2017 ACSONE
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Account Move Batch Validate",
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'author': "Camptocamp, Odoo Community Association (OCA)",
'website': 'http://www.camptocamp.com',
'website': 'https://github.com/OCA/account-financial-tools',
'category': 'Finance',
'complexity': 'normal',
'depends': [
@@ -16,6 +16,5 @@
'views/account_move.xml',
'wizard/account_move_validate.xml',
],
'installable': True,
'license': 'AGPL-3',
}

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp SA, 2017 ACSONE
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_move

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp SA, 2017 ACSONE
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
@@ -28,7 +28,7 @@ class AccountMove(models.Model):
if move.exists():
move.post()
else:
return _(u"Nothing to do because the record has been deleted")
return _("Nothing to do because the record has been deleted")
@api.model
def _delay_post_marked(self, eta=None):
@@ -88,7 +88,7 @@ class AccountMove(models.Model):
values = {'to_post': True}
for index in xrange(0, moves_count, BLOCK_SIZE):
for index in range(0, moves_count, BLOCK_SIZE):
moves = self[index:index + BLOCK_SIZE]
moves.write(values)
# users like to see the flag sooner rather than later

View File

@@ -0,0 +1,24 @@
This module provides a wizard to post many Journal Entries in batch. it
uses the queue system introduced by the Odoo Queue job module to handle a
big quantity of moves in batch.
The posting of a move takes some time, and doing that synchronously,
in one transaction is problematic.
In this module, we leverage the power of the queue system of the
Odoo queue job module, that can be very well used without other concepts
like Backends and Bindings.
This approach provides many advantages, similar to the ones we get
using that connector for e-commerce:
- Asynchronous: the operation is done in background, and users can
continue to work.
- Dedicated workers: the queued jobs are performed by specific workers
(processes). This is good for a long task, since the main workers are
busy handling HTTP requests and can be killed if operations take
too long, for example.
- Multiple transactions: this is an operation that doesn't need to be
atomic, and if a line out of 100,000 fails, it is possible to catch
it, see the error message, and fix the situation. Meanwhile, all
other jobs can proceed.

View File

@@ -1 +1,3 @@
# Copyright 2018 Camptocamp SA
from . import test_account_move_batch_validate

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import SingleTransactionCase
@@ -74,7 +74,7 @@ class TestAccountMoveBatchValidate(SingleTransactionCase):
"""
move = self.create_account_move(1000)
self.assertEquals(move.state, 'draft')
self.assertEqual(move.state, 'draft')
wizard = self.create_move_validate_wizard('mark')
wizard.with_context({
@@ -93,7 +93,7 @@ class TestAccountMoveBatchValidate(SingleTransactionCase):
post_job = Job.load(self.env, job_uuid)
post_job.perform()
self.assertEquals(
self.assertEqual(
move.state, 'posted', msg="Move should be posted.")
def test_02_delete_move_before_job_run(self):
@@ -119,9 +119,9 @@ class TestAccountMoveBatchValidate(SingleTransactionCase):
post_job = Job.load(self.env, job_uuid)
post_job.perform()
self.assertEquals(
self.assertEqual(
post_job.result,
u'Nothing to do because the record has been deleted')
'Nothing to do because the record has been deleted')
def test_03_mark_and_unmark(self):
"""
@@ -150,14 +150,14 @@ class TestAccountMoveBatchValidate(SingleTransactionCase):
job_uuid = move.post_job_uuid
self.assertEquals(mark_job_uuid, job_uuid)
self.assertEqual(mark_job_uuid, job_uuid)
post_job = Job.load(self.env, job_uuid)
self.assertEquals(post_job.state, 'done', msg="Job should be done")
self.assertEquals(
self.assertEqual(post_job.state, 'done', msg="Job should be done")
self.assertEqual(
post_job.result,
"Task set to Done because the user unmarked the move.")
self.assertEquals(
self.assertEqual(
move.state, 'draft', msg="Move should be in 'draft' state")

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 Camptocamp SA, 2017 ACSONE SA/NV
Copyright 2018 Camptocamp SA
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp SA, 2017 ACSONE
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_move_validate

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp SA, 2017 ACSONE
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2014 Camptocamp SA, 2017 ACSONE SA/NV
Copyright 2018 Camptocamp SA
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="validate_account_move_form">
<field name="name">validate.account.move.form (in account_move_batch_validate)</field>
<field name="model">validate.account.move</field>