2
0

[MIG] account_asset_management: Migration to 16.0

This commit is contained in:
Rodrigo 2022-12-24 01:28:55 +01:00
parent 3c5d26b456
commit f1371e5b33
16 changed files with 231 additions and 257 deletions

View File

@ -5,7 +5,7 @@
{
"name": "Assets Management",
"version": "15.0.1.0.1",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"depends": ["account", "report_xlsx_helper"],
"excludes": ["account_asset"],

View File

@ -32,7 +32,7 @@ class DummyFy(object):
class AccountAsset(models.Model):
_name = "account.asset"
_inherit = ["mail.thread", "mail.activity.mixin"]
_inherit = ["mail.thread", "mail.activity.mixin", "analytic.mixin"]
_description = "Asset"
_order = "date_start desc, code, name"
_check_company_auto = True
@ -59,7 +59,6 @@ class AccountAsset(models.Model):
states=READONLY_STATES,
)
purchase_value = fields.Monetary(
string="Purchase Value",
required=True,
states=READONLY_STATES,
currency_field="company_currency_id",
@ -68,7 +67,6 @@ class AccountAsset(models.Model):
"\nPurchase Value - Salvage Value.",
)
salvage_value = fields.Monetary(
string="Salvage Value",
states=READONLY_STATES,
currency_field="company_currency_id",
help="The estimated value that an asset will realize upon "
@ -77,7 +75,6 @@ class AccountAsset(models.Model):
)
depreciation_base = fields.Monetary(
compute="_compute_depreciation_base",
string="Depreciation Base",
store=True,
currency_field="company_currency_id",
help="This amount represent the depreciation base "
@ -271,20 +268,6 @@ class AccountAsset(models.Model):
string="Company Currency",
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(
string="Accumulate missed depreciations",
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
@api.depends("profile_id")
def _compute_analytic_tag_ids(self):
def _compute_analytic_distribution(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")
def _check_method(self):
@ -444,14 +427,18 @@ class AccountAsset(models.Model):
{"amount": self.depreciation_base, "line_date": self.date_start}
)
@api.model
def create(self, vals):
asset = super().create(vals)
if self.env.context.get("create_asset_from_move_line"):
# Trigger compute of depreciation_base
asset.salvage_value = 0.0
asset._create_first_asset_line()
return asset
@api.model_create_multi
def create(self, vals_list):
asset_ids = super().create(vals_list)
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
asset_id.salvage_value = 0.0
asset_id._create_first_asset_line()
return asset_ids
def write(self, vals):
res = super().write(vals)

View File

@ -16,7 +16,7 @@ class AccountAssetGroup(models.Model):
name = fields.Char(size=64, required=True, 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(
comodel_name="res.company",
string="Company",

View File

@ -35,9 +35,7 @@ class AccountAssetLine(models.Model):
string="Depreciation Base",
currency_field="company_currency_id",
)
amount = fields.Monetary(
string="Amount", required=True, currency_field="company_currency_id"
)
amount = fields.Monetary(required=True, currency_field="company_currency_id")
remaining_value = fields.Monetary(
compute="_compute_values",
string="Next Period Depreciation",
@ -235,16 +233,14 @@ class AccountAssetLine(models.Model):
currency = asset.company_id.currency_id
amount = self.amount
amount_comp = currency.compare_amounts(amount, 0)
analytic_id = False
analytic_tags = self.env["account.analytic.tag"]
analytic_distribution = False
if ml_type == "depreciation":
debit = amount_comp < 0 and -amount or 0.0
credit = amount_comp > 0 and amount or 0.0
elif ml_type == "expense":
debit = 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_tags = asset.analytic_tag_ids
analytic_distribution = asset.analytic_distribution
move_line_data = {
"name": asset.name,
"ref": self.name,
@ -254,8 +250,7 @@ class AccountAssetLine(models.Model):
"debit": debit,
"journal_id": asset.profile_id.journal_id.id,
"partner_id": asset.partner_id.id,
"analytic_account_id": analytic_id,
"analytic_tag_ids": [(4, tag.id) for tag in analytic_tags],
"analytic_distribution": analytic_distribution,
"date": depreciation_date,
"asset_id": asset.id,
}

View File

@ -7,18 +7,13 @@ from odoo.exceptions import UserError
class AccountAssetProfile(models.Model):
_name = "account.asset.profile"
_inherit = "analytic.mixin"
_check_company_auto = True
_description = "Asset profile"
_order = "name"
name = fields.Char(size=64, required=True, index=True)
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(
comodel_name="account.account",
domain="[('deprecated', '=', False), ('company_id', '=', company_id)]",
@ -207,17 +202,22 @@ class AccountAssetProfile(models.Model):
if profile.method_time != "year":
profile.prorata = True
@api.model
def create(self, vals):
if vals.get("method_time") != "year" and not vals.get("prorata"):
vals["prorata"] = True
profile = super().create(vals)
acc_id = vals.get("account_asset_id")
if acc_id:
account = self.env["account.account"].browse(acc_id)
if not account.asset_profile_id:
account.write({"asset_profile_id": profile.id})
return profile
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("method_time") != "year" and not vals.get("prorata"):
vals["prorata"] = True
profile_ids = super().create(vals_list)
account_dict = {}
for profile_id in profile_ids.filtered(
lambda x: not x.account_asset_id.asset_profile_id
):
account_dict.setdefault(profile_id.account_asset_id, []).append(
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):
if vals.get("method_time"):

View File

@ -80,7 +80,6 @@ class AccountMove(models.Model):
"purchase_value": depreciation_base,
"partner_id": aml.partner_id,
"date_start": self.date,
"account_analytic_id": aml.analytic_account_id,
}
def action_post(self):
@ -104,7 +103,7 @@ class AccountMove(models.Model):
for key, val in vals.items():
setattr(asset_form, key, val)
asset = asset_form.save()
asset.analytic_tag_ids = aml.analytic_tag_ids
asset.analytic_distribution = aml.analytic_distribution
aml.with_context(
allow_asset=True, allow_asset_removal=True
).asset_id = asset.id
@ -256,7 +255,5 @@ class AccountMoveLine(models.Model):
qty = self.quantity
name = self.name
aml.write({"quantity": 1, "name": "{} {}".format(name, 1)})
aml._onchange_price_subtotal()
for i in range(1, int(qty)):
aml.copy({"name": "{} {}".format(name, i + 1)})
aml.move_id._onchange_invoice_line_ids()

View File

@ -5,7 +5,6 @@ import logging
from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools.translate import translate
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
FORMATS,
@ -23,11 +22,6 @@ class AssetReportXlsx(models.AbstractModel):
_description = "Dynamic XLS asset report generator"
_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):
self._get_assets(wiz, data)
s1 = self._get_acquisition_ws_params(wb, data, wiz)
@ -39,18 +33,18 @@ class AssetReportXlsx(models.AbstractModel):
asset_template = {
"account": {
"header": {"type": "string", "value": self._("Account")},
"header": {"type": "string", "value": _("Account")},
"asset": {
"type": "string",
"value": self._render(
"asset.profile_id.account_asset_id.code or ''"
),
},
"totals": {"type": "string", "value": self._("Totals")},
"totals": {"type": "string", "value": _("Totals")},
"width": 20,
},
"name": {
"header": {"type": "string", "value": self._("Name")},
"header": {"type": "string", "value": _("Name")},
"asset_group": {
"type": "string",
"value": self._render("group.name or ''"),
@ -59,7 +53,7 @@ class AssetReportXlsx(models.AbstractModel):
"width": 40,
},
"code": {
"header": {"type": "string", "value": self._("Reference")},
"header": {"type": "string", "value": _("Reference")},
"asset_group": {
"type": "string",
"value": self._render("group.code or ''"),
@ -68,7 +62,7 @@ class AssetReportXlsx(models.AbstractModel):
"width": 20,
},
"date_start": {
"header": {"type": "string", "value": self._("Asset Start Date")},
"header": {"type": "string", "value": _("Asset Start Date")},
"asset": {
"value": self._render("asset.date_start or ''"),
"format": FORMATS["format_tcell_date_left"],
@ -76,7 +70,7 @@ class AssetReportXlsx(models.AbstractModel):
"width": 20,
},
"date_remove": {
"header": {"type": "string", "value": self._("Asset Removal Date")},
"header": {"type": "string", "value": _("Asset Removal Date")},
"asset": {
"value": self._render("asset.date_remove or ''"),
"format": FORMATS["format_tcell_date_left"],
@ -86,7 +80,7 @@ class AssetReportXlsx(models.AbstractModel):
"depreciation_base": {
"header": {
"type": "string",
"value": self._("Depreciation Base"),
"value": _("Depreciation Base"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -109,7 +103,7 @@ class AssetReportXlsx(models.AbstractModel):
"salvage_value": {
"header": {
"type": "string",
"value": self._("Salvage Value"),
"value": _("Salvage Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -132,7 +126,7 @@ class AssetReportXlsx(models.AbstractModel):
"purchase_value": {
"header": {
"type": "string",
"value": self._("Purchase Value"),
"value": _("Purchase Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -155,7 +149,7 @@ class AssetReportXlsx(models.AbstractModel):
"period_start_value": {
"header": {
"type": "string",
"value": self._("Period Start Value"),
"value": _("Period Start Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -178,7 +172,7 @@ class AssetReportXlsx(models.AbstractModel):
"period_depr": {
"header": {
"type": "string",
"value": self._("Period Depreciation"),
"value": _("Period Depreciation"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -201,7 +195,7 @@ class AssetReportXlsx(models.AbstractModel):
"period_end_value": {
"header": {
"type": "string",
"value": self._("Period End Value"),
"value": _("Period End Value"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -224,7 +218,7 @@ class AssetReportXlsx(models.AbstractModel):
"period_end_depr": {
"header": {
"type": "string",
"value": self._("Tot. Depreciation"),
"value": _("Tot. Depreciation"),
"format": FORMATS["format_theader_yellow_right"],
},
"asset_group": {
@ -247,7 +241,7 @@ class AssetReportXlsx(models.AbstractModel):
"method": {
"header": {
"type": "string",
"value": self._("Comput. Method"),
"value": _("Comput. Method"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@ -260,7 +254,7 @@ class AssetReportXlsx(models.AbstractModel):
"method_number": {
"header": {
"type": "string",
"value": self._("Number of Years"),
"value": _("Number of Years"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@ -273,7 +267,7 @@ class AssetReportXlsx(models.AbstractModel):
"prorata": {
"header": {
"type": "string",
"value": self._("Prorata Temporis"),
"value": _("Prorata Temporis"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {
@ -286,7 +280,7 @@ class AssetReportXlsx(models.AbstractModel):
"state": {
"header": {
"type": "string",
"value": self._("Status"),
"value": _("Status"),
"format": FORMATS["format_theader_yellow_center"],
},
"asset": {

View File

@ -83,19 +83,20 @@ class TestAssetManagement(AccountTestInvoicingCommon):
)
# analytic configuration
cls.env.user.write(
{
"groups_id": [
(4, cls.env.ref("analytic.group_analytic_accounting").id),
(4, cls.env.ref("analytic.group_analytic_tags").id),
],
}
cls.env.user.groups_id += cls.env.ref("analytic.group_analytic_accounting")
cls.default_plan = cls.env["account.analytic.plan"].create(
{"name": "Default", "company_id": False}
)
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
@ -130,8 +131,12 @@ class TestAssetManagement(AccountTestInvoicingCommon):
"method_time": "year",
"method_number": 5,
"method_period": "year",
"account_analytic_id": cls.analytic_account.id,
"analytic_tag_ids": [(4, cls.analytic_tag.id)],
"analytic_distribution": cls.distribution._get_distribution(
{
"partner_id": cls.partner.id,
}
),
# "account_analytic_id": cls.analytic_account.id,
}
)
@ -181,7 +186,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
for i in range(1, 36):
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
@ -199,7 +204,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
self.assertTrue(asset.depreciation_line_ids[0].init_entry)
for i in range(1, 4):
self.assertFalse(asset.depreciation_line_ids[i].init_entry)
@ -249,17 +254,17 @@ class TestAssetManagement(AccountTestInvoicingCommon):
self.assertEqual(len(vehicle0.depreciation_line_ids), 1)
# Compute the depreciation boards
ict0.compute_depreciation_board()
ict0.refresh()
ict0.invalidate_recordset()
self.assertEqual(len(ict0.depreciation_line_ids), 4)
self.assertEqual(ict0.depreciation_line_ids[1].amount, 500)
vehicle0.compute_depreciation_board()
vehicle0.refresh()
vehicle0.invalidate_recordset()
self.assertEqual(len(vehicle0.depreciation_line_ids), 6)
self.assertEqual(vehicle0.depreciation_line_ids[1].amount, 2000)
# Post the first depreciation line
ict0.validate()
ict0.depreciation_line_ids[1].create_move()
ict0.refresh()
ict0.invalidate_recordset()
self.assertEqual(ict0.state, "open")
self.assertEqual(ict0.value_depreciated, 500)
self.assertEqual(ict0.value_residual, 1000)
@ -271,11 +276,15 @@ class TestAssetManagement(AccountTestInvoicingCommon):
lambda line: line.account_id.internal_group == "expense"
)
self.assertEqual(
expense_line.analytic_account_id.id,
self.analytic_account.id,
expense_line.analytic_distribution,
self.distribution._get_distribution(
{
"partner_id": self.partner.id,
}
)
or False,
)
self.assertEqual(expense_line.analytic_tag_ids.id, self.analytic_tag.id)
vehicle0.refresh()
vehicle0.invalidate_recordset()
self.assertEqual(vehicle0.state, "open")
self.assertEqual(vehicle0.value_depreciated, 2000)
self.assertEqual(vehicle0.value_residual, 8000)
@ -296,7 +305,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
if calendar.isleap(date.today().year):
self.assertAlmostEqual(
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)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
# check the depreciated value is the initial value
self.assertAlmostEqual(asset.value_depreciated, 325.08, places=2)
# check computed values in the depreciation board
@ -399,7 +408,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
)
self.assertEqual(len(asset.depreciation_line_ids), 2)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
# check the depreciated value is the initial value
self.assertAlmostEqual(asset.value_depreciated, 279.44, places=2)
# check computed values in the depreciation board
@ -440,7 +449,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
# check values in the depreciation board
self.assertEqual(len(asset.depreciation_line_ids), 5)
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
@ -464,7 +473,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
# check values in the depreciation board
self.assertEqual(len(asset.depreciation_line_ids), 15)
# lines prior to asset start period are grouped in the first entry
@ -491,7 +500,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
# check values in the depreciation board
self.assertEqual(len(asset.depreciation_line_ids), 6)
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 400.00, places=2)
@ -517,7 +526,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
# check values in the depreciation board
self.assertEqual(len(asset.depreciation_line_ids), 6)
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 200.00, places=2)
@ -553,7 +562,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
wiz.remove()
asset.refresh()
asset.invalidate_recordset()
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[2].amount, 4918.54, places=2)
@ -569,7 +578,6 @@ class TestAssetManagement(AccountTestInvoicingCommon):
invoice.invoice_line_ids[0].write(
{"quantity": 2, "asset_profile_id": asset_profile.id}
)
invoice._onchange_invoice_line_ids()
invoice.action_post()
# get all asset after invoice validation
current_asset = self.env["account.asset"].search([])
@ -648,7 +656,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
day_rate = 3333 / 1827 # 3333 / 1827 depreciation days
for i in range(1, 10):
self.assertAlmostEqual(
@ -680,7 +688,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
for i in range(2, 11):
self.assertAlmostEqual(
asset.depreciation_line_ids[i].amount, 166.58, places=2
@ -709,7 +717,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
for _i in range(1, 11):
self.assertAlmostEqual(
asset.depreciation_line_ids[1].amount, 166.67, places=2
@ -781,7 +789,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
}
)
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
for _i in range(1, 11):
self.assertAlmostEqual(
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")
# Compute the depreciation board
asset.compute_depreciation_board()
asset.refresh()
asset.invalidate_recordset()
d_lines = asset.depreciation_line_ids
init_lines = d_lines[1:6]
# 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
# compute the depreciation boards
ict0.compute_depreciation_board()
ict0.refresh()
ict0.invalidate_recordset()
# post the first depreciation line
ict0.validate()
ict0.depreciation_line_ids[1].create_move()
original_move = ict0.depreciation_line_ids[1].move_id
ict0.refresh()
ict0.invalidate_recordset()
self.assertEqual(ict0.state, "open")
self.assertEqual(ict0.value_depreciated, 500)
self.assertEqual(ict0.value_residual, 1000)
@ -876,7 +884,7 @@ class TestAssetManagement(AccountTestInvoicingCommon):
reverse_wizard = wiz.save()
reverse_wizard.write({"journal_id": depreciation_line.move_id.journal_id.id})
reverse_wizard.reverse_move()
ict0.refresh()
ict0.invalidate_recordset()
self.assertEqual(ict0.value_depreciated, 0)
self.assertEqual(ict0.value_residual, 1500)
self.assertEqual(len(original_move.reversal_move_id), 1)
@ -899,17 +907,17 @@ class TestAssetManagement(AccountTestInvoicingCommon):
)
# compute the depreciation boards
ict0.compute_depreciation_board()
ict0.refresh()
ict0.invalidate_recordset()
# post the first depreciation line
ict0.validate()
ict0.depreciation_line_ids[1].create_move()
original_move_id = ict0.depreciation_line_ids[1].move_id.id
ict0.refresh()
ict0.invalidate_recordset()
self.assertEqual(ict0.state, "open")
self.assertEqual(ict0.value_depreciated, 500)
self.assertEqual(ict0.value_residual, 1000)
ict0.depreciation_line_ids[1].unlink_move()
ict0.refresh()
ict0.invalidate_recordset()
self.assertEqual(ict0.value_depreciated, 0)
self.assertEqual(ict0.value_residual, 1500)
move = self.env["account.move"].search([("id", "=", original_move_id)])

View File

@ -5,9 +5,9 @@
<field name="model">account.account</field>
<field name="inherit_id" ref="account.view_account_form" />
<field name="arch" type="xml">
<group name="options_group" position="inside">
<field name="account_type" position="before">
<field name="asset_profile_id" />
</group>
</field>
</field>
</record>

View File

@ -56,24 +56,28 @@
<field name="name" class="oe_inline" />
</h1>
</div>
<group col="4">
<field name="code" />
<field
name="company_id"
widget="selection"
groups="base.group_multi_company"
/>
<field
name="company_currency_id"
groups="base.group_multi_currency"
invisible="1"
/>
<field name="move_line_check" invisible="1" />
<newline />
<field name="depreciation_base" />
<field name="value_depreciated" />
<field name="value_residual" />
<field name="active" invisible="1" />
<group>
<group id="header_left_group">
<field name="company_id" invisible="1" />
<field name="code" />
<field
name="company_id"
widget="selection"
groups="base.group_multi_company"
/>
<field
name="company_currency_id"
groups="base.group_multi_currency"
invisible="1"
/>
<field name="move_line_check" invisible="1" />
</group>
<group id="header_right_group">
<field name="depreciation_base" />
<field name="value_depreciated" />
<field name="value_residual" />
<field name="active" invisible="1" />
</group>
</group>
<notebook colspan="4">
<page string="General">
@ -96,19 +100,19 @@
<field name="date_remove" />
</group>
</group>
<group col="4" string="Other Information">
<field name="profile_id" />
<field name="group_ids" widget="many2many_tags" />
<field name="partner_id" />
<field
name="account_analytic_id"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_tag_ids"
groups="analytic.group_analytic_tags"
widget="many2many_tags"
/>
<group string="Other Information">
<group>
<field name="profile_id" />
<field name="group_ids" widget="many2many_tags" />
</group>
<group>
<field name="partner_id" />
<field
name="analytic_distribution"
groups="analytic.group_analytic_accounting"
widget="analytic_distribution"
/>
</group>
</group>
<group>
<group string="Depreciation Dates">
@ -246,11 +250,6 @@
<field name="journal_id" optional="show" />
<field name="account_id" />
<field name="partner_id" optional="show" />
<field
name="analytic_account_id"
groups="analytic.group_analytic_accounting"
optional="show"
/>
<field name="ref" />
<field name="name" optional="hide" />
<field name="debit" sum="1" />
@ -287,7 +286,6 @@
<field name="date_start" optional="show" />
<field name="date_remove" optional="show" />
<field name="profile_id" optional="show" />
<field name="account_analytic_id" optional="hide" />
<field name="method" optional="hide" />
<field name="prorata" optional="hide" />
<field name="group_ids" widget="many2many_tags" optional="hide" />
@ -362,12 +360,6 @@
domain=""
context="{'group_by': 'state'}"
/>
<filter
string="Analytic account"
name="account_analytic_groupby"
domain=""
context="{'group_by': 'account_analytic_id'}"
/>
<filter
string="Computation Method"
name="method_groupby"

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- pylint:disable=duplicate-xml-fields -->
<odoo>
<record id="account_asset_group_view_form" model="ir.ui.view">
<field name="name">account.asset.group.form</field>
@ -7,6 +8,7 @@
<form string="Asset Group">
<group>
<group>
<field name="company_id" invisible="1" />
<field name="name" />
<field name="code" />
<field name="parent_id" />
@ -25,10 +27,15 @@
<field name="model">account.asset.group</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="company_id" invisible="1" />
<field name="name" />
<field name="code" optional="show" />
<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>
</field>
</record>

View File

@ -12,72 +12,71 @@
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
<field name="name" />
</h1>
</div>
<group>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
<field name="name" />
</h1>
</div>
<group>
<field name="group_ids" widget="many2many_tags" />
<field name="asset_product_item" />
<field name="active" invisible="1" />
<field
<group>
<field name="company_id" invisible="1" />
<field name="group_ids" widget="many2many_tags" />
<field name="asset_product_item" />
<field name="active" invisible="1" />
<field
name="company_id"
widget="selection"
groups="base.group_multi_company"
/>
</group>
<group>
<field name="journal_id" />
<field name="account_asset_id" />
<field name="account_depreciation_id" />
<field name="account_expense_depreciation_id" />
<field name="account_plus_value_id" />
<field name="account_min_value_id" />
<field name="account_residual_value_id" />
<field name="allow_reversal" />
</group>
<group string="Depreciation Dates">
<field name="method_time" />
<field
</group>
<group>
<field name="journal_id" />
<field name="account_asset_id" />
<field name="account_depreciation_id" />
<field name="account_expense_depreciation_id" />
<field name="account_plus_value_id" />
<field name="account_min_value_id" />
<field name="account_residual_value_id" />
<field name="allow_reversal" />
</group>
<group string="Depreciation Dates">
<field name="method_time" />
<field
name="method_number"
attrs="{'invisible': [('method_time', 'not in', ['number', 'year'])], 'required': [('method_time', 'in', ['number', 'year'])]}"
/>
<field name="method_period" />
<field name="days_calc" />
<field
<field name="method_period" />
<field name="days_calc" />
<field
name="use_leap_years"
attrs="{'invisible': [('days_calc', '=', True)]}"
/>
</group>
<group string="Depreciation Method">
<field name="method" />
<field
</group>
<group string="Depreciation Method">
<field name="method" />
<field
name="method_progress_factor"
attrs="{'invisible': [('method', 'in', ['linear', 'linear-limit'])], 'required': [('method', 'in', ['degressive', 'degr-linear', 'degr-limit'])]}"
/>
<field
<field
name="prorata"
attrs="{'readonly':[('method_time','!=','year')]}"
/>
<field name="open_asset" />
</group>
<group
<field name="open_asset" />
</group>
<group
groups="analytic.group_analytic_accounting"
string="Analytic Information"
>
<field name="account_analytic_id" />
<field
name="analytic_tag_ids"
widget="many2many_tags"
groups="analytic.group_analytic_tags"
<field
name="analytic_distribution"
widget="analytic_distribution"
/>
</group>
</group>
</group>
<separator string="Notes" />
<field name="note" />
<separator string="Notes" />
<field name="note" />
</sheet>
</form>
</field>
@ -96,7 +95,6 @@
<field name="account_expense_depreciation_id" optional="hide" />
<field name="account_plus_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="prorata" optional="hide" />
<field
@ -121,11 +119,6 @@
domain="[('active', '=', False)]"
/>
<group name="groupby">
<filter
name="account_analytic_groupby"
string="account_analytic_id"
context="{'group_by': 'account_analytic_id'}"
/>
<filter
name="method_groupby"
string="Computation Method"

View File

@ -4,7 +4,6 @@
<field name="name">account.move.form.account.asset.management</field>
<field name="model">account.move</field>
<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">
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
<button
@ -13,6 +12,7 @@
class="oe_stat_button"
icon="fa-cube"
attrs="{'invisible': [('asset_count', '=', 0)]}"
groups="account.group_account_invoice"
>
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
@ -30,11 +30,12 @@
name="asset_profile_id"
attrs="{'column_invisible': [('parent.move_type', 'not in', ('in_invoice', 'in_refund'))]}"
optional="show"
groups="account.group_account_invoice"
/>
<field
name="asset_id"
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"
/>
</xpath>
@ -46,10 +47,11 @@
name="asset_profile_id"
domain="[('company_id','=', parent.company_id)]"
optional="hide"
groups="account.group_account_invoice"
/>
<field
name="asset_id"
groups="account.group_account_manager"
groups="account.group_account_manager,account.group_account_invoice"
optional="show"
/>
</xpath>

View File

@ -5,7 +5,7 @@
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_form" />
<field name="arch" type="xml">
<field name="statement_id" position="after">
<field name="statement_line_id" position="after">
<field
name="asset_profile_id"
domain="[('company_id','=', parent.company_id)]"

View File

@ -36,7 +36,6 @@ class AccountAssetRemove(models.TransientModel):
)
force_date = fields.Date(string="Force accounting date")
sale_value = fields.Monetary(
string="Sale Value",
default=lambda self: self._default_sale_value(),
currency_field="company_currency_id",
)
@ -341,8 +340,7 @@ class AccountAssetRemove(models.TransientModel):
move_line_vals = {
"name": asset.name,
"account_id": self.account_residual_value_id.id,
"analytic_account_id": asset.account_analytic_id.id,
"analytic_tag_ids": [(4, tag.id) for tag in asset.analytic_tag_ids],
"analytic_distribution": asset.analytic_distribution,
"debit": residual_value,
"credit": 0.0,
"partner_id": partner_id,
@ -355,10 +353,7 @@ class AccountAssetRemove(models.TransientModel):
move_line_vals = {
"name": asset.name,
"account_id": self.account_sale_id.id,
"analytic_account_id": asset.account_analytic_id.id,
"analytic_tag_ids": [
(4, tag.id) for tag in asset.analytic_tag_ids
],
"analytic_distribution": asset.analytic_distribution,
"debit": sale_value,
"credit": 0.0,
"partner_id": partner_id,
@ -375,10 +370,9 @@ class AccountAssetRemove(models.TransientModel):
move_line_vals = {
"name": asset.name,
"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,
"credit": balance_comp > 0 and balance or 0.0,
"analytic_distribution": asset.analytic_distribution,
"partner_id": partner_id,
"asset_id": asset.id,
}

View File

@ -5,30 +5,35 @@
<field name="model">account.asset.remove</field>
<field name="arch" type="xml">
<form string="Remove Asset">
<group colspan="4" col="4">
<field name="company_id" groups="base.group_multi_company" />
<field name="date_remove" />
<field name="force_date" />
<field name="sale_value" />
<field
name="account_sale_id"
attrs="{'invisible': [('sale_value', '=', 0.0)], 'required': [('sale_value', '>', 0.0)]}"
/>
<newline />
<field name="posting_regime" />
<newline />
<field
name="account_plus_value_id"
attrs="{'invisible': [('posting_regime', '=', 'residual_value')], 'required': [('posting_regime', '!=', 'residual_value')]}"
/>
<field
name="account_min_value_id"
attrs="{'invisible': [('posting_regime', '=', 'residual_value')], 'required': [('posting_regime', '!=', 'residual_value')]}"
/>
<field
name="account_residual_value_id"
attrs="{'invisible': [('posting_regime', '!=', 'residual_value')], 'required': [('posting_regime', '=', 'residual_value')]}"
/>
<group>
<group>
<field name="company_id" invisible="1" />
<field name="company_id" groups="base.group_multi_company" />
<field name="date_remove" />
<field name="force_date" />
<field name="sale_value" />
<field
name="account_sale_id"
attrs="{'invisible': [('sale_value', '=', 0.0)], 'required': [('sale_value', '>', 0.0)]}"
/>
</group>
<group>
<field
name="account_plus_value_id"
attrs="{'invisible': [('posting_regime', '=', 'residual_value')], 'required': [('posting_regime', '!=', 'residual_value')]}"
/>
<field
name="account_min_value_id"
attrs="{'invisible': [('posting_regime', '=', 'residual_value')], 'required': [('posting_regime', '!=', 'residual_value')]}"
/>
<field
name="account_residual_value_id"
attrs="{'invisible': [('posting_regime', '!=', 'residual_value')], 'required': [('posting_regime', '=', 'residual_value')]}"
/>
</group>
<group>
<field name="posting_regime" />
</group>
<separator string="Notes" colspan="4" />
<field name="note" nolabel="1" colspan="4" />
</group>