forked from OCA/stock-logistics-warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.0][ADD] stock_inventory_exclude_sublocation (OCA#240)
* [ADD] stock_inventory_exclude_sublocation
- Loading branch information
1 parent
2a81300
commit 3687c41
Showing
15 changed files
with
572 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
<https://github.com/OCA/{project_repo}/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Lois Rilo Antelo <[email protected]> | ||
|
||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_inventory_exclude_sublocation | ||
# | ||
# Translators: | ||
# OCA Transbot <[email protected]>, 2017 | ||
# Rudolf Schnapka <[email protected]>, 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 <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_inventory_exclude_sublocation | ||
# | ||
# Translators: | ||
# OCA Transbot <[email protected]>, 2017 | ||
# Fernando Lara <[email protected]>, 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 <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>, 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 <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_inventory_exclude_sublocation | ||
# | ||
# Translators: | ||
# OCA Transbot <[email protected]>, 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 <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_inventory_exclude_sublocation | ||
# | ||
# Translators: | ||
# Paolo Valier <[email protected]>, 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 <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_inventory_exclude_sublocation | ||
# | ||
# Translators: | ||
# Felipe Lopes <[email protected]>, 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 <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_inventory_exclude_sublocation | ||
# | ||
# Translators: | ||
# Matjaž Mozetič <[email protected]>, 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č <[email protected]>, 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
53 changes: 53 additions & 0 deletions
53
stock_inventory_exclude_sublocation/models/stock_inventory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.