mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[MIG] account_asset_transfer: Migration to 16.0
This commit is contained in:
@@ -7,7 +7,7 @@ Asset Transfer from AUC to Asset
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:54bc585229303c2c59b323b6c4dd583945abda7880b25b67463697dbadc42dd5
|
||||
!! source digest: sha256:5fb144c4441c023dcd6f27dcd7be70952e7b51761699c1c4e0a08f50f8bc9c97
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
@@ -17,13 +17,13 @@ Asset Transfer from AUC to Asset
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/account-financial-tools/tree/15.0/account_asset_transfer
|
||||
:target: https://github.com/OCA/account-financial-tools/tree/16.0/account_asset_transfer
|
||||
:alt: OCA/account-financial-tools
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_asset_transfer
|
||||
:target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_asset_transfer
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=15.0
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@@ -68,7 +68,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_transfer%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_transfer%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -110,6 +110,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-kittiu|
|
||||
|
||||
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/account_asset_transfer>`_ project on GitHub.
|
||||
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_asset_transfer>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "Asset Transfer from AUC to Asset",
|
||||
"version": "15.0.1.0.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["account_asset_management"],
|
||||
"author": "Ecosoft, Odoo Community Association (OCA)",
|
||||
|
||||
@@ -367,9 +367,9 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:54bc585229303c2c59b323b6c4dd583945abda7880b25b67463697dbadc42dd5
|
||||
!! source digest: sha256:5fb144c4441c023dcd6f27dcd7be70952e7b51761699c1c4e0a08f50f8bc9c97
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_asset_transfer"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_asset_transfer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_asset_transfer"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_asset_transfer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module allow transferring assets under construction (AUC) to normal assets.</p>
|
||||
<p>AUC is Asset under construction where some assets are in construction phase and
|
||||
cost needs to be captured for the time being. Once asset is fully completed then
|
||||
@@ -414,7 +414,7 @@ cost would be transferred to final asset</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_transfer%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_asset_transfer%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -445,7 +445,7 @@ mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external image-reference" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_asset_transfer">OCA/account-financial-tools</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/16.0/account_asset_transfer">OCA/account-financial-tools</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -98,7 +98,7 @@ class TestAccountAssetTransfer(TestAssetManagement):
|
||||
assets += asset_auc
|
||||
self.assertFalse(list(set(assets.mapped("can_transfer")))[0])
|
||||
assets.validate()
|
||||
assets.invalidate_cache()
|
||||
assets.invalidate_model()
|
||||
# can_transfer = True after validate
|
||||
self.assertTrue(list(set(assets.mapped("can_transfer")))[0])
|
||||
self.assertEqual(list(set(assets.mapped("is_transfer"))), [False])
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# Copyright 2020 Ecosoft Co., Ltd. (http://ecosoft.co.th)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo import Command, _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import float_compare
|
||||
|
||||
|
||||
class AccountAssetTransfer(models.TransientModel):
|
||||
_name = "account.asset.transfer"
|
||||
_inherit = "analytic.mixin"
|
||||
_description = "Transfer Asset"
|
||||
_check_company_auto = True
|
||||
|
||||
@@ -60,14 +61,6 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
comodel_name="res.partner",
|
||||
string="Partner",
|
||||
)
|
||||
analytic_account_id = fields.Many2one(
|
||||
comodel_name="account.analytic.account",
|
||||
string="Analytic account",
|
||||
)
|
||||
analytic_tag_ids = fields.Many2many(
|
||||
comodel_name="account.analytic.tag",
|
||||
string="Analytic tags",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def default_get(self, field_list):
|
||||
@@ -79,20 +72,22 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
company.ensure_one()
|
||||
journals = assets.mapped("profile_id.transfer_journal_id")
|
||||
partners = assets.mapped("partner_id")
|
||||
analytics = assets.mapped("account_analytic_id")
|
||||
tags = assets[:1].analytic_tag_ids
|
||||
for asset in assets:
|
||||
if asset.analytic_tag_ids != tags:
|
||||
# When not all tags are the same, no default
|
||||
tags = self.env["account.analytic.tag"]
|
||||
break
|
||||
analytics = assets.mapped("analytic_distribution")
|
||||
# Combine analytic to dict
|
||||
analytic_dict = {}
|
||||
unique_elements = set()
|
||||
for analytic in analytics:
|
||||
if analytic is not False:
|
||||
for key, value in analytic.items():
|
||||
if key not in analytic_dict and key not in unique_elements:
|
||||
analytic_dict[key] = value
|
||||
unique_elements.add(key)
|
||||
# Assign values
|
||||
res["company_id"] = company.id
|
||||
res["partner_id"] = partners[0].id if len(partners) == 1 else False
|
||||
res["from_asset_ids"] = [(4, asset_id) for asset_id in assets.ids]
|
||||
res["transfer_journal_id"] = journals[:1].id
|
||||
res["analytic_account_id"] = analytics[0].id if len(analytics) == 1 else False
|
||||
res["analytic_tag_ids"] = [(4, tag_id) for tag_id in tags.ids]
|
||||
res["analytic_distribution"] = analytic_dict
|
||||
return res
|
||||
|
||||
@api.depends("from_asset_ids", "to_asset_ids")
|
||||
@@ -152,8 +147,7 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
return {
|
||||
"name": move_line.name,
|
||||
"account_id": move_line.account_id.id,
|
||||
"analytic_account_id": move_line.analytic_account_id.id or False,
|
||||
"analytic_tag_ids": [(4, tag.id) for tag in move_line.analytic_tag_ids],
|
||||
"analytic_distribution": move_line.analytic_distribution or {},
|
||||
"debit": move_line.credit,
|
||||
"credit": move_line.debit,
|
||||
"partner_id": move_line.partner_id.id,
|
||||
@@ -164,8 +158,7 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
return {
|
||||
"name": asset.name,
|
||||
"account_id": asset.profile_id.account_asset_id.id,
|
||||
"analytic_account_id": asset.account_analytic_id.id,
|
||||
"analytic_tag_ids": [(4, tag.id) for tag in asset.analytic_tag_ids],
|
||||
"analytic_distribution": asset.analytic_distribution or {},
|
||||
"debit": 0.0,
|
||||
"credit": asset.purchase_value or 0.0,
|
||||
"partner_id": asset.partner_id.id,
|
||||
@@ -176,8 +169,7 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
return {
|
||||
"name": to_asset.asset_name,
|
||||
"account_id": to_asset.asset_profile_id.account_asset_id.id,
|
||||
"analytic_account_id": to_asset.analytic_account_id.id,
|
||||
"analytic_tag_ids": [(4, tag.id) for tag in to_asset.analytic_tag_ids],
|
||||
"analytic_distribution": to_asset.analytic_distribution or {},
|
||||
"debit": to_asset.asset_value,
|
||||
"credit": 0.0,
|
||||
"partner_id": to_asset.partner_id.id,
|
||||
@@ -186,15 +178,14 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
}
|
||||
|
||||
def _get_transfer_data(self):
|
||||
move_lines = []
|
||||
# Create lines from assets
|
||||
move_lines += [
|
||||
(0, 0, self._get_move_line_from_asset(from_asset))
|
||||
move_lines = [
|
||||
Command.create(self._get_move_line_from_asset(from_asset))
|
||||
for from_asset in self.from_asset_ids
|
||||
]
|
||||
# Create lines for new assets
|
||||
move_lines += [
|
||||
(0, 0, self._get_move_line_to_asset(to_asset))
|
||||
Command.create(self._get_move_line_to_asset(to_asset))
|
||||
for to_asset in self.to_asset_ids
|
||||
]
|
||||
return move_lines
|
||||
@@ -212,6 +203,7 @@ class AccountAssetTransfer(models.TransientModel):
|
||||
|
||||
class AccountAssetTransferLine(models.TransientModel):
|
||||
_name = "account.asset.transfer.line"
|
||||
_inherit = "analytic.mixin"
|
||||
_description = "Transfer To Asset"
|
||||
|
||||
transfer_id = fields.Many2one(
|
||||
@@ -243,14 +235,6 @@ class AccountAssetTransferLine(models.TransientModel):
|
||||
comodel_name="res.partner",
|
||||
string="Partner",
|
||||
)
|
||||
analytic_account_id = fields.Many2one(
|
||||
comodel_name="account.analytic.account",
|
||||
string="Analytic account",
|
||||
)
|
||||
analytic_tag_ids = fields.Many2many(
|
||||
comodel_name="account.analytic.tag",
|
||||
string="Analytic tags",
|
||||
)
|
||||
|
||||
@api.depends("quantity", "price_unit")
|
||||
def _compute_asset_value(self):
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<group>
|
||||
<field name="date_transfer" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="company_id" invisible="1" />
|
||||
<field name="currency_id" invisible="1" />
|
||||
<field name="from_asset_value" />
|
||||
<field name="to_asset_value" />
|
||||
@@ -17,8 +18,7 @@
|
||||
<group>
|
||||
<field name="transfer_journal_id" />
|
||||
<field name="partner_id" invisible="1" />
|
||||
<field name="analytic_account_id" invisible="1" />
|
||||
<field name="analytic_tag_ids" invisible="1" />
|
||||
<field name="analytic_distribution" invisible="1" />
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
@@ -36,8 +36,7 @@
|
||||
context="{
|
||||
'default_asset_value': balance,
|
||||
'default_partner_id': partner_id,
|
||||
'default_analytic_account_id': analytic_account_id,
|
||||
'default_analytic_tag_ids': analytic_tag_ids,
|
||||
'default_analytic_distribution': analytic_distribution,
|
||||
}"
|
||||
>
|
||||
<tree editable="bottom">
|
||||
@@ -48,14 +47,9 @@
|
||||
<field name="asset_value" />
|
||||
<field name="partner_id" />
|
||||
<field
|
||||
name="analytic_account_id"
|
||||
name="analytic_distribution"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
/>
|
||||
<field
|
||||
name="analytic_tag_ids"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
widget="many2many_tags"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user