diff --git a/account_asset_management/__manifest__.py b/account_asset_management/__manifest__.py index c429a0a4..05473c3d 100644 --- a/account_asset_management/__manifest__.py +++ b/account_asset_management/__manifest__.py @@ -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"], diff --git a/account_asset_management/models/account_asset.py b/account_asset_management/models/account_asset.py index 5adfc5ed..d1e0b476 100644 --- a/account_asset_management/models/account_asset.py +++ b/account_asset_management/models/account_asset.py @@ -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) diff --git a/account_asset_management/models/account_asset_group.py b/account_asset_management/models/account_asset_group.py index 10ec693c..0263cd38 100644 --- a/account_asset_management/models/account_asset_group.py +++ b/account_asset_management/models/account_asset_group.py @@ -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", diff --git a/account_asset_management/models/account_asset_line.py b/account_asset_management/models/account_asset_line.py index 41a94d7c..1c1d971f 100644 --- a/account_asset_management/models/account_asset_line.py +++ b/account_asset_management/models/account_asset_line.py @@ -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, } diff --git a/account_asset_management/models/account_asset_profile.py b/account_asset_management/models/account_asset_profile.py index 1c9a0036..a6be523f 100644 --- a/account_asset_management/models/account_asset_profile.py +++ b/account_asset_management/models/account_asset_profile.py @@ -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"): diff --git a/account_asset_management/models/account_move.py b/account_asset_management/models/account_move.py index 43fdac32..52dc5c36 100644 --- a/account_asset_management/models/account_move.py +++ b/account_asset_management/models/account_move.py @@ -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() diff --git a/account_asset_management/report/account_asset_report_xls.py b/account_asset_management/report/account_asset_report_xls.py index 063e491d..64550cb9 100644 --- a/account_asset_management/report/account_asset_report_xls.py +++ b/account_asset_management/report/account_asset_report_xls.py @@ -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": { diff --git a/account_asset_management/tests/test_account_asset_management.py b/account_asset_management/tests/test_account_asset_management.py index c65f74fc..2a3a4405 100644 --- a/account_asset_management/tests/test_account_asset_management.py +++ b/account_asset_management/tests/test_account_asset_management.py @@ -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)]) diff --git a/account_asset_management/views/account_account.xml b/account_asset_management/views/account_account.xml index 8fabfc60..d4b3c1c2 100644 --- a/account_asset_management/views/account_account.xml +++ b/account_asset_management/views/account_account.xml @@ -5,9 +5,9 @@ account.account - + - + diff --git a/account_asset_management/views/account_asset.xml b/account_asset_management/views/account_asset.xml index b49e7a07..678e56f2 100644 --- a/account_asset_management/views/account_asset.xml +++ b/account_asset_management/views/account_asset.xml @@ -56,24 +56,28 @@ - - - - - - - - - - + + + + + + + + + + + + + + @@ -96,19 +100,19 @@ - - - - - - + + + + + + + + + @@ -246,11 +250,6 @@ - @@ -287,7 +286,6 @@ - @@ -362,12 +360,6 @@ domain="" context="{'group_by': 'state'}" /> - + account.asset.group.form @@ -7,6 +8,7 @@ + @@ -25,10 +27,15 @@ account.asset.group + - + diff --git a/account_asset_management/views/account_asset_profile.xml b/account_asset_management/views/account_asset_profile.xml index 0268f534..1f49d1fc 100644 --- a/account_asset_management/views/account_asset_profile.xml +++ b/account_asset_management/views/account_asset_profile.xml @@ -12,72 +12,71 @@ bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}" /> - - - - - - - + + + + + + - - - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + - - - - + + + - - - - + + - - + - - - + + @@ -96,7 +95,6 @@ - - account.move.form.account.asset.management account.move - @@ -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" /> @@ -46,10 +47,11 @@ name="asset_profile_id" domain="[('company_id','=', parent.company_id)]" optional="hide" + groups="account.group_account_invoice" /> diff --git a/account_asset_management/views/account_move_line.xml b/account_asset_management/views/account_move_line.xml index 73a2a169..fafedd65 100644 --- a/account_asset_management/views/account_move_line.xml +++ b/account_asset_management/views/account_move_line.xml @@ -5,7 +5,7 @@ account.move.line - + 0 and balance or 0.0, + "analytic_distribution": asset.analytic_distribution, "partner_id": partner_id, "asset_id": asset.id, } diff --git a/account_asset_management/wizard/account_asset_remove.xml b/account_asset_management/wizard/account_asset_remove.xml index 4c885a20..027e77b1 100644 --- a/account_asset_management/wizard/account_asset_remove.xml +++ b/account_asset_management/wizard/account_asset_remove.xml @@ -5,30 +5,35 @@ account.asset.remove - - - - - - - - - - - - + + + + + + + + + + + + + + + + +