[MIG] account_asset_management: Migration to 16.0
This commit is contained in:
parent
3c5d26b456
commit
f1371e5b33
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "Assets Management",
|
"name": "Assets Management",
|
||||||
"version": "15.0.1.0.1",
|
"version": "16.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"depends": ["account", "report_xlsx_helper"],
|
"depends": ["account", "report_xlsx_helper"],
|
||||||
"excludes": ["account_asset"],
|
"excludes": ["account_asset"],
|
||||||
|
@ -32,7 +32,7 @@ class DummyFy(object):
|
|||||||
|
|
||||||
class AccountAsset(models.Model):
|
class AccountAsset(models.Model):
|
||||||
_name = "account.asset"
|
_name = "account.asset"
|
||||||
_inherit = ["mail.thread", "mail.activity.mixin"]
|
_inherit = ["mail.thread", "mail.activity.mixin", "analytic.mixin"]
|
||||||
_description = "Asset"
|
_description = "Asset"
|
||||||
_order = "date_start desc, code, name"
|
_order = "date_start desc, code, name"
|
||||||
_check_company_auto = True
|
_check_company_auto = True
|
||||||
@ -59,7 +59,6 @@ class AccountAsset(models.Model):
|
|||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
)
|
)
|
||||||
purchase_value = fields.Monetary(
|
purchase_value = fields.Monetary(
|
||||||
string="Purchase Value",
|
|
||||||
required=True,
|
required=True,
|
||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
currency_field="company_currency_id",
|
currency_field="company_currency_id",
|
||||||
@ -68,7 +67,6 @@ class AccountAsset(models.Model):
|
|||||||
"\nPurchase Value - Salvage Value.",
|
"\nPurchase Value - Salvage Value.",
|
||||||
)
|
)
|
||||||
salvage_value = fields.Monetary(
|
salvage_value = fields.Monetary(
|
||||||
string="Salvage Value",
|
|
||||||
states=READONLY_STATES,
|
states=READONLY_STATES,
|
||||||
currency_field="company_currency_id",
|
currency_field="company_currency_id",
|
||||||
help="The estimated value that an asset will realize upon "
|
help="The estimated value that an asset will realize upon "
|
||||||
@ -77,7 +75,6 @@ class AccountAsset(models.Model):
|
|||||||
)
|
)
|
||||||
depreciation_base = fields.Monetary(
|
depreciation_base = fields.Monetary(
|
||||||
compute="_compute_depreciation_base",
|
compute="_compute_depreciation_base",
|
||||||
string="Depreciation Base",
|
|
||||||
store=True,
|
store=True,
|
||||||
currency_field="company_currency_id",
|
currency_field="company_currency_id",
|
||||||
help="This amount represent the depreciation base "
|
help="This amount represent the depreciation base "
|
||||||
@ -271,20 +268,6 @@ class AccountAsset(models.Model):
|
|||||||
string="Company Currency",
|
string="Company Currency",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
account_analytic_id = fields.Many2one(
|
|
||||||
comodel_name="account.analytic.account",
|
|
||||||
string="Analytic account",
|
|
||||||
compute="_compute_account_analytic_id",
|
|
||||||
readonly=False,
|
|
||||||
store=True,
|
|
||||||
)
|
|
||||||
analytic_tag_ids = fields.Many2many(
|
|
||||||
comodel_name="account.analytic.tag",
|
|
||||||
string="Analytic tags",
|
|
||||||
compute="_compute_analytic_tag_ids",
|
|
||||||
readonly=False,
|
|
||||||
store=True,
|
|
||||||
)
|
|
||||||
carry_forward_missed_depreciations = fields.Boolean(
|
carry_forward_missed_depreciations = fields.Boolean(
|
||||||
string="Accumulate missed depreciations",
|
string="Accumulate missed depreciations",
|
||||||
help="""If create an asset in a fiscal period that is now closed
|
help="""If create an asset in a fiscal period that is now closed
|
||||||
@ -395,9 +378,9 @@ class AccountAsset(models.Model):
|
|||||||
asset.account_analytic_id = asset.profile_id.account_analytic_id
|
asset.account_analytic_id = asset.profile_id.account_analytic_id
|
||||||
|
|
||||||
@api.depends("profile_id")
|
@api.depends("profile_id")
|
||||||
def _compute_analytic_tag_ids(self):
|
def _compute_analytic_distribution(self):
|
||||||
for asset in self:
|
for asset in self:
|
||||||
asset.analytic_tag_ids = asset.profile_id.analytic_tag_ids
|
asset.analytic_distribution = asset.profile_id.analytic_distribution
|
||||||
|
|
||||||
@api.constrains("method", "method_time")
|
@api.constrains("method", "method_time")
|
||||||
def _check_method(self):
|
def _check_method(self):
|
||||||
@ -444,14 +427,18 @@ class AccountAsset(models.Model):
|
|||||||
{"amount": self.depreciation_base, "line_date": self.date_start}
|
{"amount": self.depreciation_base, "line_date": self.date_start}
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
asset = super().create(vals)
|
asset_ids = super().create(vals_list)
|
||||||
if self.env.context.get("create_asset_from_move_line"):
|
create_asset_from_move_line = self.env.context.get(
|
||||||
|
"create_asset_from_move_line"
|
||||||
|
)
|
||||||
|
for asset_id in asset_ids:
|
||||||
|
if create_asset_from_move_line:
|
||||||
# Trigger compute of depreciation_base
|
# Trigger compute of depreciation_base
|
||||||
asset.salvage_value = 0.0
|
asset_id.salvage_value = 0.0
|
||||||
asset._create_first_asset_line()
|
asset_id._create_first_asset_line()
|
||||||
return asset
|
return asset_ids
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
res = super().write(vals)
|
res = super().write(vals)
|
||||||
|
@ -16,7 +16,7 @@ class AccountAssetGroup(models.Model):
|
|||||||
|
|
||||||
name = fields.Char(size=64, required=True, index=True)
|
name = fields.Char(size=64, required=True, index=True)
|
||||||
code = fields.Char(index=True)
|
code = fields.Char(index=True)
|
||||||
parent_path = fields.Char(index=True)
|
parent_path = fields.Char(index=True, unaccent=False)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name="res.company",
|
comodel_name="res.company",
|
||||||
string="Company",
|
string="Company",
|
||||||
|
@ -35,9 +35,7 @@ class AccountAssetLine(models.Model):
|
|||||||
string="Depreciation Base",
|
string="Depreciation Base",
|
||||||
currency_field="company_currency_id",
|
currency_field="company_currency_id",
|
||||||
)
|
)
|
||||||
amount = fields.Monetary(
|
amount = fields.Monetary(required=True, currency_field="company_currency_id")
|
||||||
string="Amount", required=True, currency_field="company_currency_id"
|
|
||||||
)
|
|
||||||
remaining_value = fields.Monetary(
|
remaining_value = fields.Monetary(
|
||||||
compute="_compute_values",
|
compute="_compute_values",
|
||||||
string="Next Period Depreciation",
|
string="Next Period Depreciation",
|
||||||
@ -235,16 +233,14 @@ class AccountAssetLine(models.Model):
|
|||||||
currency = asset.company_id.currency_id
|
currency = asset.company_id.currency_id
|
||||||
amount = self.amount
|
amount = self.amount
|
||||||
amount_comp = currency.compare_amounts(amount, 0)
|
amount_comp = currency.compare_amounts(amount, 0)
|
||||||
analytic_id = False
|
analytic_distribution = False
|
||||||
analytic_tags = self.env["account.analytic.tag"]
|
|
||||||
if ml_type == "depreciation":
|
if ml_type == "depreciation":
|
||||||
debit = amount_comp < 0 and -amount or 0.0
|
debit = amount_comp < 0 and -amount or 0.0
|
||||||
credit = amount_comp > 0 and amount or 0.0
|
credit = amount_comp > 0 and amount or 0.0
|
||||||
elif ml_type == "expense":
|
elif ml_type == "expense":
|
||||||
debit = amount_comp > 0 and amount or 0.0
|
debit = amount_comp > 0 and amount or 0.0
|
||||||
credit = amount_comp < 0 and -amount or 0.0
|
credit = amount_comp < 0 and -amount or 0.0
|
||||||
analytic_id = asset.account_analytic_id.id
|
analytic_distribution = asset.analytic_distribution
|
||||||
analytic_tags = asset.analytic_tag_ids
|
|
||||||
move_line_data = {
|
move_line_data = {
|
||||||
"name": asset.name,
|
"name": asset.name,
|
||||||
"ref": self.name,
|
"ref": self.name,
|
||||||
@ -254,8 +250,7 @@ class AccountAssetLine(models.Model):
|
|||||||
"debit": debit,
|
"debit": debit,
|
||||||
"journal_id": asset.profile_id.journal_id.id,
|
"journal_id": asset.profile_id.journal_id.id,
|
||||||
"partner_id": asset.partner_id.id,
|
"partner_id": asset.partner_id.id,
|
||||||
"analytic_account_id": analytic_id,
|
"analytic_distribution": analytic_distribution,
|
||||||
"analytic_tag_ids": [(4, tag.id) for tag in analytic_tags],
|
|
||||||
"date": depreciation_date,
|
"date": depreciation_date,
|
||||||
"asset_id": asset.id,
|
"asset_id": asset.id,
|
||||||
}
|
}
|
||||||
|
@ -7,18 +7,13 @@ from odoo.exceptions import UserError
|
|||||||
|
|
||||||
class AccountAssetProfile(models.Model):
|
class AccountAssetProfile(models.Model):
|
||||||
_name = "account.asset.profile"
|
_name = "account.asset.profile"
|
||||||
|
_inherit = "analytic.mixin"
|
||||||
_check_company_auto = True
|
_check_company_auto = True
|
||||||
_description = "Asset profile"
|
_description = "Asset profile"
|
||||||
_order = "name"
|
_order = "name"
|
||||||
|
|
||||||
name = fields.Char(size=64, required=True, index=True)
|
name = fields.Char(size=64, required=True, index=True)
|
||||||
note = fields.Text()
|
note = fields.Text()
|
||||||
account_analytic_id = fields.Many2one(
|
|
||||||
comodel_name="account.analytic.account", string="Analytic account"
|
|
||||||
)
|
|
||||||
analytic_tag_ids = fields.Many2many(
|
|
||||||
comodel_name="account.analytic.tag", string="Analytic tags"
|
|
||||||
)
|
|
||||||
account_asset_id = fields.Many2one(
|
account_asset_id = fields.Many2one(
|
||||||
comodel_name="account.account",
|
comodel_name="account.account",
|
||||||
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
|
||||||
@ -207,17 +202,22 @@ class AccountAssetProfile(models.Model):
|
|||||||
if profile.method_time != "year":
|
if profile.method_time != "year":
|
||||||
profile.prorata = True
|
profile.prorata = True
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
|
for vals in vals_list:
|
||||||
if vals.get("method_time") != "year" and not vals.get("prorata"):
|
if vals.get("method_time") != "year" and not vals.get("prorata"):
|
||||||
vals["prorata"] = True
|
vals["prorata"] = True
|
||||||
profile = super().create(vals)
|
profile_ids = super().create(vals_list)
|
||||||
acc_id = vals.get("account_asset_id")
|
account_dict = {}
|
||||||
if acc_id:
|
for profile_id in profile_ids.filtered(
|
||||||
account = self.env["account.account"].browse(acc_id)
|
lambda x: not x.account_asset_id.asset_profile_id
|
||||||
if not account.asset_profile_id:
|
):
|
||||||
account.write({"asset_profile_id": profile.id})
|
account_dict.setdefault(profile_id.account_asset_id, []).append(
|
||||||
return profile
|
profile_id.id
|
||||||
|
)
|
||||||
|
for account, profile_list in account_dict.items():
|
||||||
|
account.write({"asset_profile_id": profile_list[-1]})
|
||||||
|
return profile_ids
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if vals.get("method_time"):
|
if vals.get("method_time"):
|
||||||
|
@ -80,7 +80,6 @@ class AccountMove(models.Model):
|
|||||||
"purchase_value": depreciation_base,
|
"purchase_value": depreciation_base,
|
||||||
"partner_id": aml.partner_id,
|
"partner_id": aml.partner_id,
|
||||||
"date_start": self.date,
|
"date_start": self.date,
|
||||||
"account_analytic_id": aml.analytic_account_id,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def action_post(self):
|
def action_post(self):
|
||||||
@ -104,7 +103,7 @@ class AccountMove(models.Model):
|
|||||||
for key, val in vals.items():
|
for key, val in vals.items():
|
||||||
setattr(asset_form, key, val)
|
setattr(asset_form, key, val)
|
||||||
asset = asset_form.save()
|
asset = asset_form.save()
|
||||||
asset.analytic_tag_ids = aml.analytic_tag_ids
|
asset.analytic_distribution = aml.analytic_distribution
|
||||||
aml.with_context(
|
aml.with_context(
|
||||||
allow_asset=True, allow_asset_removal=True
|
allow_asset=True, allow_asset_removal=True
|
||||||
).asset_id = asset.id
|
).asset_id = asset.id
|
||||||
@ -256,7 +255,5 @@ class AccountMoveLine(models.Model):
|
|||||||
qty = self.quantity
|
qty = self.quantity
|
||||||
name = self.name
|
name = self.name
|
||||||
aml.write({"quantity": 1, "name": "{} {}".format(name, 1)})
|
aml.write({"quantity": 1, "name": "{} {}".format(name, 1)})
|
||||||
aml._onchange_price_subtotal()
|
|
||||||
for i in range(1, int(qty)):
|
for i in range(1, int(qty)):
|
||||||
aml.copy({"name": "{} {}".format(name, i + 1)})
|
aml.copy({"name": "{} {}".format(name, i + 1)})
|
||||||
aml.move_id._onchange_invoice_line_ids()
|
|
||||||
|
@ -5,7 +5,6 @@ import logging
|
|||||||
|
|
||||||
from odoo import _, models
|
from odoo import _, models
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
from odoo.tools.translate import translate
|
|
||||||
|
|
||||||
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
|
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
|
||||||
FORMATS,
|
FORMATS,
|
||||||
@ -23,11 +22,6 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
_description = "Dynamic XLS asset report generator"
|
_description = "Dynamic XLS asset report generator"
|
||||||
_inherit = "report.report_xlsx.abstract"
|
_inherit = "report.report_xlsx.abstract"
|
||||||
|
|
||||||
def _(self, src):
|
|
||||||
lang = self.env.context.get("lang", "en_US")
|
|
||||||
val = translate(self.env.cr, IR_TRANSLATION_NAME, "report", lang, src) or src
|
|
||||||
return val
|
|
||||||
|
|
||||||
def _get_ws_params(self, wb, data, wiz):
|
def _get_ws_params(self, wb, data, wiz):
|
||||||
self._get_assets(wiz, data)
|
self._get_assets(wiz, data)
|
||||||
s1 = self._get_acquisition_ws_params(wb, data, wiz)
|
s1 = self._get_acquisition_ws_params(wb, data, wiz)
|
||||||
@ -39,18 +33,18 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
|
|
||||||
asset_template = {
|
asset_template = {
|
||||||
"account": {
|
"account": {
|
||||||
"header": {"type": "string", "value": self._("Account")},
|
"header": {"type": "string", "value": _("Account")},
|
||||||
"asset": {
|
"asset": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._render(
|
"value": self._render(
|
||||||
"asset.profile_id.account_asset_id.code or ''"
|
"asset.profile_id.account_asset_id.code or ''"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"totals": {"type": "string", "value": self._("Totals")},
|
"totals": {"type": "string", "value": _("Totals")},
|
||||||
"width": 20,
|
"width": 20,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"header": {"type": "string", "value": self._("Name")},
|
"header": {"type": "string", "value": _("Name")},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._render("group.name or ''"),
|
"value": self._render("group.name or ''"),
|
||||||
@ -59,7 +53,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"width": 40,
|
"width": 40,
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"header": {"type": "string", "value": self._("Reference")},
|
"header": {"type": "string", "value": _("Reference")},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._render("group.code or ''"),
|
"value": self._render("group.code or ''"),
|
||||||
@ -68,7 +62,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"width": 20,
|
"width": 20,
|
||||||
},
|
},
|
||||||
"date_start": {
|
"date_start": {
|
||||||
"header": {"type": "string", "value": self._("Asset Start Date")},
|
"header": {"type": "string", "value": _("Asset Start Date")},
|
||||||
"asset": {
|
"asset": {
|
||||||
"value": self._render("asset.date_start or ''"),
|
"value": self._render("asset.date_start or ''"),
|
||||||
"format": FORMATS["format_tcell_date_left"],
|
"format": FORMATS["format_tcell_date_left"],
|
||||||
@ -76,7 +70,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"width": 20,
|
"width": 20,
|
||||||
},
|
},
|
||||||
"date_remove": {
|
"date_remove": {
|
||||||
"header": {"type": "string", "value": self._("Asset Removal Date")},
|
"header": {"type": "string", "value": _("Asset Removal Date")},
|
||||||
"asset": {
|
"asset": {
|
||||||
"value": self._render("asset.date_remove or ''"),
|
"value": self._render("asset.date_remove or ''"),
|
||||||
"format": FORMATS["format_tcell_date_left"],
|
"format": FORMATS["format_tcell_date_left"],
|
||||||
@ -86,7 +80,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"depreciation_base": {
|
"depreciation_base": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Depreciation Base"),
|
"value": _("Depreciation Base"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -109,7 +103,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"salvage_value": {
|
"salvage_value": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Salvage Value"),
|
"value": _("Salvage Value"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -132,7 +126,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"purchase_value": {
|
"purchase_value": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Purchase Value"),
|
"value": _("Purchase Value"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -155,7 +149,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"period_start_value": {
|
"period_start_value": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Period Start Value"),
|
"value": _("Period Start Value"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -178,7 +172,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"period_depr": {
|
"period_depr": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Period Depreciation"),
|
"value": _("Period Depreciation"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -201,7 +195,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"period_end_value": {
|
"period_end_value": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Period End Value"),
|
"value": _("Period End Value"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -224,7 +218,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"period_end_depr": {
|
"period_end_depr": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Tot. Depreciation"),
|
"value": _("Tot. Depreciation"),
|
||||||
"format": FORMATS["format_theader_yellow_right"],
|
"format": FORMATS["format_theader_yellow_right"],
|
||||||
},
|
},
|
||||||
"asset_group": {
|
"asset_group": {
|
||||||
@ -247,7 +241,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"method": {
|
"method": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Comput. Method"),
|
"value": _("Comput. Method"),
|
||||||
"format": FORMATS["format_theader_yellow_center"],
|
"format": FORMATS["format_theader_yellow_center"],
|
||||||
},
|
},
|
||||||
"asset": {
|
"asset": {
|
||||||
@ -260,7 +254,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"method_number": {
|
"method_number": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Number of Years"),
|
"value": _("Number of Years"),
|
||||||
"format": FORMATS["format_theader_yellow_center"],
|
"format": FORMATS["format_theader_yellow_center"],
|
||||||
},
|
},
|
||||||
"asset": {
|
"asset": {
|
||||||
@ -273,7 +267,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"prorata": {
|
"prorata": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Prorata Temporis"),
|
"value": _("Prorata Temporis"),
|
||||||
"format": FORMATS["format_theader_yellow_center"],
|
"format": FORMATS["format_theader_yellow_center"],
|
||||||
},
|
},
|
||||||
"asset": {
|
"asset": {
|
||||||
@ -286,7 +280,7 @@ class AssetReportXlsx(models.AbstractModel):
|
|||||||
"state": {
|
"state": {
|
||||||
"header": {
|
"header": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": self._("Status"),
|
"value": _("Status"),
|
||||||
"format": FORMATS["format_theader_yellow_center"],
|
"format": FORMATS["format_theader_yellow_center"],
|
||||||
},
|
},
|
||||||
"asset": {
|
"asset": {
|
||||||
|
@ -83,19 +83,20 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# analytic configuration
|
# analytic configuration
|
||||||
cls.env.user.write(
|
cls.env.user.groups_id += cls.env.ref("analytic.group_analytic_accounting")
|
||||||
{
|
|
||||||
"groups_id": [
|
cls.default_plan = cls.env["account.analytic.plan"].create(
|
||||||
(4, cls.env.ref("analytic.group_analytic_accounting").id),
|
{"name": "Default", "company_id": False}
|
||||||
(4, cls.env.ref("analytic.group_analytic_tags").id),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
cls.analytic_account = cls.env["account.analytic.account"].create(
|
cls.analytic_account = cls.env["account.analytic.account"].create(
|
||||||
{"name": "test_analytic_account"}
|
{"name": "test_analytic_account", "plan_id": cls.default_plan.id}
|
||||||
)
|
)
|
||||||
cls.analytic_tag = cls.env["account.analytic.tag"].create(
|
|
||||||
{"name": "test_analytic_tag"}
|
cls.distribution = cls.env["account.analytic.distribution.model"].create(
|
||||||
|
{
|
||||||
|
"partner_id": cls.partner.id,
|
||||||
|
"analytic_distribution": {cls.analytic_account.id: 100},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Asset Profile 1
|
# Asset Profile 1
|
||||||
@ -130,8 +131,12 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
"method_time": "year",
|
"method_time": "year",
|
||||||
"method_number": 5,
|
"method_number": 5,
|
||||||
"method_period": "year",
|
"method_period": "year",
|
||||||
"account_analytic_id": cls.analytic_account.id,
|
"analytic_distribution": cls.distribution._get_distribution(
|
||||||
"analytic_tag_ids": [(4, cls.analytic_tag.id)],
|
{
|
||||||
|
"partner_id": cls.partner.id,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
# "account_analytic_id": cls.analytic_account.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -181,7 +186,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
|
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
|
||||||
for i in range(1, 36):
|
for i in range(1, 36):
|
||||||
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
|
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
|
||||||
@ -199,7 +204,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
|
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
|
||||||
for i in range(1, 4):
|
for i in range(1, 4):
|
||||||
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
|
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
|
||||||
@ -249,17 +254,17 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
self.assertEqual(len(vehicle0.depreciation_line_ids), 1)
|
self.assertEqual(len(vehicle0.depreciation_line_ids), 1)
|
||||||
# Compute the depreciation boards
|
# Compute the depreciation boards
|
||||||
ict0.compute_depreciation_board()
|
ict0.compute_depreciation_board()
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
self.assertEqual(len(ict0.depreciation_line_ids), 4)
|
self.assertEqual(len(ict0.depreciation_line_ids), 4)
|
||||||
self.assertEqual(ict0.depreciation_line_ids[1].amount, 500)
|
self.assertEqual(ict0.depreciation_line_ids[1].amount, 500)
|
||||||
vehicle0.compute_depreciation_board()
|
vehicle0.compute_depreciation_board()
|
||||||
vehicle0.refresh()
|
vehicle0.invalidate_recordset()
|
||||||
self.assertEqual(len(vehicle0.depreciation_line_ids), 6)
|
self.assertEqual(len(vehicle0.depreciation_line_ids), 6)
|
||||||
self.assertEqual(vehicle0.depreciation_line_ids[1].amount, 2000)
|
self.assertEqual(vehicle0.depreciation_line_ids[1].amount, 2000)
|
||||||
# Post the first depreciation line
|
# Post the first depreciation line
|
||||||
ict0.validate()
|
ict0.validate()
|
||||||
ict0.depreciation_line_ids[1].create_move()
|
ict0.depreciation_line_ids[1].create_move()
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
self.assertEqual(ict0.state, "open")
|
self.assertEqual(ict0.state, "open")
|
||||||
self.assertEqual(ict0.value_depreciated, 500)
|
self.assertEqual(ict0.value_depreciated, 500)
|
||||||
self.assertEqual(ict0.value_residual, 1000)
|
self.assertEqual(ict0.value_residual, 1000)
|
||||||
@ -271,11 +276,15 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
lambda line: line.account_id.internal_group == "expense"
|
lambda line: line.account_id.internal_group == "expense"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
expense_line.analytic_account_id.id,
|
expense_line.analytic_distribution,
|
||||||
self.analytic_account.id,
|
self.distribution._get_distribution(
|
||||||
|
{
|
||||||
|
"partner_id": self.partner.id,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
self.assertEqual(expense_line.analytic_tag_ids.id, self.analytic_tag.id)
|
or False,
|
||||||
vehicle0.refresh()
|
)
|
||||||
|
vehicle0.invalidate_recordset()
|
||||||
self.assertEqual(vehicle0.state, "open")
|
self.assertEqual(vehicle0.state, "open")
|
||||||
self.assertEqual(vehicle0.value_depreciated, 2000)
|
self.assertEqual(vehicle0.value_depreciated, 2000)
|
||||||
self.assertEqual(vehicle0.value_residual, 8000)
|
self.assertEqual(vehicle0.value_residual, 8000)
|
||||||
@ -296,7 +305,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
if calendar.isleap(date.today().year):
|
if calendar.isleap(date.today().year):
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
asset.depreciation_line_ids[1].amount, 46.44, places=2
|
asset.depreciation_line_ids[1].amount, 46.44, places=2
|
||||||
@ -347,7 +356,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
)
|
)
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
# check the depreciated value is the initial value
|
# check the depreciated value is the initial value
|
||||||
self.assertAlmostEqual(asset.value_depreciated, 325.08, places=2)
|
self.assertAlmostEqual(asset.value_depreciated, 325.08, places=2)
|
||||||
# check computed values in the depreciation board
|
# check computed values in the depreciation board
|
||||||
@ -399,7 +408,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
)
|
)
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
self.assertEqual(len(asset.depreciation_line_ids), 2)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
# check the depreciated value is the initial value
|
# check the depreciated value is the initial value
|
||||||
self.assertAlmostEqual(asset.value_depreciated, 279.44, places=2)
|
self.assertAlmostEqual(asset.value_depreciated, 279.44, places=2)
|
||||||
# check computed values in the depreciation board
|
# check computed values in the depreciation board
|
||||||
@ -440,7 +449,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
# check values in the depreciation board
|
# check values in the depreciation board
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 5)
|
self.assertEqual(len(asset.depreciation_line_ids), 5)
|
||||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
|
||||||
@ -464,7 +473,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
# check values in the depreciation board
|
# check values in the depreciation board
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 15)
|
self.assertEqual(len(asset.depreciation_line_ids), 15)
|
||||||
# lines prior to asset start period are grouped in the first entry
|
# lines prior to asset start period are grouped in the first entry
|
||||||
@ -491,7 +500,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
# check values in the depreciation board
|
# check values in the depreciation board
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
||||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
|
||||||
@ -517,7 +526,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
# check values in the depreciation board
|
# check values in the depreciation board
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
self.assertEqual(len(asset.depreciation_line_ids), 6)
|
||||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 200.00, places=2)
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 200.00, places=2)
|
||||||
@ -553,7 +562,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
wiz.remove()
|
wiz.remove()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
self.assertEqual(len(asset.depreciation_line_ids), 3)
|
self.assertEqual(len(asset.depreciation_line_ids), 3)
|
||||||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 81.46, places=2)
|
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 81.46, places=2)
|
||||||
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 4918.54, places=2)
|
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 4918.54, places=2)
|
||||||
@ -569,7 +578,6 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
invoice.invoice_line_ids[0].write(
|
invoice.invoice_line_ids[0].write(
|
||||||
{"quantity": 2, "asset_profile_id": asset_profile.id}
|
{"quantity": 2, "asset_profile_id": asset_profile.id}
|
||||||
)
|
)
|
||||||
invoice._onchange_invoice_line_ids()
|
|
||||||
invoice.action_post()
|
invoice.action_post()
|
||||||
# get all asset after invoice validation
|
# get all asset after invoice validation
|
||||||
current_asset = self.env["account.asset"].search([])
|
current_asset = self.env["account.asset"].search([])
|
||||||
@ -648,7 +656,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
day_rate = 3333 / 1827 # 3333 / 1827 depreciation days
|
day_rate = 3333 / 1827 # 3333 / 1827 depreciation days
|
||||||
for i in range(1, 10):
|
for i in range(1, 10):
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
@ -680,7 +688,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
for i in range(2, 11):
|
for i in range(2, 11):
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
asset.depreciation_line_ids[i].amount, 166.58, places=2
|
asset.depreciation_line_ids[i].amount, 166.58, places=2
|
||||||
@ -709,7 +717,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
for _i in range(1, 11):
|
for _i in range(1, 11):
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
asset.depreciation_line_ids[1].amount, 166.67, places=2
|
asset.depreciation_line_ids[1].amount, 166.67, places=2
|
||||||
@ -781,7 +789,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
for _i in range(1, 11):
|
for _i in range(1, 11):
|
||||||
self.assertAlmostEqual(
|
self.assertAlmostEqual(
|
||||||
asset.depreciation_line_ids[1].amount, 166.67, places=2
|
asset.depreciation_line_ids[1].amount, 166.67, places=2
|
||||||
@ -813,7 +821,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
self.company_data["company"].fiscalyear_lock_date = time.strftime("2021-05-31")
|
self.company_data["company"].fiscalyear_lock_date = time.strftime("2021-05-31")
|
||||||
# Compute the depreciation board
|
# Compute the depreciation board
|
||||||
asset.compute_depreciation_board()
|
asset.compute_depreciation_board()
|
||||||
asset.refresh()
|
asset.invalidate_recordset()
|
||||||
d_lines = asset.depreciation_line_ids
|
d_lines = asset.depreciation_line_ids
|
||||||
init_lines = d_lines[1:6]
|
init_lines = d_lines[1:6]
|
||||||
# Jan to May entries are before the lock date -> marked as init
|
# Jan to May entries are before the lock date -> marked as init
|
||||||
@ -850,12 +858,12 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
ict0.profile_id.allow_reversal = True
|
ict0.profile_id.allow_reversal = True
|
||||||
# compute the depreciation boards
|
# compute the depreciation boards
|
||||||
ict0.compute_depreciation_board()
|
ict0.compute_depreciation_board()
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
# post the first depreciation line
|
# post the first depreciation line
|
||||||
ict0.validate()
|
ict0.validate()
|
||||||
ict0.depreciation_line_ids[1].create_move()
|
ict0.depreciation_line_ids[1].create_move()
|
||||||
original_move = ict0.depreciation_line_ids[1].move_id
|
original_move = ict0.depreciation_line_ids[1].move_id
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
self.assertEqual(ict0.state, "open")
|
self.assertEqual(ict0.state, "open")
|
||||||
self.assertEqual(ict0.value_depreciated, 500)
|
self.assertEqual(ict0.value_depreciated, 500)
|
||||||
self.assertEqual(ict0.value_residual, 1000)
|
self.assertEqual(ict0.value_residual, 1000)
|
||||||
@ -876,7 +884,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
reverse_wizard = wiz.save()
|
reverse_wizard = wiz.save()
|
||||||
reverse_wizard.write({"journal_id": depreciation_line.move_id.journal_id.id})
|
reverse_wizard.write({"journal_id": depreciation_line.move_id.journal_id.id})
|
||||||
reverse_wizard.reverse_move()
|
reverse_wizard.reverse_move()
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
self.assertEqual(ict0.value_depreciated, 0)
|
self.assertEqual(ict0.value_depreciated, 0)
|
||||||
self.assertEqual(ict0.value_residual, 1500)
|
self.assertEqual(ict0.value_residual, 1500)
|
||||||
self.assertEqual(len(original_move.reversal_move_id), 1)
|
self.assertEqual(len(original_move.reversal_move_id), 1)
|
||||||
@ -899,17 +907,17 @@ class TestAssetManagement(AccountTestInvoicingCommon):
|
|||||||
)
|
)
|
||||||
# compute the depreciation boards
|
# compute the depreciation boards
|
||||||
ict0.compute_depreciation_board()
|
ict0.compute_depreciation_board()
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
# post the first depreciation line
|
# post the first depreciation line
|
||||||
ict0.validate()
|
ict0.validate()
|
||||||
ict0.depreciation_line_ids[1].create_move()
|
ict0.depreciation_line_ids[1].create_move()
|
||||||
original_move_id = ict0.depreciation_line_ids[1].move_id.id
|
original_move_id = ict0.depreciation_line_ids[1].move_id.id
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
self.assertEqual(ict0.state, "open")
|
self.assertEqual(ict0.state, "open")
|
||||||
self.assertEqual(ict0.value_depreciated, 500)
|
self.assertEqual(ict0.value_depreciated, 500)
|
||||||
self.assertEqual(ict0.value_residual, 1000)
|
self.assertEqual(ict0.value_residual, 1000)
|
||||||
ict0.depreciation_line_ids[1].unlink_move()
|
ict0.depreciation_line_ids[1].unlink_move()
|
||||||
ict0.refresh()
|
ict0.invalidate_recordset()
|
||||||
self.assertEqual(ict0.value_depreciated, 0)
|
self.assertEqual(ict0.value_depreciated, 0)
|
||||||
self.assertEqual(ict0.value_residual, 1500)
|
self.assertEqual(ict0.value_residual, 1500)
|
||||||
move = self.env["account.move"].search([("id", "=", original_move_id)])
|
move = self.env["account.move"].search([("id", "=", original_move_id)])
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
<field name="model">account.account</field>
|
<field name="model">account.account</field>
|
||||||
<field name="inherit_id" ref="account.view_account_form" />
|
<field name="inherit_id" ref="account.view_account_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<group name="options_group" position="inside">
|
<field name="account_type" position="before">
|
||||||
<field name="asset_profile_id" />
|
<field name="asset_profile_id" />
|
||||||
</group>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
@ -56,7 +56,9 @@
|
|||||||
<field name="name" class="oe_inline" />
|
<field name="name" class="oe_inline" />
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<group col="4">
|
<group>
|
||||||
|
<group id="header_left_group">
|
||||||
|
<field name="company_id" invisible="1" />
|
||||||
<field name="code" />
|
<field name="code" />
|
||||||
<field
|
<field
|
||||||
name="company_id"
|
name="company_id"
|
||||||
@ -69,12 +71,14 @@
|
|||||||
invisible="1"
|
invisible="1"
|
||||||
/>
|
/>
|
||||||
<field name="move_line_check" invisible="1" />
|
<field name="move_line_check" invisible="1" />
|
||||||
<newline />
|
</group>
|
||||||
|
<group id="header_right_group">
|
||||||
<field name="depreciation_base" />
|
<field name="depreciation_base" />
|
||||||
<field name="value_depreciated" />
|
<field name="value_depreciated" />
|
||||||
<field name="value_residual" />
|
<field name="value_residual" />
|
||||||
<field name="active" invisible="1" />
|
<field name="active" invisible="1" />
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
<page string="General">
|
<page string="General">
|
||||||
<group>
|
<group>
|
||||||
@ -96,19 +100,19 @@
|
|||||||
<field name="date_remove" />
|
<field name="date_remove" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group col="4" string="Other Information">
|
<group string="Other Information">
|
||||||
|
<group>
|
||||||
<field name="profile_id" />
|
<field name="profile_id" />
|
||||||
<field name="group_ids" widget="many2many_tags" />
|
<field name="group_ids" widget="many2many_tags" />
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
<field name="partner_id" />
|
<field name="partner_id" />
|
||||||
<field
|
<field
|
||||||
name="account_analytic_id"
|
name="analytic_distribution"
|
||||||
groups="analytic.group_analytic_accounting"
|
groups="analytic.group_analytic_accounting"
|
||||||
|
widget="analytic_distribution"
|
||||||
/>
|
/>
|
||||||
<field
|
</group>
|
||||||
name="analytic_tag_ids"
|
|
||||||
groups="analytic.group_analytic_tags"
|
|
||||||
widget="many2many_tags"
|
|
||||||
/>
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group string="Depreciation Dates">
|
<group string="Depreciation Dates">
|
||||||
@ -246,11 +250,6 @@
|
|||||||
<field name="journal_id" optional="show" />
|
<field name="journal_id" optional="show" />
|
||||||
<field name="account_id" />
|
<field name="account_id" />
|
||||||
<field name="partner_id" optional="show" />
|
<field name="partner_id" optional="show" />
|
||||||
<field
|
|
||||||
name="analytic_account_id"
|
|
||||||
groups="analytic.group_analytic_accounting"
|
|
||||||
optional="show"
|
|
||||||
/>
|
|
||||||
<field name="ref" />
|
<field name="ref" />
|
||||||
<field name="name" optional="hide" />
|
<field name="name" optional="hide" />
|
||||||
<field name="debit" sum="1" />
|
<field name="debit" sum="1" />
|
||||||
@ -287,7 +286,6 @@
|
|||||||
<field name="date_start" optional="show" />
|
<field name="date_start" optional="show" />
|
||||||
<field name="date_remove" optional="show" />
|
<field name="date_remove" optional="show" />
|
||||||
<field name="profile_id" optional="show" />
|
<field name="profile_id" optional="show" />
|
||||||
<field name="account_analytic_id" optional="hide" />
|
|
||||||
<field name="method" optional="hide" />
|
<field name="method" optional="hide" />
|
||||||
<field name="prorata" optional="hide" />
|
<field name="prorata" optional="hide" />
|
||||||
<field name="group_ids" widget="many2many_tags" optional="hide" />
|
<field name="group_ids" widget="many2many_tags" optional="hide" />
|
||||||
@ -362,12 +360,6 @@
|
|||||||
domain=""
|
domain=""
|
||||||
context="{'group_by': 'state'}"
|
context="{'group_by': 'state'}"
|
||||||
/>
|
/>
|
||||||
<filter
|
|
||||||
string="Analytic account"
|
|
||||||
name="account_analytic_groupby"
|
|
||||||
domain=""
|
|
||||||
context="{'group_by': 'account_analytic_id'}"
|
|
||||||
/>
|
|
||||||
<filter
|
<filter
|
||||||
string="Computation Method"
|
string="Computation Method"
|
||||||
name="method_groupby"
|
name="method_groupby"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!-- pylint:disable=duplicate-xml-fields -->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="account_asset_group_view_form" model="ir.ui.view">
|
<record id="account_asset_group_view_form" model="ir.ui.view">
|
||||||
<field name="name">account.asset.group.form</field>
|
<field name="name">account.asset.group.form</field>
|
||||||
@ -7,6 +8,7 @@
|
|||||||
<form string="Asset Group">
|
<form string="Asset Group">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="company_id" invisible="1" />
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="code" />
|
<field name="code" />
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
@ -25,10 +27,15 @@
|
|||||||
<field name="model">account.asset.group</field>
|
<field name="model">account.asset.group</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
|
<field name="company_id" invisible="1" />
|
||||||
<field name="name" />
|
<field name="name" />
|
||||||
<field name="code" optional="show" />
|
<field name="code" optional="show" />
|
||||||
<field name="parent_id" />
|
<field name="parent_id" />
|
||||||
<field name="company_id" groups="base.group_multi_company" />
|
<field
|
||||||
|
name="company_id"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
groups="base.group_multi_company"
|
||||||
|
/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
<field name="company_id" invisible="1" />
|
||||||
<field name="group_ids" widget="many2many_tags" />
|
<field name="group_ids" widget="many2many_tags" />
|
||||||
<field name="asset_product_item" />
|
<field name="asset_product_item" />
|
||||||
<field name="active" invisible="1" />
|
<field name="active" invisible="1" />
|
||||||
@ -68,11 +69,9 @@
|
|||||||
groups="analytic.group_analytic_accounting"
|
groups="analytic.group_analytic_accounting"
|
||||||
string="Analytic Information"
|
string="Analytic Information"
|
||||||
>
|
>
|
||||||
<field name="account_analytic_id" />
|
|
||||||
<field
|
<field
|
||||||
name="analytic_tag_ids"
|
name="analytic_distribution"
|
||||||
widget="many2many_tags"
|
widget="analytic_distribution"
|
||||||
groups="analytic.group_analytic_tags"
|
|
||||||
/>
|
/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
@ -96,7 +95,6 @@
|
|||||||
<field name="account_expense_depreciation_id" optional="hide" />
|
<field name="account_expense_depreciation_id" optional="hide" />
|
||||||
<field name="account_plus_value_id" optional="hide" />
|
<field name="account_plus_value_id" optional="hide" />
|
||||||
<field name="account_min_value_id" optional="hide" />
|
<field name="account_min_value_id" optional="hide" />
|
||||||
<field name="account_analytic_id" optional="hide" />
|
|
||||||
<field name="method" optional="show" />
|
<field name="method" optional="show" />
|
||||||
<field name="prorata" optional="hide" />
|
<field name="prorata" optional="hide" />
|
||||||
<field
|
<field
|
||||||
@ -121,11 +119,6 @@
|
|||||||
domain="[('active', '=', False)]"
|
domain="[('active', '=', False)]"
|
||||||
/>
|
/>
|
||||||
<group name="groupby">
|
<group name="groupby">
|
||||||
<filter
|
|
||||||
name="account_analytic_groupby"
|
|
||||||
string="account_analytic_id"
|
|
||||||
context="{'group_by': 'account_analytic_id'}"
|
|
||||||
/>
|
|
||||||
<filter
|
<filter
|
||||||
name="method_groupby"
|
name="method_groupby"
|
||||||
string="Computation Method"
|
string="Computation Method"
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<field name="name">account.move.form.account.asset.management</field>
|
<field name="name">account.move.form.account.asset.management</field>
|
||||||
<field name="model">account.move</field>
|
<field name="model">account.move</field>
|
||||||
<field name="inherit_id" ref="account.view_move_form" />
|
<field name="inherit_id" ref="account.view_move_form" />
|
||||||
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]" />
|
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
|
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
|
||||||
<button
|
<button
|
||||||
@ -13,6 +12,7 @@
|
|||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-cube"
|
icon="fa-cube"
|
||||||
attrs="{'invisible': [('asset_count', '=', 0)]}"
|
attrs="{'invisible': [('asset_count', '=', 0)]}"
|
||||||
|
groups="account.group_account_invoice"
|
||||||
>
|
>
|
||||||
<div class="o_field_widget o_stat_info">
|
<div class="o_field_widget o_stat_info">
|
||||||
<span class="o_stat_value">
|
<span class="o_stat_value">
|
||||||
@ -30,11 +30,12 @@
|
|||||||
name="asset_profile_id"
|
name="asset_profile_id"
|
||||||
attrs="{'column_invisible': [('parent.move_type', 'not in', ('in_invoice', 'in_refund'))]}"
|
attrs="{'column_invisible': [('parent.move_type', 'not in', ('in_invoice', 'in_refund'))]}"
|
||||||
optional="show"
|
optional="show"
|
||||||
|
groups="account.group_account_invoice"
|
||||||
/>
|
/>
|
||||||
<field
|
<field
|
||||||
name="asset_id"
|
name="asset_id"
|
||||||
attrs="{'column_invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"
|
attrs="{'column_invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund'))]}"
|
||||||
groups="account.group_account_manager"
|
groups="account.group_account_manager,account.group_account_invoice"
|
||||||
optional="show"
|
optional="show"
|
||||||
/>
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
@ -46,10 +47,11 @@
|
|||||||
name="asset_profile_id"
|
name="asset_profile_id"
|
||||||
domain="[('company_id','=', parent.company_id)]"
|
domain="[('company_id','=', parent.company_id)]"
|
||||||
optional="hide"
|
optional="hide"
|
||||||
|
groups="account.group_account_invoice"
|
||||||
/>
|
/>
|
||||||
<field
|
<field
|
||||||
name="asset_id"
|
name="asset_id"
|
||||||
groups="account.group_account_manager"
|
groups="account.group_account_manager,account.group_account_invoice"
|
||||||
optional="show"
|
optional="show"
|
||||||
/>
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<field name="model">account.move.line</field>
|
<field name="model">account.move.line</field>
|
||||||
<field name="inherit_id" ref="account.view_move_line_form" />
|
<field name="inherit_id" ref="account.view_move_line_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="statement_id" position="after">
|
<field name="statement_line_id" position="after">
|
||||||
<field
|
<field
|
||||||
name="asset_profile_id"
|
name="asset_profile_id"
|
||||||
domain="[('company_id','=', parent.company_id)]"
|
domain="[('company_id','=', parent.company_id)]"
|
||||||
|
@ -36,7 +36,6 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
)
|
)
|
||||||
force_date = fields.Date(string="Force accounting date")
|
force_date = fields.Date(string="Force accounting date")
|
||||||
sale_value = fields.Monetary(
|
sale_value = fields.Monetary(
|
||||||
string="Sale Value",
|
|
||||||
default=lambda self: self._default_sale_value(),
|
default=lambda self: self._default_sale_value(),
|
||||||
currency_field="company_currency_id",
|
currency_field="company_currency_id",
|
||||||
)
|
)
|
||||||
@ -341,8 +340,7 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
move_line_vals = {
|
move_line_vals = {
|
||||||
"name": asset.name,
|
"name": asset.name,
|
||||||
"account_id": self.account_residual_value_id.id,
|
"account_id": self.account_residual_value_id.id,
|
||||||
"analytic_account_id": asset.account_analytic_id.id,
|
"analytic_distribution": asset.analytic_distribution,
|
||||||
"analytic_tag_ids": [(4, tag.id) for tag in asset.analytic_tag_ids],
|
|
||||||
"debit": residual_value,
|
"debit": residual_value,
|
||||||
"credit": 0.0,
|
"credit": 0.0,
|
||||||
"partner_id": partner_id,
|
"partner_id": partner_id,
|
||||||
@ -355,10 +353,7 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
move_line_vals = {
|
move_line_vals = {
|
||||||
"name": asset.name,
|
"name": asset.name,
|
||||||
"account_id": self.account_sale_id.id,
|
"account_id": self.account_sale_id.id,
|
||||||
"analytic_account_id": asset.account_analytic_id.id,
|
"analytic_distribution": asset.analytic_distribution,
|
||||||
"analytic_tag_ids": [
|
|
||||||
(4, tag.id) for tag in asset.analytic_tag_ids
|
|
||||||
],
|
|
||||||
"debit": sale_value,
|
"debit": sale_value,
|
||||||
"credit": 0.0,
|
"credit": 0.0,
|
||||||
"partner_id": partner_id,
|
"partner_id": partner_id,
|
||||||
@ -375,10 +370,9 @@ class AccountAssetRemove(models.TransientModel):
|
|||||||
move_line_vals = {
|
move_line_vals = {
|
||||||
"name": asset.name,
|
"name": asset.name,
|
||||||
"account_id": account_id,
|
"account_id": account_id,
|
||||||
"analytic_account_id": asset.account_analytic_id.id,
|
|
||||||
"analytic_tag_ids": [(4, tag.id) for tag in asset.analytic_tag_ids],
|
|
||||||
"debit": balance_comp < 0 and -balance or 0.0,
|
"debit": balance_comp < 0 and -balance or 0.0,
|
||||||
"credit": balance_comp > 0 and balance or 0.0,
|
"credit": balance_comp > 0 and balance or 0.0,
|
||||||
|
"analytic_distribution": asset.analytic_distribution,
|
||||||
"partner_id": partner_id,
|
"partner_id": partner_id,
|
||||||
"asset_id": asset.id,
|
"asset_id": asset.id,
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
<field name="model">account.asset.remove</field>
|
<field name="model">account.asset.remove</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Remove Asset">
|
<form string="Remove Asset">
|
||||||
<group colspan="4" col="4">
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="company_id" invisible="1" />
|
||||||
<field name="company_id" groups="base.group_multi_company" />
|
<field name="company_id" groups="base.group_multi_company" />
|
||||||
<field name="date_remove" />
|
<field name="date_remove" />
|
||||||
<field name="force_date" />
|
<field name="force_date" />
|
||||||
@ -14,9 +16,8 @@
|
|||||||
name="account_sale_id"
|
name="account_sale_id"
|
||||||
attrs="{'invisible': [('sale_value', '=', 0.0)], 'required': [('sale_value', '>', 0.0)]}"
|
attrs="{'invisible': [('sale_value', '=', 0.0)], 'required': [('sale_value', '>', 0.0)]}"
|
||||||
/>
|
/>
|
||||||
<newline />
|
</group>
|
||||||
<field name="posting_regime" />
|
<group>
|
||||||
<newline />
|
|
||||||
<field
|
<field
|
||||||
name="account_plus_value_id"
|
name="account_plus_value_id"
|
||||||
attrs="{'invisible': [('posting_regime', '=', 'residual_value')], 'required': [('posting_regime', '!=', 'residual_value')]}"
|
attrs="{'invisible': [('posting_regime', '=', 'residual_value')], 'required': [('posting_regime', '!=', 'residual_value')]}"
|
||||||
@ -29,6 +30,10 @@
|
|||||||
name="account_residual_value_id"
|
name="account_residual_value_id"
|
||||||
attrs="{'invisible': [('posting_regime', '!=', 'residual_value')], 'required': [('posting_regime', '=', 'residual_value')]}"
|
attrs="{'invisible': [('posting_regime', '!=', 'residual_value')], 'required': [('posting_regime', '=', 'residual_value')]}"
|
||||||
/>
|
/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="posting_regime" />
|
||||||
|
</group>
|
||||||
<separator string="Notes" colspan="4" />
|
<separator string="Notes" colspan="4" />
|
||||||
<field name="note" nolabel="1" colspan="4" />
|
<field name="note" nolabel="1" colspan="4" />
|
||||||
</group>
|
</group>
|
||||||
|
Loading…
Reference in New Issue
Block a user