Commit 6f33a2a9 authored by Mathias Behrle's avatar Mathias Behrle

Merging upstream version 5.0.0.

parent 3e612255
......@@ -25,12 +25,6 @@ services:
matrix:
include:
- IMAGE: python:2.7
TOXENV: py27
DATABASE: sqlite
- IMAGE: python:2.7
TOXENV: py27
DATABASE: postgresql
- IMAGE: python:3.4
TOXENV: py34
DATABASE: sqlite
......@@ -49,3 +43,9 @@ matrix:
- IMAGE: python:3.6
TOXENV: py36
DATABASE: postgresql
- IMAGE: python:3.7
TOXENV: py37
DATABASE: sqlite
- IMAGE: python:3.7
TOXENV: py37
DATABASE: postgresql
Version 5.0.0 - 2018-10-01
* Bug fixes (see mercurial logs for details)
* Allow to set when the depreciation move should be created
* Remove support for Python 2.7
Version 4.8.0 - 2018-04-23
* Bug fixes (see mercurial logs for details)
* Don't allow to close a period with asset moves not posted
Version 4.6.0 - 2017-10-30
* Bug fixes (see mercurial logs for details)
......
Copyright (C) 2012-2017 Nicolas Évrard.
Copyright (C) 2012-2017 Cédric Krier.
Copyright (C) 2012-2018 Cédric Krier.
Copyright (C) 2012-2013 Bertrand Chenal.
Copyright (C) 2012-2017 B2CK SPRL.
Copyright (C) 2012-2018 B2CK SPRL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
......@@ -4,7 +4,7 @@ Installing trytond_account_asset
Prerequisites
-------------
* Python 2.7 or later (http://www.python.org/)
* Python 3.4 or later (http://www.python.org/)
* python-dateutil (http://labix.org/python-dateutil)
* cached-property (https://github.com/pydanny/cached-property)
* trytond (http://www.tryton.org/)
......
Metadata-Version: 1.1
Metadata-Version: 1.2
Name: trytond_account_asset
Version: 4.6.0
Version: 5.0.0
Summary: Tryton module for assets management
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker@tryton.org
License: GPL-3
Download-URL: http://downloads.tryton.org/4.6/
Download-URL: http://downloads.tryton.org/5.0/
Description-Content-Type: UNKNOWN
Description: trytond_account_asset
=====================
......@@ -62,17 +63,19 @@ Classifier: Natural Language :: French
Classifier: Natural Language :: German
Classifier: Natural Language :: Hungarian
Classifier: Natural Language :: Italian
Classifier: Natural Language :: Persian
Classifier: Natural Language :: Polish
Classifier: Natural Language :: Portuguese (Brazilian)
Classifier: Natural Language :: Russian
Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Office/Business
Classifier: Topic :: Office/Business :: Financial :: Accounting
Requires-Python: >=3.4
# This file is part of Tryton. The COPYRIGHT file at the top level of this
# repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .asset import *
from .product import *
from .invoice import *
from .account import *
from .purchase import *
from . import asset
from . import product
from . import invoice
from . import account
from . import purchase
def register():
Pool.register(
Asset,
AssetLine,
AssetUpdateMove,
CreateMovesStart,
UpdateAssetStart,
UpdateAssetShowDepreciation,
PrintDepreciationTableStart,
Category,
CategoryAccount,
Template,
TemplateAccount,
Product,
InvoiceLine,
Configuration,
ConfigurationAssetSequence,
Move,
PurchaseLine,
asset.Asset,
asset.AssetLine,
asset.AssetUpdateMove,
asset.CreateMovesStart,
asset.UpdateAssetStart,
asset.UpdateAssetShowDepreciation,
asset.PrintDepreciationTableStart,
product.Category,
product.CategoryAccount,
product.Template,
product.Product,
invoice.InvoiceLine,
account.Configuration,
account.ConfigurationAssetSequence,
account.ConfigurationAssetDate,
account.Move,
account.Period,
account.Journal,
module='account_asset', type_='model')
Pool.register(
CreateMoves,
UpdateAsset,
PrintDepreciationTable,
purchase.PurchaseLine,
module='account_asset', type_='model', depends=['purchase'])
Pool.register(
asset.CreateMoves,
asset.UpdateAsset,
asset.PrintDepreciationTable,
module='account_asset', type_='wizard')
Pool.register(
AssetDepreciationTable,
asset.AssetDepreciationTable,
module='account_asset', type_='report')
......@@ -7,11 +7,32 @@ from trytond.pool import PoolMeta, Pool
from trytond.tools.multivalue import migrate_property
from trytond.modules.company.model import CompanyValueMixin
__all__ = ['Configuration', 'ConfigurationAssetSequence', 'Move']
__all__ = ['Configuration', 'ConfigurationAssetSequence',
'ConfigurationAssetDate', 'Move', 'Period', 'Journal']
asset_bymonthday = fields.Selection([
('1', "First"),
('-1', "Last"),
], "Day of the Month",
help="The day of the month to create the depreciation moves.")
asset_bymonth = fields.Selection([
('1', "January"),
('2', "February"),
('3', "March"),
('4', "April"),
('5', "May"),
('6', "June"),
('7', "July"),
('8', "August"),
('9', "September"),
('10', "October"),
('11', "November"),
('12', "December"),
], "Month", sort=False,
help="The month to create the depreciation moves.")
class Configuration:
__metaclass__ = PoolMeta
class Configuration(metaclass=PoolMeta):
__name__ = 'account.configuration'
asset_sequence = fields.MultiValue(fields.Many2One(
'ir.sequence', "Asset Reference Sequence", required=True,
......@@ -20,11 +41,29 @@ class Configuration:
Eval('context', {}).get('company', -1), None]),
('code', '=', 'account.asset'),
]))
asset_bymonthday = fields.MultiValue(asset_bymonthday)
asset_bymonth = fields.MultiValue(asset_bymonth)
@classmethod
def multivalue_model(cls, field):
pool = Pool()
if field in {'asset_bymonthday', 'asset_bymonth'}:
return pool.get('account.configuration.asset_date')
return super(Configuration, cls).multivalue_model(field)
@classmethod
def default_asset_sequence(cls, **pattern):
return cls.multivalue_model('asset_sequence').default_asset_sequence()
@classmethod
def default_asset_bymonthday(cls, **pattern):
return cls.multivalue_model(
'asset_bymonthday').default_asset_bymonthday()
@classmethod
def default_asset_bymonth(cls, **pattern):
return cls.multivalue_model('asset_bymonth').default_asset_bymonth()
class ConfigurationAssetSequence(ModelSQL, CompanyValueMixin):
"Account Configuration Asset Sequence"
......@@ -66,8 +105,22 @@ class ConfigurationAssetSequence(ModelSQL, CompanyValueMixin):
return None
class Move:
__metaclass__ = PoolMeta
class ConfigurationAssetDate(ModelSQL, CompanyValueMixin):
"Account Configuration Asset Date"
__name__ = 'account.configuration.asset_date'
asset_bymonthday = asset_bymonthday
asset_bymonth = asset_bymonth
@classmethod
def default_asset_bymonthday(cls):
return "-1"
@classmethod
def default_asset_bymonth(cls):
return "12"
class Move(metaclass=PoolMeta):
__name__ = 'account.move'
@classmethod
......@@ -76,3 +129,54 @@ class Move:
origins.append('account.asset')
origins.append('account.asset.line')
return origins
class Period(metaclass=PoolMeta):
__name__ = 'account.period'
@classmethod
def __setup__(cls):
super(Period, cls).__setup__()
cls._error_messages.update({
'running_assets_close': ('Some asset lines "%(names)s" are still '
'running for this period "%(period)s".'),
})
def check_asset_line_running(self):
"""
Check if it exist some asset lines without account move for the curent
period.
"""
pool = Pool()
Asset = pool.get('account.asset')
assets = Asset.search([
('state', '=', 'running'),
('lines', 'where', [
('date', '>=', self.start_date),
('date', '<=', self.end_date),
('move', '=', None),
]),
], limit=6)
if assets:
names = ', '.join(a.rec_name for a in assets[:5])
if len(assets) > 5:
names += '...'
self.raise_user_error('running_assets_close', {
'period': self.rec_name,
'names': names,
})
@classmethod
def close(cls, periods):
for period in periods:
period.check_asset_line_running()
super(Period, cls).close(periods)
class Journal(metaclass=PoolMeta):
__name__ = 'account.journal'
@classmethod
def __setup__(cls):
super(Journal, cls).__setup__()
cls.type.selection.append(('asset', "Asset"))
This diff is collapsed.
......@@ -7,11 +7,6 @@
<menuitem name="Assets" parent="account.menu_account"
id="menu_asset" sequence="48"/>
<record model="account.journal.type" id="journal_type_asset">
<field name="name">Asset</field>
<field name="code">asset</field>
</record>
<record model="ir.action.wizard" id="wizard_update">
<field name="name">Update Asset</field>
<field name="wiz_name">account.asset.update</field>
......@@ -130,6 +125,37 @@
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.model.button" id="asset_close_button">
<field name="name">close</field>
<field name="string">Close</field>
<field name="confirm">Are you sure to close the asset?</field>
<field name="model" search="[('model', '=', 'account.asset')]"/>
</record>
<record model="ir.model.button" id="asset_run_button">
<field name="name">run</field>
<field name="string">Run</field>
<field name="model" search="[('model', '=', 'account.asset')]"/>
</record>
<record model="ir.model.button" id="asset_create_lines_button">
<field name="name">create_lines</field>
<field name="string">Create Lines</field>
<field name="model" search="[('model', '=', 'account.asset')]"/>
</record>
<record model="ir.model.button" id="asset_clear_lines_button">
<field name="name">clear_lines</field>
<field name="string">Clear Lines</field>
<field name="model" search="[('model', '=', 'account.asset')]"/>
</record>
<record model="ir.model.button" id="asset_update_button">
<field name="name">update</field>
<field name="string">Update Asset</field>
<field name="model" search="[('model', '=', 'account.asset')]"/>
</record>
<record model="ir.ui.view" id="asset_line_view_form">
<field name="model">account.asset.line</field>
<field name="type">form</field>
......
......@@ -35,6 +35,9 @@ The asset can be in one of this states:
A wizard "Create Assets Moves" allows to post all accounting move up to a date.
The day and the month when the move will posted are defined on the accounting
configuration.
Asset Line
**********
......
......@@ -3,12 +3,12 @@
from trytond.model import fields, Unique
from trytond.pyson import Eval
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
__all__ = ['InvoiceLine']
class InvoiceLine:
__metaclass__ = PoolMeta
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
asset = fields.Many2One('account.asset', 'Asset', domain=[
('state', '=', 'running'),
......@@ -33,7 +33,8 @@ class InvoiceLine:
'Asset can be used only once on invoice line!'),
]
@fields.depends('product', 'invoice', 'invoice_type')
@fields.depends('product', 'invoice', 'invoice_type',
'_parent_invoice.invoice_date', '_parent_invoice.accounting_date')
def on_change_product(self):
super(InvoiceLine, self).on_change_product()
if self.invoice and self.invoice.type:
......@@ -44,7 +45,10 @@ class InvoiceLine:
if (self.product and type_ == 'in'
and self.product.type == 'assets'
and self.product.depreciable):
self.account = self.product.account_asset_used
date = (self.invoice.accounting_date or self.invoice.invoice_date
if self.invoice else None)
with Transaction().set_context(date=date):
self.account = self.product.account_asset_used
@fields.depends('asset', 'unit')
def on_change_asset(self):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,8 +5,7 @@ from trytond.pool import PoolMeta
__all__ = ['PurchaseLine']
class PurchaseLine:
__metaclass__ = PoolMeta
class PurchaseLine(metaclass=PoolMeta):
__name__ = 'purchase.line'
@classmethod
......
This diff is collapsed.
This diff is collapsed.
......@@ -43,6 +43,17 @@ Create chart of accounts::
>>> expense = accounts['expense']
>>> depreciation_account = accounts['depreciation']
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_expense = expense
>>> account_category.account_revenue = revenue
>>> account_category.account_asset = asset_account
>>> account_category.account_depreciation = depreciation_account
>>> account_category.save()
Create products::
>>> ProductUom = Model.get('product.uom')
......@@ -55,10 +66,7 @@ Create products::
>>> asset_template.list_price = Decimal('1000')
>>> asset_template.depreciable = True
>>> asset_template.purchasable = True
>>> asset_template.account_expense = expense
>>> asset_template.account_revenue = revenue
>>> asset_template.account_asset = asset_account
>>> asset_template.account_depreciation = depreciation_account
>>> asset_template.account_category = account_category
>>> asset_template.depreciation_duration = 24
>>> asset_template.save()
>>> service_product, = asset_template.products
......@@ -69,8 +77,7 @@ Create products::
>>> service_template.default_uom = unit
>>> service_template.list_price = Decimal('10')
>>> service_template.purchasable = True
>>> service_template.account_expense = expense
>>> service_template.account_revenue = revenue
>>> service_template.account_category = account_category
>>> service_template.save()
>>> service_product, = service_template.products
......
This diff is collapsed.
[tryton]
version=4.6.0
version=5.0.0
depends:
ir
res
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment