Skip to content

Commit

Permalink
Extract common fields to mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
grindtildeath committed Oct 19, 2018
1 parent af77965 commit a51f200
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import account_asset_method_number_end
from . import account_asset
from . import account_asset_profile
22 changes: 2 additions & 20 deletions account_asset_management_method_number_end/models/account_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@


class AccountAsset(models.Model):
_inherit = 'account.asset'

method_number = fields.Integer(
string='Number',
help="The meaning of this parameter depends on the Time Method.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n"
" * Ending Date: Choose the time between 2 depreciations "
"and the date the depreciations won't go beyond.")

method_time = fields.Selection(
help="Choose the method to use to compute the dates and "
"number of depreciation lines.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n"
" * Ending Date: Choose the time between 2 depreciations "
"and the date the depreciations won't go beyond.")
_name = 'account.asset'
_inherit = ['account.asset', 'account.asset.method.number.end.mixin']
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields


class AccountAssetMethodNumberEnd(models.AbstractModel):

_name = 'account.asset.method.number.end.mixin'

method_number = fields.Integer(
string='Number',
help="The meaning of this parameter depends on the Time Method.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n"
" * Ending Date: Choose the time between 2 depreciations "
"and the date the depreciations won't go beyond.")

method_time = fields.Selection(
selection=lambda self: self.env[
'account.asset.profile']._selection_method_time(),
help="Choose the method to use to compute the dates and "
"number of depreciation lines.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n"
" * Ending Date: Choose the time between 2 depreciations "
"and the date the depreciations won't go beyond.")
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,11 @@


class AccountAssetProfile(models.Model):
_inherit = 'account.asset.profile'

method_number = fields.Integer(
string='Number',
help="The meaning of this parameter depends on the Time Method.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n"
" * Ending Date: Choose the time between 2 depreciations "
"and the date the depreciations won't go beyond.")

method_time = fields.Selection(
help="Choose the method to use to compute the dates and "
"number of depreciation lines.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n"
" * Ending Date: Choose the time between 2 depreciations "
"and the date the depreciations won't go beyond.")
_name = 'account.asset.profile'
_inherit = [
'account.asset.profile', 'account.asset.method.number.end.mixin'
]

@api.model
def _selection_method_time(self):
Expand Down

0 comments on commit a51f200

Please sign in to comment.