[MIG] account_move_line_repair_info: Migration to 16.0

This commit is contained in:
ArnauCForgeFlow
2023-10-26 15:08:00 +02:00
parent 802219c0e9
commit 4ae9689db4
8 changed files with 69 additions and 101 deletions

View File

@@ -7,7 +7,7 @@ Account Move Line Repair Info
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:501799819b3b4d34a900a1035efbf8ba3a021300c180e1d9e4097cecdf9eabdf
!! source digest: sha256:44a807b48cf561e9c5eb22bd9e1308e78246ab34e9ca623cea3ae9d108f29e80
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Account Move Line Repair Info
: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/14.0/account_move_line_repair_info
:target: https://github.com/OCA/account-financial-tools/tree/16.0/account_move_line_repair_info
: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-14-0/account-financial-tools-14-0-account_move_line_repair_info
:target: https://translation.odoo-community.org/projects/account-financial-tools-16-0/account-financial-tools-16-0-account_move_line_repair_info
: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=14.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|
@@ -49,7 +49,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_move_line_repair_info%0Aversion:%2014.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_move_line_repair_info%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.
@@ -79,6 +79,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_move_line_repair_info>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/16.0/account_move_line_repair_info>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,7 +4,7 @@
{
"name": "Account Move Line Repair Info",
"summary": "Introduces the repair order to the journal items",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"author": "ForgeFlow S.L., " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Generic",
@@ -12,7 +12,6 @@
"account",
"repair",
"stock_account",
"stock_account_prepare_anglo_saxon_out_lines_hook",
],
"license": "AGPL-3",
"data": ["security/account_security.xml", "views/account_move_view.xml"],

View File

@@ -1,3 +1,3 @@
from . import account_move
from . import repair_order
from . import stock_move
from . import stock_valuation_layer

View File

@@ -8,40 +8,34 @@ class AccountMove(models.Model):
_inherit = "account.move"
def _prepare_interim_account_line_vals(self, line, move, debit_interim_account):
res = super()._prepare_interim_account_line_vals(
line, move, debit_interim_account
)
if len(line.repair_line_ids) == 1:
res.update(
{
"repair_order_id": line.repair_line_ids.repair_id.id,
}
)
if len(line.repair_fee_ids) == 1:
res.update(
{
"repair_order_id": line.repair_fee_ids.repair_id.id,
}
)
return res
def _prepare_expense_account_line_vals(self, line, move, debit_interim_account):
res = super()._prepare_expense_account_line_vals(
line, move, debit_interim_account
)
if len(line.repair_line_ids) == 1:
res.update(
{
"repair_order_id": line.repair_line_ids.repair_id.id,
}
)
if len(line.repair_fee_ids) == 1:
res.update(
{
"repair_order_id": line.repair_fee_ids.repair_id.id,
}
def _stock_account_prepare_anglo_saxon_out_lines_vals(self):
res = super()._stock_account_prepare_anglo_saxon_out_lines_vals()
for i, vals in enumerate(res):
if (
not vals.get("move_id", False)
or not vals.get("product_id", False)
or not vals.get("quantity", False)
):
continue
am = self.env["account.move"].browse(vals["move_id"])
repair_line = am.invoice_line_ids.filtered(
lambda il: il.product_id.id == vals["product_id"]
and il.quantity == vals["quantity"]
)
repair_order = repair_line.repair_fee_ids.mapped("repair_id")
if len(repair_order) == 1:
res[i].update(
{
"repair_order_id": repair_line.repair_fee_ids.repair_id.id,
}
)
repair_order = repair_line.repair_line_ids.mapped("repair_id")
if len(repair_order) == 1:
res[i].update(
{
"repair_order_id": repair_line.repair_line_ids.repair_id.id,
}
)
return res
@api.model_create_multi

View File

@@ -1,39 +0,0 @@
# Copyright 2022 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockMove(models.Model):
_inherit = "stock.move"
def _create_account_move_line(
self,
credit_account_id,
debit_account_id,
journal_id,
qty,
description,
svl_id,
cost,
):
am_model = self.env["account.move"]
res = super()._create_account_move_line(
credit_account_id,
debit_account_id,
journal_id,
qty,
description,
svl_id,
cost,
)
if self.repair_id:
current_move = am_model.search([("stock_move_id", "=", self.id)])
if current_move:
current_move.line_ids.write(
{
"repair_order_id": self.repair_id.id,
}
)
return res

View File

@@ -0,0 +1,22 @@
# Copyright 2022 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockValuationLayer(models.Model):
_inherit = "stock.valuation.layer"
def _validate_accounting_entries(self):
res = super()._validate_accounting_entries()
for svl in self:
if svl.stock_move_id.repair_id:
current_move = svl.account_move_id
if current_move:
current_move.line_ids.write(
{
"repair_order_id": svl.stock_move_id.repair_id.id,
}
)
return res

View File

@@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:501799819b3b4d34a900a1035efbf8ba3a021300c180e1d9e4097cecdf9eabdf
!! source digest: sha256:44a807b48cf561e9c5eb22bd9e1308e78246ab34e9ca623cea3ae9d108f29e80
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/14.0/account_move_line_repair_info"><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-14-0/account-financial-tools-14-0-account_move_line_repair_info"><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&amp;target_branch=14.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_move_line_repair_info"><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_move_line_repair_info"><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&amp;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 will add the repair order to journal items.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@@ -397,7 +397,7 @@ ul.auto-toc {
<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_move_line_repair_info%0Aversion:%2014.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_move_line_repair_info%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">
@@ -421,7 +421,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_move_line_repair_info">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_move_line_repair_info">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>

View File

@@ -27,7 +27,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test stock valuation",
"code": "tv",
"user_type_id": self.env["account.account.type"].search([], limit=1).id,
"account_type": "asset_cash",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -36,9 +36,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test Payable",
"code": "tpayable",
"user_type_id": self.env["account.account.type"]
.search([("type", "=", "payable")], limit=1)
.id,
"account_type": "liability_payable",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -47,9 +45,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test Receivable",
"code": "treceivable",
"user_type_id": self.env["account.account.type"]
.search([("type", "=", "receivable")], limit=1)
.id,
"account_type": "asset_receivable",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -59,7 +55,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test stock input",
"code": "tsti",
"user_type_id": self.env["account.account.type"].search([], limit=1).id,
"account_type": "income",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -68,7 +64,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test stock output",
"code": "tout",
"user_type_id": self.env["account.account.type"].search([], limit=1).id,
"account_type": "equity",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -77,9 +73,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test stock income",
"code": "tincome",
"user_type_id": self.env["account.account.type"]
.search([("internal_group", "=", "income")], limit=1)
.id,
"account_type": "income",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -88,9 +82,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
{
"name": "Test stock outcome",
"code": "texpense",
"user_type_id": self.env["account.account.type"]
.search([("internal_group", "=", "expense")], limit=1)
.id,
"account_type": "expense",
"reconcile": True,
"company_id": self.env.ref("base.main_company").id,
}
@@ -375,7 +367,7 @@ class TestAccountMoveLineRepairInfo(TransactionCase):
"active_model": "repair.order",
"active_ids": repairs.ids,
}
res = make_invoice.with_context(context).make_invoices()
res = make_invoice.with_context(context=context).make_invoices()
invoices = res.get("domain", []) and self.am_model.browse(
res.get("domain", [])[0][2]
)