From 58b3191eeee772faf54841a934549b85dca3d432 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 7 Nov 2016 13:41:42 +0100 Subject: [PATCH] add OCA style field available cannot be a stored field. remove field 'available', as it was not correctly defined remove unused method --- .../README.rst | 41 ++++++++++++++- .../__init__.py | 11 ++-- .../__openerp__.py | 40 +++++---------- .../models/__init__.py | 11 ++-- .../models/stock_warehouse_orderpoint.py | 51 +++++++++---------- .../tests/__init__.py | 11 ++-- .../tests/test_stock_warehouse_orderpoint.py | 39 +++++++------- .../views/stock_warehouse_orderpoint_view.xml | 6 --- 8 files changed, 117 insertions(+), 93 deletions(-) diff --git a/stock_warehouse_orderpoint_stock_info/README.rst b/stock_warehouse_orderpoint_stock_info/README.rst index 90bcd93a2..ce4a1c2e1 100644 --- a/stock_warehouse_orderpoint_stock_info/README.rst +++ b/stock_warehouse_orderpoint_stock_info/README.rst @@ -1,9 +1,30 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=========================== Reordering Rules stock info =========================== This modules allows to know the product availability directly in the reordering rules. +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/153/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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. + Credits ======= @@ -12,4 +33,22 @@ Contributors ------------ * Oihane Crucelaegui * Pedro M. Baeza -* Ana Juaristi \ No newline at end of file +* Ana Juaristi +* Jordi Ballester Alomar +* Serpent Consulting Services Pvt. Ltd. + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/stock_warehouse_orderpoint_stock_info/__init__.py b/stock_warehouse_orderpoint_stock_info/__init__.py index 054c8853d..c7f4154ff 100644 --- a/stock_warehouse_orderpoint_stock_info/__init__.py +++ b/stock_warehouse_orderpoint_stock_info/__init__.py @@ -1,6 +1,9 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2016 OdooMRP Team +# Copyright 2016 AvanzOSC +# Copyright 2016 Pedro M. Baeza +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models diff --git a/stock_warehouse_orderpoint_stock_info/__openerp__.py b/stock_warehouse_orderpoint_stock_info/__openerp__.py index 4816e0cc2..f7f17b395 100644 --- a/stock_warehouse_orderpoint_stock_info/__openerp__.py +++ b/stock_warehouse_orderpoint_stock_info/__openerp__.py @@ -1,20 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2016 OdooMRP Team +# Copyright 2016 AvanzOSC +# Copyright 2016 Pedro M. Baeza +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Reordering rules stock info", @@ -22,17 +12,13 @@ "depends": [ "stock", ], - "author": "OdooMRP team," - "AvanzOSC," - "Serv. Tecnol. Avanzados - Pedro M. Baeza", + "author": "OdooMRP team, " + "AvanzOSC, " + "Tecnativa, " + "Odoo Community Association (OCA)", "website": "http://www.odoomrp.com", - "contributors": [ - "Oihane Crucelaegui ", - "Pedro M. Baeza ", - "Ana Juaristi " - ], - "category": "Custom Module", - "summary": "", + "category": "Warehouse", + "license": "AGPL-3", "data": [ "views/stock_warehouse_orderpoint_view.xml", ], diff --git a/stock_warehouse_orderpoint_stock_info/models/__init__.py b/stock_warehouse_orderpoint_stock_info/models/__init__.py index 6c105e92e..c21daf9b7 100644 --- a/stock_warehouse_orderpoint_stock_info/models/__init__.py +++ b/stock_warehouse_orderpoint_stock_info/models/__init__.py @@ -1,6 +1,9 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2016 OdooMRP Team +# Copyright 2016 AvanzOSC +# Copyright 2016 Pedro M. Baeza +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import stock_warehouse_orderpoint diff --git a/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py b/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py index fed845c0c..c0eaf9a85 100644 --- a/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py +++ b/stock_warehouse_orderpoint_stock_info/models/stock_warehouse_orderpoint.py @@ -1,7 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2016 OdooMRP Team +# Copyright 2016 AvanzOSC +# Copyright 2016 Pedro M. Baeza +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp import models, fields, api @@ -9,33 +12,29 @@ from openerp import models, fields, api class StockWarehouseOrderpoint(models.Model): _inherit = 'stock.warehouse.orderpoint' - @api.one - def _product_available_qty(self): - product_available = self.product_id.with_context( - location=self.location_id.id - )._product_available()[self.product_id.id] - self.product_location_qty = product_available['qty_available'] - self.incoming_location_qty = product_available['incoming_qty'] - self.outgoing_location_qty = product_available['outgoing_qty'] - self.virtual_location_qty = product_available['virtual_available'] - - @api.one - @api.depends('product_location_qty', 'product_min_qty') - def _product_available(self): - self.available = self.product_location_qty > self.product_min_qty + @api.multi + def _compute_product_available_qty(self): + for rec in self: + product_available = rec.product_id.with_context( + location=rec.location_id.id + )._product_available()[rec.product_id.id] + rec.product_location_qty = product_available['qty_available'] + rec.incoming_location_qty = product_available['incoming_qty'] + rec.outgoing_location_qty = product_available['outgoing_qty'] + rec.virtual_location_qty = product_available['virtual_available'] product_location_qty = fields.Float( - string='Quantity On Location', compute='_product_available_qty') + string='Quantity On Location', + compute='_compute_product_available_qty') incoming_location_qty = fields.Float( - string='Incoming On Location', compute='_product_available_qty') + string='Incoming On Location', + compute='_compute_product_available_qty') outgoing_location_qty = fields.Float( - string='Outgoing On Location', compute='_product_available_qty') + string='Outgoing On Location', + compute='_compute_product_available_qty') virtual_location_qty = fields.Float( - string='Forecast On Location', compute='_product_available_qty') - - available = fields.Boolean( - string='Is enough product available?', compute='_product_available', - store=True) + string='Forecast On Location', + compute='_compute_product_available_qty') product_category = fields.Many2one(string='Product Category', related='product_id.categ_id', store=True) diff --git a/stock_warehouse_orderpoint_stock_info/tests/__init__.py b/stock_warehouse_orderpoint_stock_info/tests/__init__.py index 2ace5d84d..a9f167c7a 100644 --- a/stock_warehouse_orderpoint_stock_info/tests/__init__.py +++ b/stock_warehouse_orderpoint_stock_info/tests/__init__.py @@ -1,6 +1,9 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2016 OdooMRP Team +# Copyright 2016 AvanzOSC +# Copyright 2016 Pedro M. Baeza +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import test_stock_warehouse_orderpoint diff --git a/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py b/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py index de483d221..6a6880bf3 100644 --- a/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py +++ b/stock_warehouse_orderpoint_stock_info/tests/test_stock_warehouse_orderpoint.py @@ -1,7 +1,10 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2016 OdooMRP Team +# Copyright 2016 AvanzOSC +# Copyright 2016 Pedro M. Baeza +# Copyright 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016 Eficent Business and IT Consulting Services, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp.tests import common @@ -50,12 +53,12 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): def create_orderpoint(self): """Create a Reordering rule for the product.""" record = self.reordering_rule_model.create({ - 'name': 'Reordering Rule', - 'product_id': self.product.id, - 'product_min_qty': '1', - 'product_max_qty': '5', - 'qty_multiple': '1', - 'location_id': self.dest_location.id, + 'name': 'Reordering Rule', + 'product_id': self.product.id, + 'product_min_qty': '1', + 'product_max_qty': '5', + 'qty_multiple': '1', + 'location_id': self.dest_location.id, }) return record @@ -74,27 +77,21 @@ class TestStockWarehouseOrderpoint(common.TransactionCase): return move def test_product_qty(self): - 'Tests the product quantity in the Reordering rules' - # Checks the product availability - self.reordering_record._product_available() - self.assertFalse(self.reordering_record.available) + """Tests the product quantity in the Reordering rules""" # Create & process moves to test the product quantity - self.move = self.create_stock_move() - self.reordering_record._product_available_qty() + move = self.create_stock_move() + self.reordering_record.refresh() self.assertEqual(self.reordering_record.incoming_location_qty, self.product.incoming_qty, 'Incoming Qty does not match') self.assertEqual(self.reordering_record.virtual_location_qty, self.product.virtual_available, 'Virtual Qty does not match') - self.move.action_done() - self.reordering_record._product_available_qty() + move.action_done() + self.reordering_record.refresh() self.assertEqual(self.reordering_record.product_location_qty, self.product.qty_available, 'Available Qty does not match') self.assertEqual(self.reordering_record.virtual_location_qty, self.product.virtual_available, 'Virtual Qty does not match') - # Checks the product availability after moves processed - self.reordering_record._product_available() - self.assertTrue(self.reordering_record.available) diff --git a/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml b/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml index e76d4c8f9..0215dc274 100644 --- a/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml +++ b/stock_warehouse_orderpoint_stock_info/views/stock_warehouse_orderpoint_view.xml @@ -14,7 +14,6 @@ - @@ -51,11 +50,6 @@ domain="[]" context="{'group_by':'product_category'}"/> - - -