[MIG] mrp_unbuild_tracked_raw_material: Migration to 13.0

This commit is contained in:
ps-tubtim
2020-03-16 14:47:44 +07:00
parent c39007743c
commit 46e42bb007
8 changed files with 64 additions and 40 deletions

View File

@@ -14,13 +14,13 @@ Mrp Unbuild Tracked Raw Material
: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/mrp_unbuild_tracked_raw_material
:target: https://github.com/OCA/manufacture/tree/13.0/mrp_unbuild_tracked_raw_material
: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-mrp_unbuild_tracked_raw_material
:target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_unbuild_tracked_raw_material
: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|
@@ -69,14 +69,13 @@ Known issues / Roadmap
This module doesn't take account product `allow_unbuild_purchased` checked
which use `serial` tracking
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/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 <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_unbuild_tracked_raw_material%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_unbuild_tracked_raw_material%0Aversion:%2013.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.
@@ -95,6 +94,8 @@ Akretion:
* David Béal <david.beal@akretion.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
Maintainers
~~~~~~~~~~~
@@ -116,6 +117,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-bealdav|
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/mrp_unbuild_tracked_raw_material>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/13.0/mrp_unbuild_tracked_raw_material>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -13,8 +13,7 @@ logger = logging.getLogger(__name__)
MESSAGE = (
"Some of your components are tracked, you have to specify "
"a manufacturing order in order to retrieve "
"the correct components."
"a manufacturing order in order to retrieve the correct components."
)
ALTER_MESSAGE = (
"Alternatively, you may unbuild '%s' tracked product "
@@ -65,6 +64,7 @@ class MrpUnbuild(models.Model):
# Comes from
# https://github.com/OCA/ocb/blob/12.0/addons/mrp/models/...
# mrp_unbuild.py#L117
if consume_move:
if consume_move.has_tracking != "none":
self.env["stock.move.line"].create(
{
@@ -121,10 +121,14 @@ class MrpUnbuild(models.Model):
{"produce_line_ids": [(6, 0, produced_move_line_ids.ids)]}
)
self.message_post(
body=_("Product has been unbuilt without previous " "manufacturing order")
body=_("Product has been unbuilt without previous manufacturing order")
)
return self.write({"state": "done"})
def _prepare_lots_for_purchased_unbuild(self, product):
# Customize your data lot with your own code
return {"name": datetime.now().strftime(DT_FORMAT), "product_id": product.id}
return {
"name": datetime.now().strftime(DT_FORMAT),
"product_id": product.id,
"company_id": self.env.company.id,
}

View File

@@ -1,3 +1,5 @@
Akretion:
* David Béal <david.beal@akretion.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/manufacture/tree/12.0/mrp_unbuild_tracked_raw_material"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_unbuild_tracked_raw_material"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" 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" href="https://github.com/OCA/manufacture/tree/13.0/mrp_unbuild_tracked_raw_material"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-mrp_unbuild_tracked_raw_material"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/129/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Odoo has a limitation on tracked products components
which are not manufactured in the ERP.</p>
<p>When you try to do it, you get this warning:</p>
@@ -419,7 +419,7 @@ which use <cite>serial</cite> tracking</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_unbuild_tracked_raw_material%0Aversion:%2012.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/manufacture/issues/new?body=module:%20mrp_unbuild_tracked_raw_material%0Aversion:%2013.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">
@@ -438,6 +438,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>David Béal &lt;<a class="reference external" href="mailto:david.beal&#64;akretion.com">david.beal&#64;akretion.com</a>&gt;</li>
</ul>
</blockquote>
<ul class="simple">
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
@@ -448,7 +451,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" href="https://github.com/bealdav"><img alt="bealdav" src="https://github.com/bealdav.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/mrp_unbuild_tracked_raw_material">OCA/manufacture</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/13.0/mrp_unbuild_tracked_raw_material">OCA/manufacture</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

@@ -10,6 +10,7 @@ from odoo.addons.mrp.tests.common import TestMrpCommon
class TestUnbuildUnmanufacturedProduct(TestMrpCommon):
def setUp(self, *args, **kwargs):
self.company = self.env.ref("base.main_company")
self.loc = self.env.ref("stock.stock_location_stock")
super().setUp(*args, **kwargs)
@@ -44,10 +45,13 @@ class TestUnbuildUnmanufacturedProduct(TestMrpCommon):
return (bom, prd_to_build, prd_to_use1, prd_to_use2)
def test_unbuild(self):
""" """
bom, prd_to_build, prd_to_use1, prd_to_use2 = self.create_data()
lot = self.env["stock.production.lot"].create(
{"name": "%s" % datetime.now(), "product_id": prd_to_build.id}
{
"name": "%s" % datetime.now(),
"product_id": prd_to_build.id,
"company_id": self.company.id,
}
)
self.env["stock.quant"]._update_available_quantity(
prd_to_build, self.loc, 10, lot_id=lot
@@ -59,6 +63,8 @@ class TestUnbuildUnmanufacturedProduct(TestMrpCommon):
"product_qty": 1.0,
"lot_id": lot.id,
"product_uom_id": self.uom_unit.id,
"location_id": self.loc.id,
"location_dest_id": self.loc.id,
}
)
unbuild.action_validate()
@@ -68,7 +74,9 @@ class TestUnbuildUnmanufacturedProduct(TestMrpCommon):
def _check_qty(self, qty, product):
self.assertEqual(
self.env["stock.quant"]._get_available_quantity(product, self.loc),
self.env["stock.quant"]._get_available_quantity(
product, self.loc, allow_negative=True
),
qty,
"You should have the {} product '{}' in stock".format(qty, product.name),
)

View File

@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_template_property_form" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.view_template_property_form" />
<field name="arch" type="xml">
<field name="tracking" position="after">
<field name="allow_unbuild_purchased"
attrs="{'invisible': [('tracking', '=', 'none')]}"/>
<field
name="allow_unbuild_purchased"
attrs="{'invisible': [('tracking', '=', 'none')]}"
/>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
../../../../mrp_unbuild_tracked_raw_material

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)