From 3feb14165c7688e099fb5a3dd9af8c05d4b0ed6a Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Thu, 9 Feb 2017 19:22:38 +0100 Subject: [PATCH 01/23] [9.0][ADD] stock_inventory_exclude_sublocation (#240) * [ADD] stock_inventory_exclude_sublocation --- .../README.rst | 69 +++++++ .../__init__.py | 7 + .../__openerp__.py | 21 ++ .../models/__init__.py | 6 + .../models/stock_inventory.py | 53 +++++ .../tests/__init__.py | 6 + .../tests/test_exclude_sublocation.py | 187 ++++++++++++++++++ .../views/stock_inventory_view.xml | 18 ++ 8 files changed, 367 insertions(+) create mode 100644 stock_inventory_exclude_sublocation/README.rst create mode 100644 stock_inventory_exclude_sublocation/__init__.py create mode 100644 stock_inventory_exclude_sublocation/__openerp__.py create mode 100644 stock_inventory_exclude_sublocation/models/__init__.py create mode 100644 stock_inventory_exclude_sublocation/models/stock_inventory.py create mode 100644 stock_inventory_exclude_sublocation/tests/__init__.py create mode 100644 stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py create mode 100644 stock_inventory_exclude_sublocation/views/stock_inventory_view.xml diff --git a/stock_inventory_exclude_sublocation/README.rst b/stock_inventory_exclude_sublocation/README.rst new file mode 100644 index 000000000..7d1865718 --- /dev/null +++ b/stock_inventory_exclude_sublocation/README.rst @@ -0,0 +1,69 @@ +.. 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 + +=================================== +Stock Inventory Exclude Sublocation +=================================== + +This module extends the functionality of Inventory Adjustment to allow you to +exclude all the sublocations when doing an inventory adjustment for a +given location. + +Sometimes we just want to make an inventory adjustment of just one shelf, or +space and forget about extra subdivisions in the location. In other cases we +do inventories of smaller locations contained in our stock, so we don't want +to count them again when doing an inventory adjustment of the parent location. +E.g. if we apply a cycle count strategy. + + +Usage +===== + +To use this module, you simply need to: + +#. Create a new inventory adjustment. +#. Select the option inventory of all products. +#. Check the box "Exclude Sublocations". + +.. 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/9.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 smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Lois Rilo Antelo + + +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_inventory_exclude_sublocation/__init__.py b/stock_inventory_exclude_sublocation/__init__.py new file mode 100644 index 000000000..289aba0fe --- /dev/null +++ b/stock_inventory_exclude_sublocation/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from . import tests diff --git a/stock_inventory_exclude_sublocation/__openerp__.py b/stock_inventory_exclude_sublocation/__openerp__.py new file mode 100644 index 000000000..a6ba8022d --- /dev/null +++ b/stock_inventory_exclude_sublocation/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Inventory Exclude Sublocation", + "summary": "Allow to perform inventories of a location without including " + "its child locations.", + "version": "9.0.1.0.0", + "author": "Eficent," + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse Management", + "depends": ["stock"], + "data": [ + 'views/stock_inventory_view.xml' + ], + "license": "AGPL-3", + 'installable': True, + 'application': False, +} diff --git a/stock_inventory_exclude_sublocation/models/__init__.py b/stock_inventory_exclude_sublocation/models/__init__.py new file mode 100644 index 000000000..eff36f793 --- /dev/null +++ b/stock_inventory_exclude_sublocation/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import stock_inventory diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py new file mode 100644 index 000000000..8421ce802 --- /dev/null +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openerp import fields, models, api + + +class StockInventory(models.Model): + _inherit = 'stock.inventory' + + exclude_sublocation = fields.Boolean(string='Exclude Sublocations', + default=False) + + @api.model + def _get_inventory_lines(self, inventory): + if inventory.exclude_sublocation: + product_obj = self.env['product.product'] + domain = ' location_id = %s' + args = (tuple(inventory.location_id.ids)) + if inventory.partner_id: + domain += ' and owner_id = %s' + args += (inventory.partner_id.id,) + if inventory.lot_id: + domain += ' and lot_id = %s' + args += (inventory.lot_id.id,) + if inventory.product_id: + domain += ' and product_id = %s' + args += (inventory.product_id.id,) + if inventory.package_id: + domain += ' and package_id = %s' + args += (inventory.package_id.id,) + + self.env.cr.execute(''' + SELECT product_id, sum(qty) as product_qty, location_id, lot_id + as prod_lot_id, package_id, owner_id as partner_id + FROM stock_quant WHERE''' + domain + ''' + GROUP BY product_id, location_id, lot_id, package_id, partner_id + ''', args) + vals = [] + for product_line in self.env.cr.dictfetchall(): + for key, value in product_line.items(): + if not value: + product_line[key] = False + product_line['inventory_id'] = inventory.id + product_line['theoretical_qty'] = product_line['product_qty'] + if product_line['product_id']: + product = product_obj.browse(product_line['product_id']) + product_line['product_uom_id'] = product.uom_id.id + vals.append(product_line) + return vals + else: + return super(StockInventory, self)._get_inventory_lines(inventory) diff --git a/stock_inventory_exclude_sublocation/tests/__init__.py b/stock_inventory_exclude_sublocation/tests/__init__.py new file mode 100644 index 000000000..f2e05e912 --- /dev/null +++ b/stock_inventory_exclude_sublocation/tests/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py new file mode 100644 index 000000000..8913dba79 --- /dev/null +++ b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py @@ -0,0 +1,187 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +import openerp.tests.common as common + + +class TestStockInventoryExcludeSublocation(common.TransactionCase): + + def setUp(self): + super(TestStockInventoryExcludeSublocation, self).setUp() + self.inventory_model = self.env['stock.inventory'] + self.location_model = self.env['stock.location'] + self.lot_model = self.env['stock.production.lot'] + self.quant_model = self.env['stock.quant'] + self.package_model = self.env['stock.quant.package'] + self.res_users_model = self.env['res.users'] + + self.company = self.env.ref('base.main_company') + self.partner = self.ref('base.res_partner_4') + self.grp_stock_manager = self.env.ref('stock.group_stock_manager') + self.grp_tracking_owner = self.env.ref('stock.group_tracking_owner') + self.grp_production_lot = self.env.ref('stock.group_production_lot') + self.grp_tracking_lot = self.env.ref('stock.group_tracking_lot') + + self.user = self.res_users_model.create({ + 'name': 'Test Account User', + 'login': 'user_1', + 'password': 'demo', + 'email': 'example@yourcompany.com', + 'company_id': self.company.id, + 'company_ids': [(4, self.company.id)], + 'groups_id': [(6, 0, [ + self.grp_stock_manager.id, + self.grp_tracking_owner.id, + self.grp_production_lot.id, + self.grp_tracking_lot.id + ])] + }) + + self.product1 = self.env['product.product'].create({ + 'name': 'Product for parent location', + 'type': 'product', + 'default_code': 'PROD1', + }) + self.product2 = self.env['product.product'].create({ + 'name': 'Product for child location', + 'type': 'product', + 'default_code': 'PROD2', + }) + self.location = self.location_model.create({ + 'name': 'Inventory tests', + 'usage': 'internal', + }) + self.sublocation = self.location_model.create({ + 'name': 'Inventory sublocation test', + 'usage': 'internal', + 'location_id': self.location.id + }) + self.lot_a = self.lot_model.create({ + 'name': 'Lot for product1', + 'product_id': self.product1.id + }) + self.package = self.package_model.create({'name': 'PACK00TEST1'}) + + # Add a product in each location + starting_inv = self.inventory_model.create({ + 'name': 'Starting inventory', + 'filter': 'product', + 'line_ids': [ + (0, 0, { + 'product_id': self.product1.id, + 'product_uom_id': self.env.ref( + "product.product_uom_unit").id, + 'product_qty': 2.0, + 'location_id': self.location.id, + 'prod_lot_id': self.lot_a.id + }), + (0, 0, { + 'product_id': self.product2.id, + 'product_uom_id': self.env.ref( + "product.product_uom_unit").id, + 'product_qty': 4.0, + 'location_id': self.sublocation.id, + 'prod_lot_id': self.lot_a.id + }), + ], + }) + starting_inv.action_done() + + def _create_inventory_all_products(self, name, location, + exclude_sublocation): + inventory = self.inventory_model.create({ + 'name': name, + 'filter': 'none', + 'location_id': location.id, + 'exclude_sublocation': exclude_sublocation + }) + return inventory + + def test_not_excluding_sublocations(self): + '''Check if products in sublocations are included into the inventory + if the excluding sublocations option is disabled.''' + inventory_location = self._create_inventory_all_products( + 'location inventory', self.location, False) + inventory_location.prepare_inventory() + inventory_location.action_done() + lines = inventory_location.line_ids + self.assertEqual(len(lines), 2, 'Not all expected products are ' + 'included') + + def test_excluding_sublocations(self): + '''Check if products in sublocations are not included if the exclude + sublocations is enabled.''' + inventory_location = self._create_inventory_all_products( + 'location inventory', self.location, True) + inventory_sublocation = self._create_inventory_all_products( + 'sublocation inventory', self.sublocation, True) + inventory_location.prepare_inventory() + inventory_location.action_done() + inventory_sublocation.prepare_inventory() + inventory_sublocation.action_done() + lines_location = inventory_location.line_ids + lines_sublocation = inventory_sublocation.line_ids + self.assertEqual(len(lines_location), 1, + 'The products in the sublocations are not excluded') + self.assertEqual(len(lines_sublocation), 1, + 'The products in the sublocations are not excluded') + + def test_lot_excluding_sublocation(self): + '''Check if the sublocations are excluded when using lots.''' + inventory = self.inventory_model.sudo(self.user.id).create({ + 'name': 'Inventory lot', + 'filter': 'lot', + 'location_id': self.location.id, + 'lot_id': self.lot_a.id, + 'exclude_sublocation': True + }) + inventory.prepare_inventory() + inventory.action_done() + lines = inventory.line_ids + self.assertEqual(len(lines), 1, 'The products in the sublocations are ' + 'not excluded with lots.') + + def test_product_and_owner_excluding_sublocation(self): + '''Check if sublocations are excluded when filtering by owner and + product.''' + self.quant_model.create({ + 'product_id': self.product1.id, + 'location_id': self.location.id, + 'qty': 1, + 'owner_id': self.partner, + }) + inventory = self.inventory_model.sudo(self.user.id).create({ + 'name': 'Inventory lot', + 'filter': 'product_owner', + 'location_id': self.location.id, + 'product_id': self.product1.id, + 'partner_id': self.partner, + 'exclude_sublocation': True + }) + inventory.prepare_inventory() + lines = inventory.line_ids + self.assertEqual(len(lines), 1, + 'The products in the sublocations are ' + 'not excluded with product and owner filter.') + + def test_pack_excluding_sublocation(self): + '''Check if sublocations are excluded when filtering by package.''' + self.quant_model.create({ + 'product_id': self.product1.id, + 'location_id': self.location.id, + 'qty': 1, + 'package_id': self.package.id + }) + inventory = self.inventory_model.sudo(self.user.id).create({ + 'name': 'Inventory lot', + 'filter': 'pack', + 'location_id': self.location.id, + 'package_id': self.package.id, + 'exclude_sublocation': True + }) + inventory.prepare_inventory() + lines = inventory.line_ids + self.assertEqual(len(lines), 1, 'The products in the sublocations are ' + 'not excluded with package filter.') diff --git a/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml b/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml new file mode 100644 index 000000000..c51b076b2 --- /dev/null +++ b/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml @@ -0,0 +1,18 @@ + + + + + + + Inventory form view - cycle count extension + stock.inventory + + + + + + + + + From 293f559859dab2534b15955118d785df1581e5ed Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 11 Feb 2017 02:36:26 -0500 Subject: [PATCH 02/23] OCA Transbot updated translations from Transifex --- .../i18n/de.po | 30 +++++++++++++++++++ .../i18n/es.po | 30 +++++++++++++++++++ .../i18n/es_ES.po | 29 ++++++++++++++++++ .../i18n/fr.po | 29 ++++++++++++++++++ .../i18n/it.po | 29 ++++++++++++++++++ .../i18n/pt_BR.po | 29 ++++++++++++++++++ .../i18n/sl.po | 29 ++++++++++++++++++ 7 files changed, 205 insertions(+) create mode 100644 stock_inventory_exclude_sublocation/i18n/de.po create mode 100644 stock_inventory_exclude_sublocation/i18n/es.po create mode 100644 stock_inventory_exclude_sublocation/i18n/es_ES.po create mode 100644 stock_inventory_exclude_sublocation/i18n/fr.po create mode 100644 stock_inventory_exclude_sublocation/i18n/it.po create mode 100644 stock_inventory_exclude_sublocation/i18n/pt_BR.po create mode 100644 stock_inventory_exclude_sublocation/i18n/sl.po diff --git a/stock_inventory_exclude_sublocation/i18n/de.po b/stock_inventory_exclude_sublocation/i18n/de.po new file mode 100644 index 000000000..2d76ee227 --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/de.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# OCA Transbot , 2017 +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-29 13:12+0000\n" +"PO-Revision-Date: 2017-06-29 13:12+0000\n" +"Last-Translator: Rudolf Schnapka , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "Unterlager ausschließen" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Bestand" diff --git a/stock_inventory_exclude_sublocation/i18n/es.po b/stock_inventory_exclude_sublocation/i18n/es.po new file mode 100644 index 000000000..a8a4cbd61 --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/es.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# OCA Transbot , 2017 +# Fernando Lara , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-18 04:05+0000\n" +"PO-Revision-Date: 2017-02-18 04:05+0000\n" +"Last-Translator: Fernando Lara , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "Excluir sublocaciones" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventario" diff --git a/stock_inventory_exclude_sublocation/i18n/es_ES.po b/stock_inventory_exclude_sublocation/i18n/es_ES.po new file mode 100644 index 000000000..519e9dadc --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/es_ES.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# Javier García-Panach , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-10 03:40+0000\n" +"PO-Revision-Date: 2017-02-10 03:40+0000\n" +"Last-Translator: Javier García-Panach , 2017\n" +"Language-Team: Spanish (Spain) (https://www.transifex.com/oca/teams/23907/es_ES/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es_ES\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventario" diff --git a/stock_inventory_exclude_sublocation/i18n/fr.po b/stock_inventory_exclude_sublocation/i18n/fr.po new file mode 100644 index 000000000..4c16caaee --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/fr.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-10 03:40+0000\n" +"PO-Revision-Date: 2017-02-10 03:40+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventaire" diff --git a/stock_inventory_exclude_sublocation/i18n/it.po b/stock_inventory_exclude_sublocation/i18n/it.po new file mode 100644 index 000000000..789884283 --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/it.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# Paolo Valier , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-10 03:40+0000\n" +"PO-Revision-Date: 2017-02-10 03:40+0000\n" +"Last-Translator: Paolo Valier , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventario" diff --git a/stock_inventory_exclude_sublocation/i18n/pt_BR.po b/stock_inventory_exclude_sublocation/i18n/pt_BR.po new file mode 100644 index 000000000..822a1cfd9 --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/pt_BR.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# Felipe Lopes , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-10 03:40+0000\n" +"PO-Revision-Date: 2017-02-10 03:40+0000\n" +"Last-Translator: Felipe Lopes , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventário" diff --git a/stock_inventory_exclude_sublocation/i18n/sl.po b/stock_inventory_exclude_sublocation/i18n/sl.po new file mode 100644 index 000000000..d9dec889f --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/sl.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# Matjaž Mozetič , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-10 03:40+0000\n" +"PO-Revision-Date: 2017-02-10 03:40+0000\n" +"Last-Translator: Matjaž Mozetič , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventar" From 346d37d1bbe0897d76c536e11834dfc636aa299f Mon Sep 17 00:00:00 2001 From: lreficent Date: Tue, 4 Jul 2017 10:31:31 +0200 Subject: [PATCH 03/23] [9.0][IMP] stock_inventory_exclude_sublocaton: track visibility and only editable in draft state --- .../__openerp__.py | 4 ++-- .../models/stock_inventory.py | 13 ++++++++---- .../static/description/icon.png | Bin 0 -> 9455 bytes .../tests/test_exclude_sublocation.py | 20 +++++++++--------- 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 stock_inventory_exclude_sublocation/static/description/icon.png diff --git a/stock_inventory_exclude_sublocation/__openerp__.py b/stock_inventory_exclude_sublocation/__openerp__.py index a6ba8022d..3774ab76d 100644 --- a/stock_inventory_exclude_sublocation/__openerp__.py +++ b/stock_inventory_exclude_sublocation/__openerp__.py @@ -6,12 +6,12 @@ "name": "Stock Inventory Exclude Sublocation", "summary": "Allow to perform inventories of a location without including " "its child locations.", - "version": "9.0.1.0.0", + "version": "9.0.1.0.1", "author": "Eficent," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse Management", - "depends": ["stock"], + "depends": ["stock", "stock_inventory_chatter"], "data": [ 'views/stock_inventory_view.xml' ], diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py index 8421ce802..99e15b2e4 100644 --- a/stock_inventory_exclude_sublocation/models/stock_inventory.py +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -3,21 +3,26 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import fields, models, api +from openerp import api, fields, models class StockInventory(models.Model): _inherit = 'stock.inventory' - exclude_sublocation = fields.Boolean(string='Exclude Sublocations', - default=False) + exclude_sublocation = fields.Boolean( + string='Exclude Sublocations', default=False, + track_visibility='onchange', readonly=True, + states={'draft': [('readonly', False)]}) @api.model def _get_inventory_lines(self, inventory): if inventory.exclude_sublocation: product_obj = self.env['product.product'] domain = ' location_id = %s' - args = (tuple(inventory.location_id.ids)) + args = (tuple(inventory.location_id.ids),) + if inventory.company_id.id: + domain += ' and company_id = %s' + args += (inventory.company_id.id,) if inventory.partner_id: domain += ' and owner_id = %s' args += (inventory.partner_id.id,) diff --git a/stock_inventory_exclude_sublocation/static/description/icon.png b/stock_inventory_exclude_sublocation/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH z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yE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py index 8913dba79..bc9bbfc60 100644 --- a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py +++ b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py @@ -3,10 +3,10 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common +from openerp.tests.common import TransactionCase -class TestStockInventoryExcludeSublocation(common.TransactionCase): +class TestStockInventoryExcludeSublocation(TransactionCase): def setUp(self): super(TestStockInventoryExcludeSublocation, self).setUp() @@ -100,8 +100,8 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): return inventory def test_not_excluding_sublocations(self): - '''Check if products in sublocations are included into the inventory - if the excluding sublocations option is disabled.''' + """Check if products in sublocations are included into the inventory + if the excluding sublocations option is disabled.""" inventory_location = self._create_inventory_all_products( 'location inventory', self.location, False) inventory_location.prepare_inventory() @@ -111,8 +111,8 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'included') def test_excluding_sublocations(self): - '''Check if products in sublocations are not included if the exclude - sublocations is enabled.''' + """Check if products in sublocations are not included if the exclude + sublocations is enabled.""" inventory_location = self._create_inventory_all_products( 'location inventory', self.location, True) inventory_sublocation = self._create_inventory_all_products( @@ -129,7 +129,7 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'The products in the sublocations are not excluded') def test_lot_excluding_sublocation(self): - '''Check if the sublocations are excluded when using lots.''' + """Check if the sublocations are excluded when using lots.""" inventory = self.inventory_model.sudo(self.user.id).create({ 'name': 'Inventory lot', 'filter': 'lot', @@ -144,8 +144,8 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'not excluded with lots.') def test_product_and_owner_excluding_sublocation(self): - '''Check if sublocations are excluded when filtering by owner and - product.''' + """Check if sublocations are excluded when filtering by owner and + product.""" self.quant_model.create({ 'product_id': self.product1.id, 'location_id': self.location.id, @@ -167,7 +167,7 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'not excluded with product and owner filter.') def test_pack_excluding_sublocation(self): - '''Check if sublocations are excluded when filtering by package.''' + """Check if sublocations are excluded when filtering by package.""" self.quant_model.create({ 'product_id': self.product1.id, 'location_id': self.location.id, From 2c230a1f2c72d326a9ac0565451340aad6dd05dd Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 19 Jul 2017 18:35:09 +0200 Subject: [PATCH 04/23] [MIG] stock_inventory_exclude_sublocation: Migration to 10.0 --- .../README.rst | 2 +- .../{__openerp__.py => __manifest__.py} | 2 +- .../models/stock_inventory.py | 98 +++++++++++-------- .../tests/test_exclude_sublocation.py | 2 +- 4 files changed, 62 insertions(+), 42 deletions(-) rename stock_inventory_exclude_sublocation/{__openerp__.py => __manifest__.py} (96%) diff --git a/stock_inventory_exclude_sublocation/README.rst b/stock_inventory_exclude_sublocation/README.rst index 7d1865718..38d75ff58 100644 --- a/stock_inventory_exclude_sublocation/README.rst +++ b/stock_inventory_exclude_sublocation/README.rst @@ -28,7 +28,7 @@ To use this module, you simply need to: .. 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/9.0 + :target: https://runbot.odoo-community.org/runbot/153/10.0 Bug Tracker diff --git a/stock_inventory_exclude_sublocation/__openerp__.py b/stock_inventory_exclude_sublocation/__manifest__.py similarity index 96% rename from stock_inventory_exclude_sublocation/__openerp__.py rename to stock_inventory_exclude_sublocation/__manifest__.py index 3774ab76d..1d7ee88d3 100644 --- a/stock_inventory_exclude_sublocation/__openerp__.py +++ b/stock_inventory_exclude_sublocation/__manifest__.py @@ -6,7 +6,7 @@ "name": "Stock Inventory Exclude Sublocation", "summary": "Allow to perform inventories of a location without including " "its child locations.", - "version": "9.0.1.0.1", + "version": "10.0.1.0.0", "author": "Eficent," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py index 99e15b2e4..fdc647ad6 100644 --- a/stock_inventory_exclude_sublocation/models/stock_inventory.py +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -3,10 +3,10 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models +from odoo import api, fields, models -class StockInventory(models.Model): +class Inventory(models.Model): _inherit = 'stock.inventory' exclude_sublocation = fields.Boolean( @@ -14,45 +14,65 @@ class StockInventory(models.Model): track_visibility='onchange', readonly=True, states={'draft': [('readonly', False)]}) - @api.model - def _get_inventory_lines(self, inventory): - if inventory.exclude_sublocation: - product_obj = self.env['product.product'] + @api.multi + def _get_inventory_lines_values(self): + if self.exclude_sublocation: domain = ' location_id = %s' - args = (tuple(inventory.location_id.ids),) - if inventory.company_id.id: - domain += ' and company_id = %s' - args += (inventory.company_id.id,) - if inventory.partner_id: - domain += ' and owner_id = %s' - args += (inventory.partner_id.id,) - if inventory.lot_id: - domain += ' and lot_id = %s' - args += (inventory.lot_id.id,) - if inventory.product_id: - domain += ' and product_id = %s' - args += (inventory.product_id.id,) - if inventory.package_id: - domain += ' and package_id = %s' - args += (inventory.package_id.id,) + args = (tuple(self.location_id.ids),) - self.env.cr.execute(''' - SELECT product_id, sum(qty) as product_qty, location_id, lot_id - as prod_lot_id, package_id, owner_id as partner_id - FROM stock_quant WHERE''' + domain + ''' - GROUP BY product_id, location_id, lot_id, package_id, partner_id - ''', args) vals = [] - for product_line in self.env.cr.dictfetchall(): - for key, value in product_line.items(): - if not value: - product_line[key] = False - product_line['inventory_id'] = inventory.id - product_line['theoretical_qty'] = product_line['product_qty'] - if product_line['product_id']: - product = product_obj.browse(product_line['product_id']) - product_line['product_uom_id'] = product.uom_id.id - vals.append(product_line) + product_obj = self.env['product.product'] + # Empty recordset of products available in stock_quants + quant_products = self.env['product.product'] + # Empty recordset of products to filter + products_to_filter = self.env['product.product'] + + if self.company_id.id: + domain += ' and company_id = %s' + args += (self.company_id.id,) + if self.partner_id: + domain += ' and owner_id = %s' + args += (self.partner_id.id,) + if self.lot_id: + domain += ' and lot_id = %s' + args += (self.lot_id.id,) + if self.product_id: + domain += ' and product_id = %s' + args += (self.product_id.id,) + products_to_filter |= self.product_id + if self.package_id: + domain += ' and package_id = %s' + args += (self.package_id.id,) + if self.category_id: + categ_products = product_obj.search( + [('categ_id', '=', self.category_id.id)]) + domain += ' AND product_id = ANY (%s)' + args += (categ_products.ids,) + products_to_filter |= categ_products + + self.env.cr.execute(""" + SELECT product_id, sum(qty) as product_qty, location_id, lot_id + as prod_lot_id, package_id, owner_id as partner_id + FROM stock_quant + WHERE %s + GROUP BY product_id, location_id, lot_id, package_id, + partner_id """ % domain, args) + + for product_data in self.env.cr.dictfetchall(): + for void_field in [item[0] for item in product_data.items() if + item[1] is None]: + product_data[void_field] = False + product_data['theoretical_qty'] = product_data['product_qty'] + if product_data['product_id']: + product_data['product_uom_id'] = product_obj.browse( + product_data['product_id']).uom_id.id + quant_products |= product_obj.browse( + product_data['product_id']) + vals.append(product_data) + if self.exhausted: + exhausted_vals = self._get_exhausted_inventory_line( + products_to_filter, quant_products) + vals.extend(exhausted_vals) return vals else: - return super(StockInventory, self)._get_inventory_lines(inventory) + return super(Inventory, self)._get_inventory_lines_values() diff --git a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py index bc9bbfc60..0fe5afbc2 100644 --- a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py +++ b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py @@ -3,7 +3,7 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase class TestStockInventoryExcludeSublocation(TransactionCase): From da1c9d2c7bfa8f68ab8f2a9defb83f648559eac6 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 2 Dec 2017 14:28:21 +0100 Subject: [PATCH 05/23] OCA Transbot updated translations from Transifex --- .../i18n/cs_CZ.po | 30 +++++++++++++++++++ .../i18n/de.po | 15 +++++----- .../i18n/es.po | 15 +++++----- .../i18n/es_ES.po | 7 +++-- .../i18n/fr.po | 4 +-- .../i18n/it.po | 4 +-- .../i18n/pt_BR.po | 7 +++-- .../i18n/sl.po | 7 +++-- .../stock_inventory_exclude_sublocation.pot | 25 ++++++++++++++++ 9 files changed, 85 insertions(+), 29 deletions(-) create mode 100644 stock_inventory_exclude_sublocation/i18n/cs_CZ.po create mode 100644 stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot diff --git a/stock_inventory_exclude_sublocation/i18n/cs_CZ.po b/stock_inventory_exclude_sublocation/i18n/cs_CZ.po new file mode 100644 index 000000000..f43e86bb0 --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/cs_CZ.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +# Translators: +# Lukáš Spurný , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-27 11:37+0000\n" +"PO-Revision-Date: 2018-02-27 11:37+0000\n" +"Last-Translator: Lukáš Spurný , 2018\n" +"Language-Team: Czech (Czech Republic) (https://www.transifex.com/oca/" +"teams/23907/cs_CZ/)\n" +"Language: cs_CZ\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "Vyloučení sublocací" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "Inventář" diff --git a/stock_inventory_exclude_sublocation/i18n/de.po b/stock_inventory_exclude_sublocation/i18n/de.po index 2d76ee227..a7d01b0c6 100644 --- a/stock_inventory_exclude_sublocation/i18n/de.po +++ b/stock_inventory_exclude_sublocation/i18n/de.po @@ -1,28 +1,27 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # OCA Transbot , 2017 -# Rudolf Schnapka , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-06-29 13:12+0000\n" -"PO-Revision-Date: 2017-06-29 13:12+0000\n" -"Last-Translator: Rudolf Schnapka , 2017\n" +"POT-Creation-Date: 2017-11-30 03:53+0000\n" +"PO-Revision-Date: 2017-11-30 03:53+0000\n" +"Last-Translator: OCA Transbot , 2017\n" "Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: stock_inventory_exclude_sublocation #: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation msgid "Exclude Sublocations" -msgstr "Unterlager ausschließen" +msgstr "" #. module: stock_inventory_exclude_sublocation #: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory diff --git a/stock_inventory_exclude_sublocation/i18n/es.po b/stock_inventory_exclude_sublocation/i18n/es.po index a8a4cbd61..1e68a3693 100644 --- a/stock_inventory_exclude_sublocation/i18n/es.po +++ b/stock_inventory_exclude_sublocation/i18n/es.po @@ -1,28 +1,27 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # OCA Transbot , 2017 -# Fernando Lara , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-02-18 04:05+0000\n" -"PO-Revision-Date: 2017-02-18 04:05+0000\n" -"Last-Translator: Fernando Lara , 2017\n" +"POT-Creation-Date: 2017-11-30 03:53+0000\n" +"PO-Revision-Date: 2017-11-30 03:53+0000\n" +"Last-Translator: OCA Transbot , 2017\n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: stock_inventory_exclude_sublocation #: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation msgid "Exclude Sublocations" -msgstr "Excluir sublocaciones" +msgstr "" #. module: stock_inventory_exclude_sublocation #: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory diff --git a/stock_inventory_exclude_sublocation/i18n/es_ES.po b/stock_inventory_exclude_sublocation/i18n/es_ES.po index 519e9dadc..8dbba8422 100644 --- a/stock_inventory_exclude_sublocation/i18n/es_ES.po +++ b/stock_inventory_exclude_sublocation/i18n/es_ES.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # Javier García-Panach , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-02-10 03:40+0000\n" "PO-Revision-Date: 2017-02-10 03:40+0000\n" "Last-Translator: Javier García-Panach , 2017\n" -"Language-Team: Spanish (Spain) (https://www.transifex.com/oca/teams/23907/es_ES/)\n" +"Language-Team: Spanish (Spain) (https://www.transifex.com/oca/teams/23907/" +"es_ES/)\n" +"Language: es_ES\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: es_ES\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: stock_inventory_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/i18n/fr.po b/stock_inventory_exclude_sublocation/i18n/fr.po index 4c16caaee..414d6aae6 100644 --- a/stock_inventory_exclude_sublocation/i18n/fr.po +++ b/stock_inventory_exclude_sublocation/i18n/fr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # OCA Transbot , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-02-10 03:40+0000\n" "Last-Translator: OCA Transbot , 2017\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: stock_inventory_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/i18n/it.po b/stock_inventory_exclude_sublocation/i18n/it.po index 789884283..5be79531d 100644 --- a/stock_inventory_exclude_sublocation/i18n/it.po +++ b/stock_inventory_exclude_sublocation/i18n/it.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # Paolo Valier , 2017 msgid "" @@ -12,10 +12,10 @@ msgstr "" "PO-Revision-Date: 2017-02-10 03:40+0000\n" "Last-Translator: Paolo Valier , 2017\n" "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: it\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: stock_inventory_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/i18n/pt_BR.po b/stock_inventory_exclude_sublocation/i18n/pt_BR.po index 822a1cfd9..d9c425ae5 100644 --- a/stock_inventory_exclude_sublocation/i18n/pt_BR.po +++ b/stock_inventory_exclude_sublocation/i18n/pt_BR.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # Felipe Lopes , 2017 msgid "" @@ -11,11 +11,12 @@ msgstr "" "POT-Creation-Date: 2017-02-10 03:40+0000\n" "PO-Revision-Date: 2017-02-10 03:40+0000\n" "Last-Translator: Felipe Lopes , 2017\n" -"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: stock_inventory_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/i18n/sl.po b/stock_inventory_exclude_sublocation/i18n/sl.po index d9dec889f..f2bbda9b9 100644 --- a/stock_inventory_exclude_sublocation/i18n/sl.po +++ b/stock_inventory_exclude_sublocation/i18n/sl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_inventory_exclude_sublocation -# +# # Translators: # Matjaž Mozetič , 2017 msgid "" @@ -12,11 +12,12 @@ msgstr "" "PO-Revision-Date: 2017-02-10 03:40+0000\n" "Last-Translator: Matjaž Mozetič , 2017\n" "Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: sl\n" -"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" #. module: stock_inventory_exclude_sublocation #: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot b/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot new file mode 100644 index 000000000..b8af21560 --- /dev/null +++ b/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_inventory_exclude_sublocation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model.fields,field_description:stock_inventory_exclude_sublocation.field_stock_inventory_exclude_sublocation +msgid "Exclude Sublocations" +msgstr "" + +#. module: stock_inventory_exclude_sublocation +#: model:ir.model,name:stock_inventory_exclude_sublocation.model_stock_inventory +msgid "Inventory" +msgstr "" + From 1d2431b0e33eec2cdff5a6e3f7fc85d4cfbfd2a5 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Sun, 15 Jul 2018 12:12:20 +0200 Subject: [PATCH 06/23] fix pylint warning and errors --- .../models/stock_inventory.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py index fdc647ad6..9d3492467 100644 --- a/stock_inventory_exclude_sublocation/models/stock_inventory.py +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -28,20 +28,20 @@ class Inventory(models.Model): products_to_filter = self.env['product.product'] if self.company_id.id: - domain += ' and company_id = %s' + domain += ' AND company_id = %s' args += (self.company_id.id,) if self.partner_id: - domain += ' and owner_id = %s' + domain += ' AND owner_id = %s' args += (self.partner_id.id,) if self.lot_id: - domain += ' and lot_id = %s' + domain += ' AND lot_id = %s' args += (self.lot_id.id,) if self.product_id: - domain += ' and product_id = %s' + domain += ' AND product_id = %s' args += (self.product_id.id,) products_to_filter |= self.product_id if self.package_id: - domain += ' and package_id = %s' + domain += ' AND package_id = %s' args += (self.package_id.id,) if self.category_id: categ_products = product_obj.search( @@ -50,13 +50,16 @@ class Inventory(models.Model): args += (categ_products.ids,) products_to_filter |= categ_products - self.env.cr.execute(""" - SELECT product_id, sum(qty) as product_qty, location_id, lot_id - as prod_lot_id, package_id, owner_id as partner_id - FROM stock_quant - WHERE %s - GROUP BY product_id, location_id, lot_id, package_id, - partner_id """ % domain, args) + # disable error about SQL injection as the code here is generating + # a vulnerability + # pylint: disable = E8103 + self.env.cr.execute( + "SELECT product_id, SUM(qty) AS product_qty, location_id, " + " lot_id AS prod_lot_id, package_id, owner_id AS partner_id " + "FROM stock_quant " + "WHERE " + domain + " " + + "GROUP BY product_id, location_id, lot_id, package_id, " + "partner_id """, args) for product_data in self.env.cr.dictfetchall(): for void_field in [item[0] for item in product_data.items() if From 8c57a859211a7f393a94e672e4ff8047cb1862a0 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Wed, 12 Sep 2018 14:31:06 +0200 Subject: [PATCH 07/23] [11.0][MIG] stock_inventory_exclude_sublocation --- .../README.rst | 61 +++++--- .../__init__.py | 6 - .../__manifest__.py | 8 +- .../models/__init__.py | 5 - .../models/stock_inventory.py | 133 ++++++++++-------- .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 9 ++ .../readme/USAGE.rst | 5 + .../tests/__init__.py | 5 - .../tests/test_exclude_sublocation.py | 17 ++- .../views/stock_inventory_view.xml | 2 +- 11 files changed, 138 insertions(+), 114 deletions(-) create mode 100644 stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst create mode 100644 stock_inventory_exclude_sublocation/readme/DESCRIPTION.rst create mode 100644 stock_inventory_exclude_sublocation/readme/USAGE.rst diff --git a/stock_inventory_exclude_sublocation/README.rst b/stock_inventory_exclude_sublocation/README.rst index 38d75ff58..8b5f687e5 100644 --- a/stock_inventory_exclude_sublocation/README.rst +++ b/stock_inventory_exclude_sublocation/README.rst @@ -1,11 +1,27 @@ -.. 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 - =================================== Stock Inventory Exclude Sublocation =================================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_inventory_exclude_sublocation + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| + This module extends the functionality of Inventory Adjustment to allow you to exclude all the sublocations when doing an inventory adjustment for a given location. @@ -16,6 +32,10 @@ do inventories of smaller locations contained in our stock, so we don't want to count them again when doing an inventory adjustment of the parent location. E.g. if we apply a cycle count strategy. +**Table of contents** + +.. contents:: + :local: Usage ===== @@ -26,44 +46,41 @@ To use this module, you simply need to: #. Select the option inventory of all products. #. Check the box "Exclude Sublocations". -.. 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/10.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 smash it by providing detailed and welcomed feedback. +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. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Eficent Contributors ------------- +~~~~~~~~~~~~ * Lois Rilo Antelo +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. 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. +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_inventory_exclude_sublocation/__init__.py b/stock_inventory_exclude_sublocation/__init__.py index 289aba0fe..0650744f6 100644 --- a/stock_inventory_exclude_sublocation/__init__.py +++ b/stock_inventory_exclude_sublocation/__init__.py @@ -1,7 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - from . import models -from . import tests diff --git a/stock_inventory_exclude_sublocation/__manifest__.py b/stock_inventory_exclude_sublocation/__manifest__.py index 1d7ee88d3..8fbb5a94c 100644 --- a/stock_inventory_exclude_sublocation/__manifest__.py +++ b/stock_inventory_exclude_sublocation/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -6,14 +5,15 @@ "name": "Stock Inventory Exclude Sublocation", "summary": "Allow to perform inventories of a location without including " "its child locations.", - "version": "10.0.1.0.0", - "author": "Eficent," + "version": "11.0.1.0.0", + "development_status": "Mature", + "author": "Eficent, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse Management", "depends": ["stock", "stock_inventory_chatter"], "data": [ - 'views/stock_inventory_view.xml' + 'views/stock_inventory_view.xml', ], "license": "AGPL-3", 'installable': True, diff --git a/stock_inventory_exclude_sublocation/models/__init__.py b/stock_inventory_exclude_sublocation/models/__init__.py index eff36f793..35536816e 100644 --- a/stock_inventory_exclude_sublocation/models/__init__.py +++ b/stock_inventory_exclude_sublocation/models/__init__.py @@ -1,6 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - from . import stock_inventory diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py index 9d3492467..918addddb 100644 --- a/stock_inventory_exclude_sublocation/models/stock_inventory.py +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models +from odoo import fields, models class Inventory(models.Model): @@ -14,68 +13,78 @@ class Inventory(models.Model): track_visibility='onchange', readonly=True, states={'draft': [('readonly', False)]}) - @api.multi def _get_inventory_lines_values(self): - if self.exclude_sublocation: - domain = ' location_id = %s' - args = (tuple(self.location_id.ids),) + """This method is a copy of standard one but considering only the + current location. + WARNING: In case of excluding sublocations standard method + is overridden by this one.""" + if not self.exclude_sublocation: + # Early return if exclude_sublocation is not set + return super()._get_inventory_lines_values() - vals = [] - product_obj = self.env['product.product'] - # Empty recordset of products available in stock_quants - quant_products = self.env['product.product'] - # Empty recordset of products to filter - products_to_filter = self.env['product.product'] + # STAR OF MODIFIED CODE: + domain = ' location_id in %s' + args = (tuple(self.location_id.ids),) + # END OF MODIFIED CODE. - if self.company_id.id: - domain += ' AND company_id = %s' - args += (self.company_id.id,) - if self.partner_id: - domain += ' AND owner_id = %s' - args += (self.partner_id.id,) - if self.lot_id: - domain += ' AND lot_id = %s' - args += (self.lot_id.id,) - if self.product_id: - domain += ' AND product_id = %s' - args += (self.product_id.id,) - products_to_filter |= self.product_id - if self.package_id: - domain += ' AND package_id = %s' - args += (self.package_id.id,) - if self.category_id: - categ_products = product_obj.search( - [('categ_id', '=', self.category_id.id)]) - domain += ' AND product_id = ANY (%s)' - args += (categ_products.ids,) - products_to_filter |= categ_products + vals = [] + Product = self.env['product.product'] + # Empty recordset of products available in stock_quants + quant_products = self.env['product.product'] + # Empty recordset of products to filter + products_to_filter = self.env['product.product'] - # disable error about SQL injection as the code here is generating - # a vulnerability - # pylint: disable = E8103 - self.env.cr.execute( - "SELECT product_id, SUM(qty) AS product_qty, location_id, " - " lot_id AS prod_lot_id, package_id, owner_id AS partner_id " - "FROM stock_quant " - "WHERE " + domain + " " + - "GROUP BY product_id, location_id, lot_id, package_id, " - "partner_id """, args) + # case 0: Filter on company + if self.company_id: + domain += ' AND company_id = %s' + args += (self.company_id.id,) - for product_data in self.env.cr.dictfetchall(): - for void_field in [item[0] for item in product_data.items() if - item[1] is None]: - product_data[void_field] = False - product_data['theoretical_qty'] = product_data['product_qty'] - if product_data['product_id']: - product_data['product_uom_id'] = product_obj.browse( - product_data['product_id']).uom_id.id - quant_products |= product_obj.browse( - product_data['product_id']) - vals.append(product_data) - if self.exhausted: - exhausted_vals = self._get_exhausted_inventory_line( - products_to_filter, quant_products) - vals.extend(exhausted_vals) - return vals - else: - return super(Inventory, self)._get_inventory_lines_values() + # case 1: Filter on One owner only or One product for a specific owner + if self.partner_id: + domain += ' AND owner_id = %s' + args += (self.partner_id.id,) + # case 2: Filter on One Lot/Serial Number + if self.lot_id: + domain += ' AND lot_id = %s' + args += (self.lot_id.id,) + # case 3: Filter on One product + if self.product_id: + domain += ' AND product_id = %s' + args += (self.product_id.id,) + products_to_filter |= self.product_id + # case 4: Filter on A Pack + if self.package_id: + domain += ' AND package_id = %s' + args += (self.package_id.id,) + # case 5: Filter on One product category + Exahausted Products + if self.category_id: + categ_products = Product.search( + [('categ_id', '=', self.category_id.id)]) + domain += ' AND product_id = ANY (%s)' + args += (categ_products.ids,) + products_to_filter |= categ_products + + self.env.cr.execute(""" + SELECT product_id, sum(quantity) as product_qty, + location_id, lot_id as prod_lot_id, package_id, + owner_id as partner_id + FROM stock_quant + WHERE %s + GROUP BY product_id, location_id, lot_id, + package_id, partner_id """ % domain, args) + + for product_data in self.env.cr.dictfetchall(): + for void_field in [item[0] for item in product_data.items() if + item[1] is None]: + product_data[void_field] = False + product_data['theoretical_qty'] = product_data['product_qty'] + if product_data['product_id']: + product_data['product_uom_id'] = Product.browse( + product_data['product_id']).uom_id.id + quant_products |= Product.browse(product_data['product_id']) + vals.append(product_data) + if self.exhausted: + exhausted_vals = self._get_exhausted_inventory_line( + products_to_filter, quant_products) + vals.extend(exhausted_vals) + return vals diff --git a/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst b/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..7e28360de --- /dev/null +++ b/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Lois Rilo Antelo diff --git a/stock_inventory_exclude_sublocation/readme/DESCRIPTION.rst b/stock_inventory_exclude_sublocation/readme/DESCRIPTION.rst new file mode 100644 index 000000000..1175e27f7 --- /dev/null +++ b/stock_inventory_exclude_sublocation/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +This module extends the functionality of Inventory Adjustment to allow you to +exclude all the sublocations when doing an inventory adjustment for a +given location. + +Sometimes we just want to make an inventory adjustment of just one shelf, or +space and forget about extra subdivisions in the location. In other cases we +do inventories of smaller locations contained in our stock, so we don't want +to count them again when doing an inventory adjustment of the parent location. +E.g. if we apply a cycle count strategy. diff --git a/stock_inventory_exclude_sublocation/readme/USAGE.rst b/stock_inventory_exclude_sublocation/readme/USAGE.rst new file mode 100644 index 000000000..b1c26759c --- /dev/null +++ b/stock_inventory_exclude_sublocation/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you simply need to: + +#. Create a new inventory adjustment. +#. Select the option inventory of all products. +#. Check the box "Exclude Sublocations". diff --git a/stock_inventory_exclude_sublocation/tests/__init__.py b/stock_inventory_exclude_sublocation/tests/__init__.py index f2e05e912..2d88b76aa 100644 --- a/stock_inventory_exclude_sublocation/tests/__init__.py +++ b/stock_inventory_exclude_sublocation/tests/__init__.py @@ -1,6 +1 @@ -# -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - from . import test_exclude_sublocation diff --git a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py index 0fe5afbc2..2f3548240 100644 --- a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py +++ b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). @@ -104,7 +103,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase): if the excluding sublocations option is disabled.""" inventory_location = self._create_inventory_all_products( 'location inventory', self.location, False) - inventory_location.prepare_inventory() + inventory_location.action_start() inventory_location.action_done() lines = inventory_location.line_ids self.assertEqual(len(lines), 2, 'Not all expected products are ' @@ -117,9 +116,9 @@ class TestStockInventoryExcludeSublocation(TransactionCase): 'location inventory', self.location, True) inventory_sublocation = self._create_inventory_all_products( 'sublocation inventory', self.sublocation, True) - inventory_location.prepare_inventory() + inventory_location.action_start() inventory_location.action_done() - inventory_sublocation.prepare_inventory() + inventory_sublocation.action_start() inventory_sublocation.action_done() lines_location = inventory_location.line_ids lines_sublocation = inventory_sublocation.line_ids @@ -137,7 +136,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase): 'lot_id': self.lot_a.id, 'exclude_sublocation': True }) - inventory.prepare_inventory() + inventory.action_start() inventory.action_done() lines = inventory.line_ids self.assertEqual(len(lines), 1, 'The products in the sublocations are ' @@ -149,7 +148,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase): self.quant_model.create({ 'product_id': self.product1.id, 'location_id': self.location.id, - 'qty': 1, + 'quantity': 1, 'owner_id': self.partner, }) inventory = self.inventory_model.sudo(self.user.id).create({ @@ -160,7 +159,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase): 'partner_id': self.partner, 'exclude_sublocation': True }) - inventory.prepare_inventory() + inventory.action_start() lines = inventory.line_ids self.assertEqual(len(lines), 1, 'The products in the sublocations are ' @@ -171,7 +170,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase): self.quant_model.create({ 'product_id': self.product1.id, 'location_id': self.location.id, - 'qty': 1, + 'quantity': 1, 'package_id': self.package.id }) inventory = self.inventory_model.sudo(self.user.id).create({ @@ -181,7 +180,7 @@ class TestStockInventoryExcludeSublocation(TransactionCase): 'package_id': self.package.id, 'exclude_sublocation': True }) - inventory.prepare_inventory() + inventory.action_start() lines = inventory.line_ids self.assertEqual(len(lines), 1, 'The products in the sublocations are ' 'not excluded with package filter.') diff --git a/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml b/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml index c51b076b2..a0fb1b83e 100644 --- a/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml +++ b/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml @@ -5,7 +5,7 @@ - Inventory form view - cycle count extension + Inventory form view - stock_inventory_exclude_sublocation extension stock.inventory From 054a37c5ba8042767c053ffd3541a1410e331ee2 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Wed, 19 Sep 2018 09:22:07 +0000 Subject: [PATCH 08/23] [UPD] Update stock_inventory_exclude_sublocation.pot --- .../i18n/stock_inventory_exclude_sublocation.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot b/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot index b8af21560..02d7961b0 100644 --- a/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot +++ b/stock_inventory_exclude_sublocation/i18n/stock_inventory_exclude_sublocation.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" From 57d1bb3311e0d960d61a9cff805f98a2ba90ef78 Mon Sep 17 00:00:00 2001 From: OCA Git Bot Date: Thu, 20 Sep 2018 05:34:13 +0200 Subject: [PATCH 09/23] [UPD] README.rst --- .../README.rst | 10 +- .../static/description/index.html | 436 ++++++++++++++++++ 2 files changed, 443 insertions(+), 3 deletions(-) create mode 100644 stock_inventory_exclude_sublocation/static/description/index.html diff --git a/stock_inventory_exclude_sublocation/README.rst b/stock_inventory_exclude_sublocation/README.rst index 8b5f687e5..0ef81649a 100644 --- a/stock_inventory_exclude_sublocation/README.rst +++ b/stock_inventory_exclude_sublocation/README.rst @@ -16,11 +16,14 @@ Stock Inventory Exclude Sublocation .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github :target: https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_inventory_exclude_sublocation :alt: OCA/stock-logistics-warehouse -.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-11-0/stock-logistics-warehouse-11-0-stock_inventory_exclude_sublocation + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png :target: https://runbot.odoo-community.org/runbot/153/11.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| +|badge1| |badge2| |badge3| |badge4| |badge5| This module extends the functionality of Inventory Adjustment to allow you to exclude all the sublocations when doing an inventory adjustment for a @@ -51,7 +54,8 @@ 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. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. diff --git a/stock_inventory_exclude_sublocation/static/description/index.html b/stock_inventory_exclude_sublocation/static/description/index.html new file mode 100644 index 000000000..ba36f547d --- /dev/null +++ b/stock_inventory_exclude_sublocation/static/description/index.html @@ -0,0 +1,436 @@ + + + + + + +Stock Inventory Exclude Sublocation + + + +
+

Stock Inventory Exclude Sublocation

+ + +

Mature License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module extends the functionality of Inventory Adjustment to allow you to +exclude all the sublocations when doing an inventory adjustment for a +given location.

+

Sometimes we just want to make an inventory adjustment of just one shelf, or +space and forget about extra subdivisions in the location. In other cases we +do inventories of smaller locations contained in our stock, so we don’t want +to count them again when doing an inventory adjustment of the parent location. +E.g. if we apply a cycle count strategy.

+

Table of contents

+ +
+

Usage

+

To use this module, you simply need to:

+
    +
  1. Create a new inventory adjustment.
  2. +
  3. Select the option inventory of all products.
  4. +
  5. Check the box “Exclude Sublocations”.
  6. +
+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Eficent
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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-warehouse project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + From 0929983a78623945df84abdac10f250db5a69208 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 31 Jan 2019 17:25:37 +0100 Subject: [PATCH 10/23] [FIX+IMP] stock_inventory_exclude_sublocation: Don't mess inheritance It also includes the removal of an unneeded dependency + better position of the field in view --- .../README.rst | 1 + .../__manifest__.py | 8 +- .../models/stock_inventory.py | 86 +++---------------- .../static/description/index.html | 1 + .../views/stock_inventory_view.xml | 7 +- 5 files changed, 26 insertions(+), 77 deletions(-) diff --git a/stock_inventory_exclude_sublocation/README.rst b/stock_inventory_exclude_sublocation/README.rst index 0ef81649a..459f9ae46 100644 --- a/stock_inventory_exclude_sublocation/README.rst +++ b/stock_inventory_exclude_sublocation/README.rst @@ -66,6 +66,7 @@ Authors ~~~~~~~ * Eficent +* Tecnativa Contributors ~~~~~~~~~~~~ diff --git a/stock_inventory_exclude_sublocation/__manifest__.py b/stock_inventory_exclude_sublocation/__manifest__.py index 8fbb5a94c..133d69b48 100644 --- a/stock_inventory_exclude_sublocation/__manifest__.py +++ b/stock_inventory_exclude_sublocation/__manifest__.py @@ -1,17 +1,21 @@ # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) +# Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Stock Inventory Exclude Sublocation", "summary": "Allow to perform inventories of a location without including " "its child locations.", - "version": "11.0.1.0.0", + "version": "11.0.2.0.0", "development_status": "Mature", "author": "Eficent, " + "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse Management", - "depends": ["stock", "stock_inventory_chatter"], + "depends": [ + "stock", + ], "data": [ 'views/stock_inventory_view.xml', ], diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py index 918addddb..c242123d3 100644 --- a/stock_inventory_exclude_sublocation/models/stock_inventory.py +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -1,5 +1,6 @@ # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) +# Copyright 2019 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import fields, models @@ -14,77 +15,16 @@ class Inventory(models.Model): states={'draft': [('readonly', False)]}) def _get_inventory_lines_values(self): - """This method is a copy of standard one but considering only the - current location. - WARNING: In case of excluding sublocations standard method - is overridden by this one.""" + """Discard inventory lines that are from sublocations if option + is enabled. + + Done this way for maximizing inheritance compatibility. + """ + vals = super()._get_inventory_lines_values() if not self.exclude_sublocation: - # Early return if exclude_sublocation is not set - return super()._get_inventory_lines_values() - - # STAR OF MODIFIED CODE: - domain = ' location_id in %s' - args = (tuple(self.location_id.ids),) - # END OF MODIFIED CODE. - - vals = [] - Product = self.env['product.product'] - # Empty recordset of products available in stock_quants - quant_products = self.env['product.product'] - # Empty recordset of products to filter - products_to_filter = self.env['product.product'] - - # case 0: Filter on company - if self.company_id: - domain += ' AND company_id = %s' - args += (self.company_id.id,) - - # case 1: Filter on One owner only or One product for a specific owner - if self.partner_id: - domain += ' AND owner_id = %s' - args += (self.partner_id.id,) - # case 2: Filter on One Lot/Serial Number - if self.lot_id: - domain += ' AND lot_id = %s' - args += (self.lot_id.id,) - # case 3: Filter on One product - if self.product_id: - domain += ' AND product_id = %s' - args += (self.product_id.id,) - products_to_filter |= self.product_id - # case 4: Filter on A Pack - if self.package_id: - domain += ' AND package_id = %s' - args += (self.package_id.id,) - # case 5: Filter on One product category + Exahausted Products - if self.category_id: - categ_products = Product.search( - [('categ_id', '=', self.category_id.id)]) - domain += ' AND product_id = ANY (%s)' - args += (categ_products.ids,) - products_to_filter |= categ_products - - self.env.cr.execute(""" - SELECT product_id, sum(quantity) as product_qty, - location_id, lot_id as prod_lot_id, package_id, - owner_id as partner_id - FROM stock_quant - WHERE %s - GROUP BY product_id, location_id, lot_id, - package_id, partner_id """ % domain, args) - - for product_data in self.env.cr.dictfetchall(): - for void_field in [item[0] for item in product_data.items() if - item[1] is None]: - product_data[void_field] = False - product_data['theoretical_qty'] = product_data['product_qty'] - if product_data['product_id']: - product_data['product_uom_id'] = Product.browse( - product_data['product_id']).uom_id.id - quant_products |= Product.browse(product_data['product_id']) - vals.append(product_data) - if self.exhausted: - exhausted_vals = self._get_exhausted_inventory_line( - products_to_filter, quant_products) - vals.extend(exhausted_vals) - return vals + return vals + new_vals = [] + for val in vals: + if val['location_id'] == self.location_id.id: + new_vals.append(val) + return new_vals diff --git a/stock_inventory_exclude_sublocation/static/description/index.html b/stock_inventory_exclude_sublocation/static/description/index.html index ba36f547d..d92e92108 100644 --- a/stock_inventory_exclude_sublocation/static/description/index.html +++ b/stock_inventory_exclude_sublocation/static/description/index.html @@ -412,6 +412,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Authors

  • Eficent
  • +
  • Tecnativa
diff --git a/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml b/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml index a0fb1b83e..0a6d46d43 100644 --- a/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml +++ b/stock_inventory_exclude_sublocation/views/stock_inventory_view.xml @@ -1,5 +1,6 @@ @@ -9,8 +10,10 @@ stock.inventory - - + + From 4c12ac5f04bdb5b6b904d5931b3888966c081706 Mon Sep 17 00:00:00 2001 From: Bhavesh Odedra Date: Fri, 21 Jun 2019 17:34:21 +0530 Subject: [PATCH 11/23] [12.0][MIG] stock_inventory_exclude_sublocation: Migration to 12.0 --- .../README.rst | 11 +++--- .../__manifest__.py | 2 +- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 37 ++++--------------- .../tests/test_exclude_sublocation.py | 20 ++++++---- 5 files changed, 28 insertions(+), 43 deletions(-) diff --git a/stock_inventory_exclude_sublocation/README.rst b/stock_inventory_exclude_sublocation/README.rst index 459f9ae46..d2798da02 100644 --- a/stock_inventory_exclude_sublocation/README.rst +++ b/stock_inventory_exclude_sublocation/README.rst @@ -14,13 +14,13 @@ Stock Inventory Exclude Sublocation :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--warehouse-lightgray.png?logo=github - :target: https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_inventory_exclude_sublocation + :target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_inventory_exclude_sublocation :alt: OCA/stock-logistics-warehouse .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-11-0/stock-logistics-warehouse-11-0-stock_inventory_exclude_sublocation + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_inventory_exclude_sublocation :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/153/11.0 + :target: https://runbot.odoo-community.org/runbot/153/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -55,7 +55,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -72,6 +72,7 @@ Contributors ~~~~~~~~~~~~ * Lois Rilo Antelo +* Bhavesh Odedra Maintainers ~~~~~~~~~~~ @@ -86,6 +87,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-warehouse `_ project on GitHub. +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_inventory_exclude_sublocation/__manifest__.py b/stock_inventory_exclude_sublocation/__manifest__.py index 133d69b48..5f880b6f8 100644 --- a/stock_inventory_exclude_sublocation/__manifest__.py +++ b/stock_inventory_exclude_sublocation/__manifest__.py @@ -6,7 +6,7 @@ "name": "Stock Inventory Exclude Sublocation", "summary": "Allow to perform inventories of a location without including " "its child locations.", - "version": "11.0.2.0.0", + "version": "12.0.1.0.0", "development_status": "Mature", "author": "Eficent, " "Tecnativa, " diff --git a/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst b/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst index 7e28360de..77f4ab6c8 100644 --- a/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst +++ b/stock_inventory_exclude_sublocation/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Lois Rilo Antelo +* Bhavesh Odedra diff --git a/stock_inventory_exclude_sublocation/static/description/index.html b/stock_inventory_exclude_sublocation/static/description/index.html index d92e92108..f34c6137b 100644 --- a/stock_inventory_exclude_sublocation/static/description/index.html +++ b/stock_inventory_exclude_sublocation/static/description/index.html @@ -3,13 +3,13 @@ - + Stock Inventory Exclude Sublocation