From 98fdd915941f8e8101aeb5746af7b1342d73d06f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A0=20Gil=20Sorribes?=
Date: Fri, 27 Dec 2019 11:34:04 +0100
Subject: [PATCH] [MIG] account_move_line_manufacture_info: Migration to 13.0
---
account_move_line_manufacture_info/README.rst | 14 ++---
.../__manifest__.py | 6 +-
.../models/account_move_line.py | 2 +-
.../models/stock_move.py | 7 ++-
.../readme/CONTRIBUTORS.rst | 2 +-
.../static/description/index.html | 10 ++--
...test_account_move_line_manufacture_info.py | 59 +++++++++----------
.../views/account_move_line_view.xml | 2 -
8 files changed, 48 insertions(+), 54 deletions(-)
diff --git a/account_move_line_manufacture_info/README.rst b/account_move_line_manufacture_info/README.rst
index 981ea45eb..d219ed493 100644
--- a/account_move_line_manufacture_info/README.rst
+++ b/account_move_line_manufacture_info/README.rst
@@ -14,13 +14,13 @@ Account Move Line Manufacture Information
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
- :target: https://github.com/OCA/manufacture/tree/12.0/account_move_line_manufacture_info
+ :target: https://github.com/OCA/manufacture/tree/13.0/account_move_line_manufacture_info
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-account_move_line_manufacture_info
+ :target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-account_move_line_manufacture_info
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/129/12.0
+ :target: https://runbot.odoo-community.org/runbot/129/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -47,7 +47,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -57,12 +57,12 @@ Credits
Authors
~~~~~~~
-* Eficent
+* ForgeFlow
Contributors
~~~~~~~~~~~~
-* Adria Gil
+* Adria Gil
Maintainers
~~~~~~~~~~~
@@ -77,6 +77,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/manufacture `_ project on GitHub.
+This module is part of the `OCA/manufacture `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/account_move_line_manufacture_info/__manifest__.py b/account_move_line_manufacture_info/__manifest__.py
index b5babd39f..70390c92e 100644
--- a/account_move_line_manufacture_info/__manifest__.py
+++ b/account_move_line_manufacture_info/__manifest__.py
@@ -1,10 +1,10 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Move Line Manufacture Information",
- "version": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"depends": ["stock_account", "mrp"],
- "author": "Eficent," "Odoo Community Association (OCA)",
+ "author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture",
"category": "Manufacture Management",
"installable": True,
diff --git a/account_move_line_manufacture_info/models/account_move_line.py b/account_move_line_manufacture_info/models/account_move_line.py
index 0a71e2b8d..4bad4a958 100644
--- a/account_move_line_manufacture_info/models/account_move_line.py
+++ b/account_move_line_manufacture_info/models/account_move_line.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
diff --git a/account_move_line_manufacture_info/models/stock_move.py b/account_move_line_manufacture_info/models/stock_move.py
index d11ce550c..1267fb168 100644
--- a/account_move_line_manufacture_info/models/stock_move.py
+++ b/account_move_line_manufacture_info/models/stock_move.py
@@ -1,4 +1,4 @@
-# © 2019 Eficent Business and IT Consulting Services S.L.
+# © 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
@@ -9,16 +9,17 @@ class StockMove(models.Model):
@api.model
def _prepare_account_move_line(
- self, qty, cost, credit_account_id, debit_account_id
+ self, qty, cost, credit_account_id, debit_account_id, description
):
res = super(StockMove, self)._prepare_account_move_line(
- qty, cost, credit_account_id, debit_account_id
+ qty, cost, credit_account_id, debit_account_id, description
)
for line in res:
if self.production_id:
line[2]["manufacture_order_id"] = self.production_id.id
elif self.raw_material_production_id:
line[2]["manufacture_order_id"] = self.raw_material_production_id.id
+ line[2]["name"] = self.raw_material_production_id.name
elif self.unbuild_id:
line[2]["unbuild_order_id"] = self.unbuild_id.id
elif self.consume_unbuild_id:
diff --git a/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst b/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst
index dcd1839c8..be192c531 100644
--- a/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst
+++ b/account_move_line_manufacture_info/readme/CONTRIBUTORS.rst
@@ -1 +1 @@
-* Adria Gil
+* Adria Gil
diff --git a/account_move_line_manufacture_info/static/description/index.html b/account_move_line_manufacture_info/static/description/index.html
index efc6485c3..2fb17d762 100644
--- a/account_move_line_manufacture_info/static/description/index.html
+++ b/account_move_line_manufacture_info/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module adds the manufacture information to any account move lines generated by a
manufacture operation such as a manufacturing order or an unbuild order.
Table of contents
@@ -397,7 +397,7 @@ move lines that are related to the UO.
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -405,13 +405,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -421,7 +421,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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/manufacture project on GitHub.
+
This module is part of the OCA/manufacture project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py b/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py
index e542dfdc4..960bca9f7 100644
--- a/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py
+++ b/account_move_line_manufacture_info/tests/test_account_move_line_manufacture_info.py
@@ -1,4 +1,4 @@
-# 2018 Eficent Business and IT Consulting Services S.L.
+# 2018 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import odoo.tests.common as common
@@ -14,11 +14,14 @@ class TestAccountMoveLineManufactureInfo(common.SavepointCase):
cls.account_move_line_obj = cls.env["account.move.line"]
cls.bom_obj = cls.env["mrp.bom"]
cls.bom_line_obj = cls.env["mrp.bom.line"]
- cls.location_production = cls.env.ref("stock.location_production")
cls.production_obj = cls.env["mrp.production"]
cls.produce_wiz = cls.env["mrp.product.produce"]
cls.unbuild_obj = cls.env["mrp.unbuild"]
+ cls.location_production = cls.env["stock.location"].search(
+ [("usage", "=", "production"), ("company_id", "=", cls.env.company.id)]
+ )
+
# Create accounts for WIP
cls.account_wip = cls.env["account.account"].create(
{
@@ -124,24 +127,25 @@ class TestAccountMoveLineManufactureInfo(common.SavepointCase):
wiz = Form(
self.produce_wiz.with_context({"active_id": mo.id, "active_ids": [mo.id]})
)
- wiz.product_qty = qty or mo.product_qty
+ wiz.qty_producing = qty or mo.product_qty
produce_wizard = wiz.save()
produce_wizard.do_produce()
return True
+ def _generate_mo(self, product_id, bom_id, qty=5.0):
+ mo_form = Form(self.production_obj)
+ mo_form.product_id = product_id
+ mo_form.bom_id = bom_id
+ mo_form.product_qty = qty
+ mo = mo_form.save()
+ mo.action_confirm()
+ return mo
+
def test_01_manufacture_order(self):
"""Create Manufacture Order and check account move lines created"""
self.product_top.write({"standard_price": 445.0})
- mo = self.production_obj.create(
- {
- "name": "MO-01",
- "product_id": self.product_top.id,
- "product_uom_id": self.product_top.uom_id.id,
- "product_qty": 5.0,
- "bom_id": self.bom_top.id,
- }
- )
- mo.action_assign()
+ mo = self._generate_mo(self.product_top, self.bom_top)
+
self._produce(mo, 5.0)
mo.button_mark_done()
account_move_lines = self.account_move_line_obj.search(
@@ -152,27 +156,18 @@ class TestAccountMoveLineManufactureInfo(common.SavepointCase):
def test_02_ubuild_order(self):
"""Create Unbuild Order and check account move lines created"""
self.product_top.write({"standard_price": 445.0})
- mo = self.production_obj.create(
- {
- "name": "MO-01",
- "product_id": self.product_top.id,
- "product_uom_id": self.product_top.uom_id.id,
- "product_qty": 5.0,
- "bom_id": self.bom_top.id,
- }
- )
- mo.action_assign()
+ mo = self._generate_mo(self.product_top, self.bom_top)
+
self._produce(mo, 3.0)
mo.button_mark_done()
- uo = self.unbuild_obj.create(
- {
- "product_id": self.product_top.id,
- "bom_id": self.bom_top.id,
- "product_qty": 1.0,
- "product_uom_id": self.product_top.uom_id.id,
- }
- )
- uo.action_unbuild()
+
+ uo = Form(self.unbuild_obj)
+ uo.product_id = self.product_top
+ uo.bom_id = self.bom_top
+ uo.product_qty = 1
+ uo.product_uom_id = self.product_top.uom_id
+ uo.save().action_unbuild()
+
account_move_lines = self.account_move_line_obj.search(
[("unbuild_order_id", "=", uo.id)]
)
diff --git a/account_move_line_manufacture_info/views/account_move_line_view.xml b/account_move_line_manufacture_info/views/account_move_line_view.xml
index b9f71d26c..d32891cf3 100644
--- a/account_move_line_manufacture_info/views/account_move_line_view.xml
+++ b/account_move_line_manufacture_info/views/account_move_line_view.xml
@@ -17,7 +17,6 @@
Account Moves
ir.actions.act_window
account.move.line
- form
tree,form
[('manufacture_order_id', '=', active_id)]
@@ -26,7 +25,6 @@
Account Moves
ir.actions.act_window
account.move.line
- form
tree,form
[('unbuild_order_id', '=', active_id)]