From b2763e5ce3a3c5e7e196295ec458996c01d22afb Mon Sep 17 00:00:00 2001 From: Nikul-Chaudhary Date: Sun, 27 Jan 2019 18:27:19 +0530 Subject: [PATCH] [MIG] purchase_order_secondary_unit v11 to v12 --- purchase_order_secondary_unit/README.rst | 1 + purchase_order_secondary_unit/__manifest__.py | 2 +- .../readme/CONTRIBUTORS.rst | 1 + .../test_purchase_order_secondary_unit.py | 27 +++++++++++++------ .../views/product_views.xml | 2 +- .../views/purchase_order_views.xml | 2 +- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/purchase_order_secondary_unit/README.rst b/purchase_order_secondary_unit/README.rst index d6687078e86..ccd20e139ab 100644 --- a/purchase_order_secondary_unit/README.rst +++ b/purchase_order_secondary_unit/README.rst @@ -66,6 +66,7 @@ Contributors ~~~~~~~~~~~~ * Sergio Teruel +* Nikul Chaudhary Maintainers ~~~~~~~~~~~ diff --git a/purchase_order_secondary_unit/__manifest__.py b/purchase_order_secondary_unit/__manifest__.py index 45c6dd339bb..19817b87c68 100644 --- a/purchase_order_secondary_unit/__manifest__.py +++ b/purchase_order_secondary_unit/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Purchase Order Secondary Unit', 'summary': 'Purchase product in a secondary unit', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'development_status': 'Beta', 'category': 'Purchase', 'website': 'https://github.com/OCA/purchase-workflow', diff --git a/purchase_order_secondary_unit/readme/CONTRIBUTORS.rst b/purchase_order_secondary_unit/readme/CONTRIBUTORS.rst index f24a0b0dc74..cbf75168438 100644 --- a/purchase_order_secondary_unit/readme/CONTRIBUTORS.rst +++ b/purchase_order_secondary_unit/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Sergio Teruel +* Nikul Chaudhary diff --git a/purchase_order_secondary_unit/tests/test_purchase_order_secondary_unit.py b/purchase_order_secondary_unit/tests/test_purchase_order_secondary_unit.py index d9ea71d6ab1..23c32d953c4 100644 --- a/purchase_order_secondary_unit/tests/test_purchase_order_secondary_unit.py +++ b/purchase_order_secondary_unit/tests/test_purchase_order_secondary_unit.py @@ -1,17 +1,18 @@ # Copyright 2018 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields -from odoo.tests import SavepointCase +from odoo.tests.common import SavepointCase, tagged +@tagged('post_install', '-at_install') class TestPurchaseOrderSecondaryUnit(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.product_uom_kg = cls.env.ref('product.product_uom_kgm') - cls.product_uom_gram = cls.env.ref('product.product_uom_gram') - cls.product_uom_unit = cls.env.ref('product.product_uom_unit') + cls.product_uom_kg = cls.env.ref('uom.product_uom_kgm') + cls.product_uom_gram = cls.env.ref('uom.product_uom_gram') + cls.product_uom_unit = cls.env.ref('uom.product_uom_unit') cls.product = cls.env['product.product'].create({ 'name': 'test', 'uom_id': cls.product_uom_kg.id, @@ -31,9 +32,19 @@ def setUpClass(cls): 'name': 'test - partner', 'supplier': True, }) - po = cls.env['purchase.order'].new({ + type_obj = cls.env['stock.picking.type'] + company_id = cls.env.user.company_id.id + picking_type_id = type_obj.search([ + ('code', '=', 'incoming'), + ('warehouse_id.company_id', '=', company_id) + ], limit=1) + if not picking_type_id: + picking_type_id = cls.env.ref('stock.picking_type_in') + cls.purchase_order_obj = cls.env['purchase.order'] + po_val = { 'partner_id': cls.partner.id, 'company_id': cls.env.user.company_id.id, + 'picking_type_id': picking_type_id.id, 'order_line': [(0, 0, { 'name': cls.product.name, 'product_id': cls.product.id, @@ -42,10 +53,10 @@ def setUpClass(cls): 'price_unit': 1000.00, 'date_planned': fields.Datetime.now(), })], - }) + } + po = cls.purchase_order_obj.new(po_val) po.onchange_partner_id() - cls.order = cls.env['purchase.order'].create( - po._convert_to_write(po._cache)) + cls.order = cls.purchase_order_obj.create(po_val) def test_onchange_secondary_uom(self): self.order.order_line.write({ diff --git a/purchase_order_secondary_unit/views/product_views.xml b/purchase_order_secondary_unit/views/product_views.xml index 552fd225f6a..522d6070993 100755 --- a/purchase_order_secondary_unit/views/product_views.xml +++ b/purchase_order_secondary_unit/views/product_views.xml @@ -7,7 +7,7 @@ Product template Secondary Unit product.template - + Purchase Order Secondary Unit purchase.order - +