Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] assets_management get in-out values and minor fixes #3350

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets_management/models/asset_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def copy(self, default=None):
def unlink(self):
if self.env["asset.asset"].sudo().search([("category_id", "in", self.ids)]):
raise UserError(
_("Cannot delete categories while they're still linked" " to an asset.")
_("Cannot delete categories while they're still linked to an asset.")
)
return super().unlink()

Expand Down
41 changes: 34 additions & 7 deletions assets_management/models/asset_depreciation_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,27 @@

def get_historical_account_move_line_vals(self):
raise NotImplementedError(
_("Cannot create account move lines for lines of type" " `Historical`")
_("Cannot create account move lines for lines of type `Historical`")
)

def get_in_account_move_line_vals(self):
raise NotImplementedError(
_("Cannot create account move lines for lines of type `In`")
)
self.ensure_one()
credit_line_vals = {

Check warning on line 445 in assets_management/models/asset_depreciation_line.py

View check run for this annotation

Codecov / codecov/patch

assets_management/models/asset_depreciation_line.py#L444-L445

Added lines #L444 - L445 were not covered by tests
"account_id": self.asset_id.category_id.gain_account_id.id,
"credit": self.amount,
"debit": 0.0,
"currency_id": self.currency_id.id,
"name": " - ".join((self.asset_id.make_name(), self.name)),
}

debit_line_vals = {

Check warning on line 453 in assets_management/models/asset_depreciation_line.py

View check run for this annotation

Codecov / codecov/patch

assets_management/models/asset_depreciation_line.py#L453

Added line #L453 was not covered by tests
"account_id": self.asset_id.category_id.asset_account_id.id,
"credit": 0.0,
"debit": self.amount,
"currency_id": self.currency_id.id,
"name": " - ".join((self.asset_id.make_name(), self.name)),
}
return [credit_line_vals, debit_line_vals]

Check warning on line 460 in assets_management/models/asset_depreciation_line.py

View check run for this annotation

Codecov / codecov/patch

assets_management/models/asset_depreciation_line.py#L460

Added line #L460 was not covered by tests

def get_loss_account_move_line_vals(self):
self.ensure_one()
Expand All @@ -464,9 +478,22 @@
return [credit_line_vals, debit_line_vals]

def get_out_account_move_line_vals(self):
raise NotImplementedError(
_("Cannot create account move lines for lines of type `Out`")
)
self.ensure_one()
credit_line_vals = {

Check warning on line 482 in assets_management/models/asset_depreciation_line.py

View check run for this annotation

Codecov / codecov/patch

assets_management/models/asset_depreciation_line.py#L481-L482

Added lines #L481 - L482 were not covered by tests
"account_id": self.asset_id.category_id.asset_account_id.id,
"credit": self.amount,
"debit": 0.0,
"currency_id": self.currency_id.id,
"name": " - ".join((self.asset_id.make_name(), self.name)),
}
debit_line_vals = {

Check warning on line 489 in assets_management/models/asset_depreciation_line.py

View check run for this annotation

Codecov / codecov/patch

assets_management/models/asset_depreciation_line.py#L489

Added line #L489 was not covered by tests
"account_id": self.asset_id.category_id.loss_account_id.id,
"credit": 0.0,
"debit": self.amount,
"currency_id": self.currency_id.id,
"name": " - ".join((self.asset_id.make_name(), self.name)),
}
return [credit_line_vals, debit_line_vals]

Check warning on line 496 in assets_management/models/asset_depreciation_line.py

View check run for this annotation

Codecov / codecov/patch

assets_management/models/asset_depreciation_line.py#L496

Added line #L496 was not covered by tests

def needs_account_move(self):
self.ensure_one()
Expand Down
4 changes: 2 additions & 2 deletions assets_management/wizard/account_move_manage_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def check_pre_dismiss_asset(self):

if not self.move_line_ids and not self.dismiss_asset_without_sale:
raise ValidationError(
_("At least one move line is mandatory to dismiss" " an asset!")
_("At least one move line is mandatory to dismiss an asset!")
)

if (
Expand Down Expand Up @@ -316,7 +316,7 @@ def check_pre_update_asset(self):

if not self.move_line_ids:
raise ValidationError(
_("At least one move line is mandatory to update" " an asset!")
_("At least one move line is mandatory to update an asset!")
)

if not all(
Expand Down