forked from OCA/stock-logistics-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] stock_lot_scrap: Migration to 16.0
- Loading branch information
1 parent
7b80dc8
commit 41daa8e
Showing
7 changed files
with
35 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
* David Vidal | ||
* Vicent Cubells | ||
* Carlos Roca | ||
* Carolina Fernandez |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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, | ||
|
@@ -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, | ||
|