Skip to content

Commit

Permalink
[MIG] assets_management filtering only compulsory changes from OCA#2704
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Jan 6, 2023
1 parent c11f965 commit 94965a5
Show file tree
Hide file tree
Showing 41 changed files with 1,968 additions and 3,164 deletions.
5 changes: 1 addition & 4 deletions assets_management/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

{
"name": "ITA - Gestione Cespiti",
"version": "12.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Localization/Italy",
"summary": "Gestione Cespiti",
"author": "Openforce, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy" "/tree/12.0/assets_management",
"license": "AGPL-3",
"depends": [
"account",
"account_cancel",
"account_financial_report",
"account_fiscal_year",
"mail",
Expand All @@ -30,7 +29,6 @@
"report/reports.xml",
"views/action_client.xml",
"views/asset_menuitems.xml",
"views/account_invoice.xml",
"views/account_move.xml",
"views/asset.xml",
"views/asset_accounting_info.xml",
Expand All @@ -41,7 +39,6 @@
"views/asset_depreciation_mode.xml",
"views/asset_depreciation_type.xml",
"views/asset_tag.xml",
"wizard/account_invoice_manage_asset_view.xml",
"wizard/account_move_manage_asset_view.xml",
"wizard/asset_generate_depreciation_view.xml",
"wizard/asset_journal_report_view.xml",
Expand Down
2 changes: 1 addition & 1 deletion assets_management/data/asset_data.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="0">
<odoo noupdate="1">

<!-- Natura ammortamento -->
<record id="ad_type_civilistico" model="asset.depreciation.type">
Expand Down
1,476 changes: 624 additions & 852 deletions assets_management/i18n/it.po

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions assets_management/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from . import account_account
from . import account_fiscal_year
from . import account_invoice
from . import account_invoice_line
from . import account_journal
from . import account_move
from . import account_move_line
Expand Down
3 changes: 1 addition & 2 deletions assets_management/models/account_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
# Copyright 2019 Openforce Srls Unipersonale (www.openforce.it)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, models
from odoo import _, models
from odoo.exceptions import UserError


class AccountAccount(models.Model):
_inherit = "account.account"

@api.multi
def unlink(self):
if (
self.env["asset.category"]
Expand Down
128 changes: 0 additions & 128 deletions assets_management/models/account_invoice.py

This file was deleted.

92 changes: 0 additions & 92 deletions assets_management/models/account_invoice_line.py

This file was deleted.

3 changes: 1 addition & 2 deletions assets_management/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
# Copyright 2019 Openforce Srls Unipersonale (www.openforce.it)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, models
from odoo import _, models
from odoo.exceptions import UserError


class AccountJournal(models.Model):
_inherit = "account.journal"

@api.multi
def unlink(self):
if (
self.env["asset.category"]
Expand Down
16 changes: 7 additions & 9 deletions assets_management/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def check_company(self):
).format(move.name_get()[0][-1])
)

@api.multi
def button_cancel(self):
res = super().button_cancel()
if self:
Expand All @@ -55,7 +54,6 @@ def button_cancel(self):
dep_lines.filtered(lambda l: not l.asset_accounting_info_ids).unlink()
return res

@api.multi
@api.depends(
"asset_accounting_info_ids",
"asset_accounting_info_ids.asset_id",
Expand All @@ -75,7 +73,6 @@ def _compute_asset_data(self):
}
)

@api.multi
def _compute_hide_link_asset_button(self):
valid_account_ids = self.get_valid_accounts()
if not valid_account_ids:
Expand All @@ -85,17 +82,18 @@ def _compute_hide_link_asset_button(self):
move.hide_link_asset_button = (
not any(
[
l.account_id.id in valid_account_ids.ids
for l in move.line_ids
line.account_id.id in valid_account_ids.ids
for line in move.invoice_line_ids
]
)
or move.state != "posted"
)

@api.multi
def open_wizard_manage_asset(self):
self.ensure_one()
lines = self.line_ids.filtered(lambda l: not l.asset_accounting_info_ids)
# do not use invoice_line_ids as it will ignore possible extra lines for not
# deductible VAT
lines = self.line_ids.filtered(lambda line: not line.asset_accounting_info_ids)
if not lines:
raise ValidationError(_("Every line is already linked to an asset."))

Expand All @@ -105,10 +103,10 @@ def open_wizard_manage_asset(self):
ctx.update(
{
"default_company_id": self.company_id.id,
"default_dismiss_date": self.date or fields.Date.today(),
"default_dismiss_date": self.invoice_date or self.invoice_date_due,
"default_move_ids": [(6, 0, self.ids)],
"default_move_line_ids": [(6, 0, lines.ids)],
"default_purchase_date": self.date or fields.Date.today(),
"default_purchase_date": self.invoice_date or self.invoice_date_due,
"move_ids": self.ids,
}
)
Expand Down
9 changes: 5 additions & 4 deletions assets_management/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def check_company(self):
).format(move_line.name_get()[0][-1])
)

@api.multi
@api.depends(
"asset_accounting_info_ids",
"asset_accounting_info_ids.asset_id",
Expand All @@ -59,10 +58,12 @@ def _compute_asset_data(self):
def get_asset_purchase_amount(self, currency=None):
purchase_amount = 0
for line in self:
purchase_amount += line.currency_id.compute(
line.debit - line.credit, currency
purchase_amount += line.currency_id._convert(
line.debit - line.credit,
currency,
line.company_id,
line.date,
)

return purchase_amount

def get_linked_aa_info_records(self):
Expand Down
Loading

0 comments on commit 94965a5

Please sign in to comment.