Skip to content

Commit

Permalink
[REF] account_asset_management: the name of the company_currency_id f…
Browse files Browse the repository at this point in the history
…ield is changed to currency_id and currency_field is not required.
  • Loading branch information
RodrigoBM committed Dec 24, 2022
1 parent 84f2fa4 commit 73b3200
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
9 changes: 2 additions & 7 deletions account_asset_management/models/account_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,30 @@ class AccountAsset(models.Model):
purchase_value = fields.Monetary(
required=True,
states=READONLY_STATES,
currency_field="company_currency_id",
help="This amount represent the initial value of the asset."
"\nThe Depreciation Base is calculated as follows:"
"\nPurchase Value - Salvage Value.",
)
salvage_value = fields.Monetary(
states=READONLY_STATES,
currency_field="company_currency_id",
help="The estimated value that an asset will realize upon "
"its sale at the end of its useful life.\n"
"This value is used to determine the depreciation amounts.",
)
depreciation_base = fields.Monetary(
compute="_compute_depreciation_base",
store=True,
currency_field="company_currency_id",
help="This amount represent the depreciation base "
"of the asset (Purchase Value - Salvage Value).",
)
value_residual = fields.Monetary(
compute="_compute_depreciation",
string="Residual Value",
currency_field="company_currency_id",
store=True,
)
value_depreciated = fields.Monetary(
compute="_compute_depreciation",
string="Depreciated Value",
currency_field="company_currency_id",
store=True,
)
note = fields.Text()
Expand Down Expand Up @@ -262,7 +257,7 @@ class AccountAsset(models.Model):
readonly=True,
default=lambda self: self._default_company_id(),
)
company_currency_id = fields.Many2one(
currency_id = fields.Many2one(
comodel_name="res.currency",
related="company_id.currency_id",
string="Company Currency",
Expand Down Expand Up @@ -514,7 +509,7 @@ def name_get(self):

def validate(self):
for asset in self:
if asset.company_currency_id.is_zero(asset.value_residual):
if asset.currency_id.is_zero(asset.value_residual):
asset.state = "close"
else:
asset.state = "open"
Expand Down
9 changes: 3 additions & 6 deletions account_asset_management/models/account_asset_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,17 @@ class AccountAssetLine(models.Model):
depreciation_base = fields.Monetary(
related="asset_id.depreciation_base",
string="Depreciation Base",
currency_field="company_currency_id",
)
amount = fields.Monetary(required=True, currency_field="company_currency_id")
amount = fields.Monetary(required=True)
remaining_value = fields.Monetary(
compute="_compute_values",
string="Next Period Depreciation",
store=True,
currency_field="company_currency_id",
)
depreciated_value = fields.Monetary(
compute="_compute_values",
string="Amount Already Depreciated",
store=True,
currency_field="company_currency_id",
)
line_date = fields.Date(string="Date", required=True)
line_days = fields.Integer(string="Days", readonly=True)
Expand Down Expand Up @@ -74,7 +71,7 @@ class AccountAssetLine(models.Model):
"for which Odoo has not generated accounting entries.",
)
company_id = fields.Many2one(related="asset_id.company_id", store=True)
company_currency_id = fields.Many2one(
currency_id = fields.Many2one(
related="asset_id.company_id.currency_id", store=True, string="Company Currency"
)

Expand Down Expand Up @@ -281,7 +278,7 @@ def create_move(self):
asset_ids.add(asset.id)
# we re-evaluate the assets to determine if we can close them
for asset in self.env["account.asset"].browse(list(asset_ids)):
if asset.company_currency_id.is_zero(asset.value_residual):
if asset.currency_id.is_zero(asset.value_residual):
asset.state = "close"
return created_move_ids

Expand Down
11 changes: 4 additions & 7 deletions account_asset_management/views/account_asset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
groups="base.group_multi_company"
/>
<field
name="company_currency_id"
name="currency_id"
groups="base.group_multi_currency"
invisible="1"
/>
Expand Down Expand Up @@ -174,7 +174,7 @@
<field name="init_entry" string="Init" />
<field name="move_check" />
<field name="parent_state" invisible="1" />
<field name="company_currency_id" invisible="1" />
<field name="currency_id" invisible="1" />
<button
name="create_move"
icon="fa-cog"
Expand Down Expand Up @@ -207,10 +207,7 @@
name="depreciation_base"
invisible="1"
/>
<field
name="company_currency_id"
invisible="1"
/>
<field name="currency_id" invisible="1" />
<field name="type" />
<field name="name" />
<field
Expand Down Expand Up @@ -302,7 +299,7 @@
decoration-info="state == 'draft'"
decoration-muted="state == 'close'"
/>
<field name="company_currency_id" invisible="1" />
<field name="currency_id" invisible="1" />
</tree>
</field>
</record>
Expand Down
5 changes: 2 additions & 3 deletions account_asset_management/wizard/account_asset_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AccountAssetRemove(models.TransientModel):
required=True,
default=lambda self: self._default_company_id(),
)
company_currency_id = fields.Many2one(
currency_id = fields.Many2one(
related="company_id.currency_id", string="Company Currency"
)
date_remove = fields.Date(
Expand All @@ -37,7 +37,6 @@ class AccountAssetRemove(models.TransientModel):
force_date = fields.Date(string="Force accounting date")
sale_value = fields.Monetary(
default=lambda self: self._default_sale_value(),
currency_field="company_currency_id",
)
account_sale_id = fields.Many2one(
comodel_name="account.account",
Expand Down Expand Up @@ -107,7 +106,7 @@ def _get_sale(self):
)
for line in inv_lines:
inv = line.move_id
comp_curr = inv.company_currency_id
comp_curr = inv.currency_id
inv_curr = inv.currency_id
if line.move_id.payment_state == "paid" or line.parent_state == "draft":
account_sale_id = line.account_id.id
Expand Down

0 comments on commit 73b3200

Please sign in to comment.