Skip to content

Commit

Permalink
[MIG] stock_lot_scrap: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinafernandez-tecnativa committed Jan 5, 2024
1 parent 7b80dc8 commit 41daa8e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
13 changes: 7 additions & 6 deletions stock_lot_scrap/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Scrap Production Lot
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:18b4f801e7ac8c515fb91fc05bc17b09ae314f40963aa31695e16d116aab23b3
!! source digest: sha256:a1b0470f00d0544b144393d2d88084606a6592ca309c3fe97c11e763d7cc2451
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Scrap Production Lot
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_lot_scrap
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_lot_scrap
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_lot_scrap
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_lot_scrap
: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/stock-logistics-workflow&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -55,7 +55,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/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/stock-logistics-workflow/issues/new?body=module:%20stock_lot_scrap%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_lot_scrap%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.

Expand All @@ -77,6 +77,7 @@ Contributors
* David Vidal
* Vicent Cubells
* Carlos Roca
* Carolina Fernandez

Maintainers
~~~~~~~~~~~
Expand All @@ -91,6 +92,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/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/14.0/stock_lot_scrap>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_lot_scrap>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 2 additions & 1 deletion stock_lot_scrap/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# Copyright 2016 Pedro M. Baeza <[email protected]>
# Copyright 2017 David Vidal <[email protected]>
# Copyright 2021 Tecnativa - Carlos Roca
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Scrap Production Lot",
"summary": "This module adds a button in Production Lot/Serial Number "
"view form to Scrap all products contained.",
"version": "14.0.1.0.2",
"version": "16.0.1.0.0",
"category": "Stock",
"license": "AGPL-3",
"author": "Tecnativa," "Odoo Community Association (OCA)",
Expand Down
2 changes: 1 addition & 1 deletion stock_lot_scrap/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import stock_production_lot
from . import stock_lot
from . import stock_scrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2016 Carlos Dauden <[email protected]>
# Copyright 2016 Pedro M. Baeza <[email protected]>
# Copyright 2017 David Vidal <[email protected]>
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from lxml import etree
Expand All @@ -9,20 +10,22 @@
from odoo.exceptions import ValidationError


class StockProductionLot(models.Model):
_inherit = "stock.production.lot"
class StockLot(models.Model):
_inherit = "stock.lot"

@api.model
def fields_view_get(
self, view_id=None, view_type="form", toolbar=False, submenu=False
): # pragma: no cover
def _get_view(self, view_id=None, view_type="form", **options):
"""Inject the button here to avoid conflicts with other modules
that add a header element in the main view.
"""
res = super().fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
)
eview = etree.fromstring(res["arch"])
arch, view = super()._get_view(view_id, view_type, **options)

if isinstance(arch, bytes):
# If arch is bytes, convert it to an XML element
eview = etree.fromstring(arch)
else:
# If arch is already an XML element, no need to parse
eview = arch
xml_header = eview.xpath("//header")
if not xml_header:
# Create a header
Expand All @@ -39,15 +42,14 @@ def fields_view_get(
"type": "object",
"name": "action_scrap_lot",
"confirm": _(
"This will scrap the whole lot. Are you"
" sure you want to continue?"
"This will scrap the whole lot. Are you sure you want to continue?"
),
"string": _("Scrap"),
},
)
header_element.append(button_element)
res["arch"] = etree.tostring(eview)
return res
arch = eview # Return the XML element directly
return arch, view

def _prepare_scrap_vals(self, quant, scrap_location_id):
self.ensure_one()
Expand Down
1 change: 1 addition & 0 deletions stock_lot_scrap/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* David Vidal
* Vicent Cubells
* Carlos Roca
* Carolina Fernandez
9 changes: 5 additions & 4 deletions stock_lot_scrap/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Scrap Production Lot</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:18b4f801e7ac8c515fb91fc05bc17b09ae314f40963aa31695e16d116aab23b3
!! source digest: sha256:a1b0470f00d0544b144393d2d88084606a6592ca309c3fe97c11e763d7cc2451
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/stock-logistics-workflow/tree/14.0/stock_lot_scrap"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-14-0/stock-logistics-workflow-14-0-stock_lot_scrap"><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/stock-logistics-workflow&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/stock-logistics-workflow/tree/16.0/stock_lot_scrap"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_lot_scrap"><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/stock-logistics-workflow&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 adds a button in <em>Production Lot/Serial Number</em> view form to
<em>Scrap</em> all quants contained.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -406,7 +406,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/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/stock-logistics-workflow/issues/new?body=module:%20stock_lot_scrap%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/stock-logistics-workflow/issues/new?body=module:%20stock_lot_scrap%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">
Expand All @@ -426,6 +426,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>David Vidal</li>
<li>Vicent Cubells</li>
<li>Carlos Roca</li>
<li>Carolina Fernandez</li>
</ul>
</li>
</ul>
Expand All @@ -437,7 +438,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<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/stock-logistics-workflow/tree/14.0/stock_lot_scrap">OCA/stock-logistics-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_lot_scrap">OCA/stock-logistics-workflow</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>
Expand Down
7 changes: 4 additions & 3 deletions stock_lot_scrap/tests/test_stock_lot_scrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2016 Carlos Dauden <[email protected]>
# Copyright 2016 Pedro M. Baeza <[email protected]>
# Copyright 2017 David Vidal <[email protected]>
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.exceptions import ValidationError
Expand All @@ -9,15 +10,15 @@


@tagged("post_install", "-at_install")
class TestStockLotScrap(common.SavepointCase):
class TestStockLotScrap(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.product = cls.env["product.product"].create(
{"name": "Test product", "type": "product"}
)
cls.company = cls.env.ref("base.main_company")
cls.lot010 = cls.env["stock.production.lot"].create(
cls.lot010 = cls.env["stock.lot"].create(
{
"name": "0000010",
"product_id": cls.product.id,
Expand Down Expand Up @@ -56,7 +57,7 @@ def test_picking_created(self):

def test_warning(self):
product_new = self.product.create({"name": "Test product 040"})
self.lot040 = self.env["stock.production.lot"].create(
self.lot040 = self.env["stock.lot"].create(
{
"name": "0000040",
"product_id": product_new.id,
Expand Down

0 comments on commit 41daa8e

Please sign in to comment.