2016-08-25 15:26:49 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-03-23 07:52:07 +01:00
|
|
|
# Copyright 2016-2017 ACSONE SA/NV
|
2016-08-25 15:26:49 +02:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
|
|
|
|
from openerp import api, fields, models, _
|
|
|
|
|
|
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
try:
|
2017-03-23 07:52:07 +01:00
|
|
|
from odoo.addons.queue_job.job import job
|
2016-08-25 15:26:49 +02:00
|
|
|
except ImportError:
|
2017-03-23 07:52:07 +01:00
|
|
|
_logger.debug('Can not `import queue_job`.')
|
2016-08-25 15:26:49 +02:00
|
|
|
|
|
|
|
def empty_decorator(func):
|
|
|
|
return func
|
|
|
|
job = empty_decorator
|
|
|
|
|
|
|
|
|
|
|
|
class AssetDepreciationConfirmationWizard(models.TransientModel):
|
|
|
|
|
|
|
|
_inherit = 'asset.depreciation.confirmation.wizard'
|
|
|
|
|
|
|
|
batch_processing = fields.Boolean()
|
|
|
|
|
|
|
|
@api.multi
|
2017-03-23 07:52:07 +01:00
|
|
|
@job(default_channel='root.account_asset_batch_compute')
|
2016-08-25 15:26:49 +02:00
|
|
|
def asset_compute(self):
|
|
|
|
self.ensure_one()
|
|
|
|
if not self.batch_processing:
|
|
|
|
return super(AssetDepreciationConfirmationWizard, self)\
|
|
|
|
.asset_compute()
|
2017-03-23 07:52:07 +01:00
|
|
|
if not self.env.context.get('job_uuid'):
|
|
|
|
description = \
|
|
|
|
_("Creating jobs to create moves for assets to %s") % (
|
|
|
|
self.date_end,)
|
|
|
|
job = self.with_delay(description=description).asset_compute()
|
|
|
|
return u'Job created with uuid %s' % (job.uuid,)
|
2016-08-25 15:26:49 +02:00
|
|
|
else:
|
2017-03-23 07:52:07 +01:00
|
|
|
self = self.with_context(asset_batch_processing=True)
|
|
|
|
return super(AssetDepreciationConfirmationWizard, self)\
|
|
|
|
.asset_compute()
|