2
0

[REF] account_asset_management: the name of the company_currency_id field is changed to currency_id and currency_field is not required.

This commit is contained in:
Rodrigo 2022-12-24 01:54:58 +01:00
parent f1371e5b33
commit 12a018de43
4 changed files with 11 additions and 23 deletions

View File

@ -61,14 +61,12 @@ class AccountAsset(models.Model):
purchase_value = fields.Monetary( purchase_value = fields.Monetary(
required=True, required=True,
states=READONLY_STATES, states=READONLY_STATES,
currency_field="company_currency_id",
help="This amount represent the initial value of the asset." help="This amount represent the initial value of the asset."
"\nThe Depreciation Base is calculated as follows:" "\nThe Depreciation Base is calculated as follows:"
"\nPurchase Value - Salvage Value.", "\nPurchase Value - Salvage Value.",
) )
salvage_value = fields.Monetary( salvage_value = fields.Monetary(
states=READONLY_STATES, states=READONLY_STATES,
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 "
"its sale at the end of its useful life.\n" "its sale at the end of its useful life.\n"
"This value is used to determine the depreciation amounts.", "This value is used to determine the depreciation amounts.",
@ -76,20 +74,17 @@ class AccountAsset(models.Model):
depreciation_base = fields.Monetary( depreciation_base = fields.Monetary(
compute="_compute_depreciation_base", compute="_compute_depreciation_base",
store=True, store=True,
currency_field="company_currency_id",
help="This amount represent the depreciation base " help="This amount represent the depreciation base "
"of the asset (Purchase Value - Salvage Value).", "of the asset (Purchase Value - Salvage Value).",
) )
value_residual = fields.Monetary( value_residual = fields.Monetary(
compute="_compute_depreciation", compute="_compute_depreciation",
string="Residual Value", string="Residual Value",
currency_field="company_currency_id",
store=True, store=True,
) )
value_depreciated = fields.Monetary( value_depreciated = fields.Monetary(
compute="_compute_depreciation", compute="_compute_depreciation",
string="Depreciated Value", string="Depreciated Value",
currency_field="company_currency_id",
store=True, store=True,
) )
note = fields.Text() note = fields.Text()
@ -262,7 +257,7 @@ class AccountAsset(models.Model):
readonly=True, readonly=True,
default=lambda self: self._default_company_id(), default=lambda self: self._default_company_id(),
) )
company_currency_id = fields.Many2one( currency_id = fields.Many2one(
comodel_name="res.currency", comodel_name="res.currency",
related="company_id.currency_id", related="company_id.currency_id",
string="Company Currency", string="Company Currency",
@ -514,7 +509,7 @@ class AccountAsset(models.Model):
def validate(self): def validate(self):
for asset in 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" asset.state = "close"
else: else:
asset.state = "open" asset.state = "open"

View File

@ -33,20 +33,17 @@ class AccountAssetLine(models.Model):
depreciation_base = fields.Monetary( depreciation_base = fields.Monetary(
related="asset_id.depreciation_base", related="asset_id.depreciation_base",
string="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( remaining_value = fields.Monetary(
compute="_compute_values", compute="_compute_values",
string="Next Period Depreciation", string="Next Period Depreciation",
store=True, store=True,
currency_field="company_currency_id",
) )
depreciated_value = fields.Monetary( depreciated_value = fields.Monetary(
compute="_compute_values", compute="_compute_values",
string="Amount Already Depreciated", string="Amount Already Depreciated",
store=True, store=True,
currency_field="company_currency_id",
) )
line_date = fields.Date(string="Date", required=True) line_date = fields.Date(string="Date", required=True)
line_days = fields.Integer(string="Days", readonly=True) line_days = fields.Integer(string="Days", readonly=True)
@ -74,7 +71,7 @@ class AccountAssetLine(models.Model):
"for which Odoo has not generated accounting entries.", "for which Odoo has not generated accounting entries.",
) )
company_id = fields.Many2one(related="asset_id.company_id", store=True) 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" related="asset_id.company_id.currency_id", store=True, string="Company Currency"
) )
@ -281,7 +278,7 @@ class AccountAssetLine(models.Model):
asset_ids.add(asset.id) asset_ids.add(asset.id)
# we re-evaluate the assets to determine if we can close them # we re-evaluate the assets to determine if we can close them
for asset in self.env["account.asset"].browse(list(asset_ids)): 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" asset.state = "close"
return created_move_ids return created_move_ids

View File

@ -66,7 +66,7 @@
groups="base.group_multi_company" groups="base.group_multi_company"
/> />
<field <field
name="company_currency_id" name="currency_id"
groups="base.group_multi_currency" groups="base.group_multi_currency"
invisible="1" invisible="1"
/> />
@ -174,7 +174,7 @@
<field name="init_entry" string="Init" /> <field name="init_entry" string="Init" />
<field name="move_check" /> <field name="move_check" />
<field name="parent_state" invisible="1" /> <field name="parent_state" invisible="1" />
<field name="company_currency_id" invisible="1" /> <field name="currency_id" invisible="1" />
<button <button
name="create_move" name="create_move"
icon="fa-cog" icon="fa-cog"
@ -207,10 +207,7 @@
name="depreciation_base" name="depreciation_base"
invisible="1" invisible="1"
/> />
<field <field name="currency_id" invisible="1" />
name="company_currency_id"
invisible="1"
/>
<field name="type" /> <field name="type" />
<field name="name" /> <field name="name" />
<field <field
@ -302,7 +299,7 @@
decoration-info="state == 'draft'" decoration-info="state == 'draft'"
decoration-muted="state == 'close'" decoration-muted="state == 'close'"
/> />
<field name="company_currency_id" invisible="1" /> <field name="currency_id" invisible="1" />
</tree> </tree>
</field> </field>
</record> </record>

View File

@ -24,7 +24,7 @@ class AccountAssetRemove(models.TransientModel):
required=True, required=True,
default=lambda self: self._default_company_id(), default=lambda self: self._default_company_id(),
) )
company_currency_id = fields.Many2one( currency_id = fields.Many2one(
related="company_id.currency_id", string="Company Currency" related="company_id.currency_id", string="Company Currency"
) )
date_remove = fields.Date( date_remove = fields.Date(
@ -37,7 +37,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(
default=lambda self: self._default_sale_value(), default=lambda self: self._default_sale_value(),
currency_field="company_currency_id",
) )
account_sale_id = fields.Many2one( account_sale_id = fields.Many2one(
comodel_name="account.account", comodel_name="account.account",
@ -107,7 +106,7 @@ class AccountAssetRemove(models.TransientModel):
) )
for line in inv_lines: for line in inv_lines:
inv = line.move_id inv = line.move_id
comp_curr = inv.company_currency_id comp_curr = inv.currency_id
inv_curr = inv.currency_id inv_curr = inv.currency_id
if line.move_id.payment_state == "paid" or line.parent_state == "draft": if line.move_id.payment_state == "paid" or line.parent_state == "draft":
account_sale_id = line.account_id.id account_sale_id = line.account_id.id