2
0

[12.0][FIX] account_asset_management: date_range -> account_fiscal_year, account_analytic_id without domain

This commit is contained in:
Henrik 2019-06-28 22:05:16 +02:00 committed by Rodrigo
parent 8fa0de5226
commit 61d5a0b076
7 changed files with 360 additions and 345 deletions

View File

@ -14,13 +14,13 @@ Assets Management
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/11.0/account_asset_management :target: https://github.com/OCA/account-financial-tools/tree/12.0/account_asset_management
:alt: OCA/account-financial-tools :alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-11-0/account-financial-tools-11-0-account_asset_management :target: https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-0-account_asset_management
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/11.0 :target: https://runbot.odoo-community.org/runbot/92/12.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -55,13 +55,22 @@ Usage
The module in NOT compatible with the standard account_asset module. The module in NOT compatible with the standard account_asset module.
Changelog
=========
12.0.1.0.0 (2019-01-13)
~~~~~~~~~~~~~~~~~~~~~~~
* [BREAKING] account.asset: parent_path has replaced parent_left & parent_right (TODO: migration script)
* [BREAKING] account.asset.recompute.trigger: depends on date_range.py (TODO: re-implement in account_fiscal_year.py)
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_management%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_management%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -83,6 +92,8 @@ Contributors
- Stéphane Bidoul (Acsone) - Stéphane Bidoul (Acsone)
- Adrien Peiffer (Acsone) - Adrien Peiffer (Acsone)
- Akim Juillerat <akim.juillerat@camptocamp.com> - Akim Juillerat <akim.juillerat@camptocamp.com>
- Henrik Norlin (Apps2GROW)
- Maxence Groine <mgroine@fiefmanage.ch>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -97,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/11.0/account_asset_management>`_ project on GitHub. This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/12.0/account_asset_management>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ from . import account_asset
from . import account_asset_profile from . import account_asset_profile
from . import account_asset_line from . import account_asset_line
from . import account_asset_recompute_trigger from . import account_asset_recompute_trigger
from . import account_fiscal_year
from . import account_invoice from . import account_invoice
from . import account_move from . import account_move
#from . import date_range
from . import res_config_settings from . import res_config_settings

View File

@ -193,9 +193,7 @@ class AccountAsset(models.Model):
store=True, readonly=True) store=True, readonly=True)
account_analytic_id = fields.Many2one( account_analytic_id = fields.Many2one(
comodel_name='account.analytic.account', comodel_name='account.analytic.account',
string='Analytic account', string='Analytic account')
domain=[('type', '!=', 'view'),
('state', 'not in', ('close', 'cancelled'))])
@api.model @api.model
def _default_company_id(self): def _default_company_id(self):

View File

@ -0,0 +1,49 @@
# Copyright 2009-2017 Noviat
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo import api, models
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
_logger = logging.getLogger(__name__)
class AccountFiscalYear(models.Model):
_inherit = 'account.fiscal.year'
@api.model
def create(self, vals):
date_from = datetime.strptime(vals.get('date_from'), '%Y-%m-%d')
date_to = datetime.strptime(vals.get('date_to'), '%Y-%m-%d')
if not date_to == date_from + relativedelta(years=1, days=-1):
recompute_vals = {
'reason': 'creation of fiscalyear %s' % vals.get('name'),
'company_id':
vals.get('company_id') or
self.env.user.company_id.id,
'date_trigger': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'state': 'open',
}
self.env['account.asset.recompute.trigger'].sudo().create(
recompute_vals)
return super().create(vals)
@api.multi
def write(self, vals):
if vals.get('date_from') or vals.get('date_to'):
for fy in self:
recompute_vals = {
'reason':
'duration change of fiscalyear %s' % fy.name,
'company_id': fy.company_id.id,
'date_trigger':
time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'state': 'open',
}
self.env['account.asset.recompute.trigger'].sudo().\
create(recompute_vals)
return super().write(vals)

View File

@ -1,50 +0,0 @@
# Copyright 2009-2017 Noviat
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import time
from odoo import api, models
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
class DateRange(models.Model):
_inherit = 'date.range'
@api.model
def create(self, vals):
# TODO:
# change logic to avoid table recompute overhead
# when a regular (duration = 1 year) new FY is created
fy_types = self.env['date.range.type'].search(
[('fiscal_year', '=', True)])
if vals.get('type_id') in fy_types._ids:
recompute_vals = {
'reason': 'creation of fiscalyear %s' % vals.get('code'),
'company_id':
vals.get('company_id') or
self.env.user.company_id.id,
'date_trigger': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'state': 'open',
}
self.env['account.asset.recompute.trigger'].sudo().create(
recompute_vals)
return super().create(vals)
@api.multi
def write(self, vals):
fy_types = self.env['date.range.type'].search(
[('fiscal_year', '=', True)])
if vals.get('type_id') in fy_types.ids:
if vals.get('date_start') or vals.get('date_end'):
for fy in self:
recompute_vals = {
'reason':
'duration change of fiscalyear %s' % fy.name,
'company_id': fy.company_id.id,
'date_trigger':
time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'state': 'open',
}
self.env['account.asset.recompute.trigger'].sudo().\
create(recompute_vals)
return super().write(vals)

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/11.0/account_asset_management"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-11-0/account-financial-tools-11-0-account_asset_management"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/12.0/account_asset_management"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-12-0/account-financial-tools-12-0-account_asset_management"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This Module manages the assets owned by a company. It will keep <p>This Module manages the assets owned by a company. It will keep
track of depreciations occurred on those assets. And it allows to create track of depreciations occurred on those assets. And it allows to create
accounting entries from the depreciation lines.</p> accounting entries from the depreciation lines.</p>
@ -380,44 +380,58 @@ the standard account_asset module from Odoo.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li> <li><a class="reference internal" href="#configuration" id="id2">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li> <li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li> <li><a class="reference internal" href="#changelog" id="id4">Changelog</a><ul>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul> <li><a class="reference internal" href="#id1" id="id5">12.0.1.0.0 (2019-01-13)</a></li>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li> </ul>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li> </li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li> <li><a class="reference internal" href="#bug-tracker" id="id6">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id7">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id8">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id9">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id10">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div> </div>
<div class="section" id="configuration"> <div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1> <h1><a class="toc-backref" href="#id2">Configuration</a></h1>
<p>It is recommended to configure your Purchase Journal with “Group Invoice Lines” to avoid the <p>It is recommended to configure your Purchase Journal with “Group Invoice Lines” to avoid the
creation of separate assets per Supplier Invoice Line.</p> creation of separate assets per Supplier Invoice Line.</p>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h1><a class="toc-backref" href="#id2">Usage</a></h1> <h1><a class="toc-backref" href="#id3">Usage</a></h1>
<p>The module in NOT compatible with the standard account_asset module.</p> <p>The module in NOT compatible with the standard account_asset module.</p>
</div> </div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#id4">Changelog</a></h1>
<div class="section" id="id1">
<h2><a class="toc-backref" href="#id5">12.0.1.0.0 (2019-01-13)</a></h2>
<ul class="simple">
<li>[BREAKING] account.asset: parent_path has replaced parent_left &amp; parent_right (TODO: migration script)</li>
<li>[BREAKING] account.asset.recompute.trigger: depends on date_range.py (TODO: re-implement in account_fiscal_year.py)</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#id6">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_management%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_management%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1> <h1><a class="toc-backref" href="#id7">Credits</a></h1>
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2> <h2><a class="toc-backref" href="#id8">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Noviat</li> <li>Noviat</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2> <h2><a class="toc-backref" href="#id9">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>OpenERP SA</li> <li>OpenERP SA</li>
<li>Luc De Meyer (Noviat)</li> <li>Luc De Meyer (Noviat)</li>
@ -426,16 +440,18 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Stéphane Bidoul (Acsone)</li> <li>Stéphane Bidoul (Acsone)</li>
<li>Adrien Peiffer (Acsone)</li> <li>Adrien Peiffer (Acsone)</li>
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li> <li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li>Henrik Norlin (Apps2GROW)</li>
<li>Maxence Groine &lt;<a class="reference external" href="mailto:mgroine&#64;fiefmanage.ch">mgroine&#64;fiefmanage.ch</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2> <h2><a class="toc-backref" href="#id10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/11.0/account_asset_management">OCA/account-financial-tools</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/12.0/account_asset_management">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>