From 93e3f2d1b7990b58df541df00301c9f873a0ebc8 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Sat, 26 Dec 2020 15:13:13 +0100 Subject: [PATCH] [MIG] stock_available_immediately: Migration to 14.0 --- stock_available_immediately/__manifest__.py | 3 +- .../models/product_product.py | 7 +-- .../readme/CONTRIBUTORS.rst | 1 + .../tests/test_stock_available_immediately.py | 46 +++++++++---------- 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/stock_available_immediately/__manifest__.py b/stock_available_immediately/__manifest__.py index 9fe70564e..50990e71b 100644 --- a/stock_available_immediately/__manifest__.py +++ b/stock_available_immediately/__manifest__.py @@ -6,8 +6,9 @@ { "name": "Ignore planned receptions in quantity available to promise", - "version": "12.0.1.0.0", + "version": "14.0.1.0.0", "depends": ["stock_available"], + "website": "https://github.com/OCA/stock-logistics-warehouse", "author": "Camptocamp,Sodexis,Odoo Community Association (OCA),Sergio Díaz", "license": "AGPL-3", "category": "Hidden", diff --git a/stock_available_immediately/models/product_product.py b/stock_available_immediately/models/product_product.py index 7c63e7c95..90a0d4bb6 100644 --- a/stock_available_immediately/models/product_product.py +++ b/stock_available_immediately/models/product_product.py @@ -9,11 +9,8 @@ from odoo import api, models class ProductProduct(models.Model): _inherit = "product.product" - @api.multi def _compute_available_quantities_dict(self): - res, stock_dict = super( - ProductProduct, self - )._compute_available_quantities_dict() + res, stock_dict = super()._compute_available_quantities_dict() for product in self: res[product.id]["immediately_usable_qty"] -= stock_dict[product.id][ "incoming_qty" @@ -22,4 +19,4 @@ class ProductProduct(models.Model): @api.depends("virtual_available", "incoming_qty") def _compute_available_quantities(self): - return super(ProductProduct, self)._compute_available_quantities() + return super()._compute_available_quantities() diff --git a/stock_available_immediately/readme/CONTRIBUTORS.rst b/stock_available_immediately/readme/CONTRIBUTORS.rst index 08fdae8b1..efc2cf7f5 100644 --- a/stock_available_immediately/readme/CONTRIBUTORS.rst +++ b/stock_available_immediately/readme/CONTRIBUTORS.rst @@ -7,3 +7,4 @@ * `Tecnativa `_: * Pedro M. Baeza +* Florian da Costa diff --git a/stock_available_immediately/tests/test_stock_available_immediately.py b/stock_available_immediately/tests/test_stock_available_immediately.py index 26405d2eb..72ab48b12 100644 --- a/stock_available_immediately/tests/test_stock_available_immediately.py +++ b/stock_available_immediately/tests/test_stock_available_immediately.py @@ -14,38 +14,36 @@ class TestStockLogisticsWarehouse(TransactionCase): in stock, both on product and template. """ moveObj = self.env["stock.move"] - productObj = self.env["product.product"] templateObj = self.env["product.template"] supplier_location = self.env.ref("stock.stock_location_suppliers") stock_location = self.env.ref("stock.stock_location_stock") customer_location = self.env.ref("stock.stock_location_customers") uom_unit = self.env.ref("uom.product_uom_unit") - # Create product template - templateAB = templateObj.create({"name": "templAB", "uom_id": uom_unit.id}) + # Create product template with 2 variant + templateAB = templateObj.create( + {"name": "templAB", "uom_id": uom_unit.id, "type": "product"} + ) + self.env["product.template.attribute.line"].create( + { + "product_tmpl_id": templateAB.id, + "attribute_id": self.env.ref("product.product_attribute_2").id, + "value_ids": [ + ( + 6, + 0, + [ + self.env.ref("product.product_attribute_value_3").id, + self.env.ref("product.product_attribute_value_4").id, + ], + ) + ], + } + ) # Create product A and B - productA = productObj.create( - { - "name": "product A", - "standard_price": 1, - "type": "product", - "uom_id": uom_unit.id, - "default_code": "A", - "product_tmpl_id": templateAB.id, - } - ) - - productB = productObj.create( - { - "name": "product B", - "standard_price": 1, - "type": "product", - "uom_id": uom_unit.id, - "default_code": "B", - "product_tmpl_id": templateAB.id, - } - ) + productA = templateAB.product_variant_ids[0] + productB = templateAB.product_variant_ids[1] # Create a stock move from INCOMING to STOCK stockMoveInA = moveObj.create(