[IMP] stock_inventory_preparation_filter: Preparation for OCA

This commit is contained in:
Pedro M. Baeza
2015-06-27 20:42:48 +02:00
committed by Ivàn Todorovich
parent 90cd216a32
commit 00ec84b832
13 changed files with 821 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
.. 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
========================================
More preparation filters for inventories
========================================
Includes more options for making an inventory out of:
* Multiple products.
* Products of a category.
* Multiple lots
It also allows to make an inventory based on scanned products, adding a line
with product code and quantity.
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/153/8.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/stock-logistics-warehouse/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
<https://github.com/OCA/
stock-logistics-warehouse/issues/new?body=module:%20
stock_inventory_preparation_filter%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
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.

View File

@@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################
from . import models

View File

@@ -0,0 +1,41 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################
{
"name": "Extended Inventory Preparation Filters",
"version": "8.0.1.0.0",
"depends": [
"stock",
],
"author": "OdooMRP team,"
"AvanzOSC,"
"Serv. Tecnol. Avanzados - Pedro M. Baeza,"
"Odoo Community Association (OCA)",
"contributors": [
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
],
"category": "Inventory, Logistic, Storage",
"website": "http://www.odoomrp.com",
"summary": "More filters for inventory adjustments",
"data": [
"views/stock_inventory_view.xml",
"security/ir.model.access.csv",
],
"installable": True,
}

View File

@@ -0,0 +1,113 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_inventory_preparation_filters
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-07-30 08:59+0000\n"
"PO-Revision-Date: 2014-07-30 11:01+0100\n"
"Last-Translator: Oihane <oihanecruce@gmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: stock_inventory_preparation_filters
#: view:stock.inventory:0
#: field:stock.inventory,empty_line_ids:0
msgid "Capture Lines"
msgstr "Líneas capturadas"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,categ_ids:0
msgid "Categories"
msgstr "Categorias"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,create_uid:0
msgid "Created by"
msgstr "Creado por"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,create_date:0
msgid "Created on"
msgstr "Creado el"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:66
#, python-format
msgid "Empty list"
msgstr "Lista vacía"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,id:0
msgid "ID"
msgstr "ID"
#. module: stock_inventory_preparation_filters
#: model:ir.model,name:stock_inventory_preparation_filters.model_stock_inventory
#: field:stock.inventory.line.empty,inventory_id:0
msgid "Inventory"
msgstr "Inventario"
#. module: stock_inventory_preparation_filters
#: view:stock.inventory:0
msgid "Inventory Details"
msgstr "Detalles del inventario"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,write_uid:0
msgid "Last Updated by"
msgstr "Actualizado por"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,write_date:0
msgid "Last Updated on"
msgstr "Actualizado el"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,lot_ids:0
msgid "Lots"
msgstr "Lotes"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,product_code:0
msgid "Product Code"
msgstr "Codigo de producto"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,product_ids:0
msgid "Products"
msgstr "Productos"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,product_qty:0
msgid "Quantity"
msgstr "Cantidad"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:61
#, python-format
msgid "Selected Categories"
msgstr "Categorias seleccionadas"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:65
#, python-format
msgid "Selected Lots"
msgstr "Lotes seleccionados"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:62
#, python-format
msgid "Selected Products"
msgstr "Productos seleccionados"
#. module: stock_inventory_preparation_filters
#: model:ir.model,name:stock_inventory_preparation_filters.model_stock_inventory_line_empty
msgid "stock.inventory.line.empty"
msgstr "stock.inventory.line.empty"

View File

@@ -0,0 +1,112 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_inventory_preparation_filters
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-07-30 08:59+0000\n"
"PO-Revision-Date: 2015-06-27 11:09+0100\n"
"Last-Translator: Antoine Morit <amorit@team-dsi.fr>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 1.5.4\n"
#. module: stock_inventory_preparation_filters
#: view:stock.inventory:0 field:stock.inventory,empty_line_ids:0
msgid "Capture Lines"
msgstr "Lignes extraites"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,categ_ids:0
msgid "Categories"
msgstr "Catégories"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,create_uid:0
msgid "Created by"
msgstr "Créé par"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,create_date:0
msgid "Created on"
msgstr "Créé le"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:66
#, python-format
msgid "Empty list"
msgstr "Liste vide"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,id:0
msgid "ID"
msgstr "ID"
#. module: stock_inventory_preparation_filters
#: model:ir.model,name:stock_inventory_preparation_filters.model_stock_inventory
#: field:stock.inventory.line.empty,inventory_id:0
msgid "Inventory"
msgstr "Inventaire"
#. module: stock_inventory_preparation_filters
#: view:stock.inventory:0
msgid "Inventory Details"
msgstr "Détails de l'inventaire"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,write_uid:0
msgid "Last Updated by"
msgstr "Dernière màj par"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,write_date:0
msgid "Last Updated on"
msgstr "Dernière màj le"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,lot_ids:0
msgid "Lots"
msgstr "Lots"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,product_code:0
msgid "Product Code"
msgstr "Code produit"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,product_ids:0
msgid "Products"
msgstr "Produits"
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,product_qty:0
msgid "Quantity"
msgstr "Quantité"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:61
#, python-format
msgid "Selected Categories"
msgstr "Catégories sélectionnées"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:65
#, python-format
msgid "Selected Lots"
msgstr "Lots sélectionnés"
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:62
#, python-format
msgid "Selected Products"
msgstr "Produits sélectionnés"
#. module: stock_inventory_preparation_filters
#: model:ir.model,name:stock_inventory_preparation_filters.model_stock_inventory_line_empty
msgid "stock.inventory.line.empty"
msgstr "stock.inventory.line.empty"

View File

@@ -0,0 +1,113 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_inventory_preparation_filters
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-07-30 08:58+0000\n"
"PO-Revision-Date: 2014-07-30 08:58+0000\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_preparation_filters
#: view:stock.inventory:0
#: field:stock.inventory,empty_line_ids:0
msgid "Capture Lines"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,categ_ids:0
msgid "Categories"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,create_uid:0
msgid "Created by"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,create_date:0
msgid "Created on"
msgstr ""
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:66
#, python-format
msgid "Empty list"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,id:0
msgid "ID"
msgstr ""
#. module: stock_inventory_preparation_filters
#: model:ir.model,name:stock_inventory_preparation_filters.model_stock_inventory
#: field:stock.inventory.line.empty,inventory_id:0
msgid "Inventory"
msgstr ""
#. module: stock_inventory_preparation_filters
#: view:stock.inventory:0
msgid "Inventory Details"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,lot_ids:0
msgid "Lots"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,product_code:0
msgid "Product Code"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory,product_ids:0
msgid "Products"
msgstr ""
#. module: stock_inventory_preparation_filters
#: field:stock.inventory.line.empty,product_qty:0
msgid "Quantity"
msgstr ""
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:61
#, python-format
msgid "Selected Categories"
msgstr ""
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:65
#, python-format
msgid "Selected Lots"
msgstr ""
#. module: stock_inventory_preparation_filters
#: code:addons/stock_inventory_preparation_filters/models/stock_inventory.py:62
#, python-format
msgid "Selected Products"
msgstr ""
#. module: stock_inventory_preparation_filters
#: model:ir.model,name:stock_inventory_preparation_filters.model_stock_inventory_line_empty
msgid "stock.inventory.line.empty"
msgstr ""

View File

@@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################
from . import stock_inventory

View File

@@ -0,0 +1,133 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################
from openerp import models, fields, api, _
class StockInventoryEmptyLines(models.Model):
_name = 'stock.inventory.line.empty'
product_code = fields.Char(
string='Product Code', size=64, required=True)
product_qty = fields.Float(
string='Quantity', required=True, default=1.0)
inventory_id = fields.Many2one(
comodel_name='stock.inventory', string='Inventory',
required=True, ondelete="cascade")
class StockInventoryFake(object):
def __init__(self, inventory, product=None, lot=None):
self.id = inventory.id
self.location_id = inventory.location_id
self.product_id = product
self.lot_id = lot
self.partner_id = inventory.partner_id
self.package_id = inventory.package_id
class StockInventory(models.Model):
_inherit = 'stock.inventory'
@api.model
def _get_available_filters(self):
"""This function will return the list of filters allowed according to
the options checked in 'Settings/Warehouse'.
:return: list of tuple
"""
res_filters = super(StockInventory, self)._get_available_filters()
res_filters.append(('categories', _('Selected Categories')))
res_filters.append(('products', _('Selected Products')))
for res_filter in res_filters:
if res_filter[0] == 'lot':
res_filters.append(('lots', _('Selected Lots')))
res_filters.append(('empty', _('Empty list')))
return res_filters
filter = fields.Selection(
selection=_get_available_filters, string='Selection Filter',
required=True)
categ_ids = fields.Many2many(
comodel_name='product.category', relation='rel_inventories_categories',
column1='inventory_id', column2='category_id', string='Categories')
product_ids = fields.Many2many(
comodel_name='product.product', relation='rel_inventories_products',
column1='inventory_id', column2='product_id', string='Products')
lot_ids = fields.Many2many(
comodel_name='stock.production.lot', relation='rel_inventories_lots',
column1='inventory_id', column2='lot_id', string='Lots')
empty_line_ids = fields.One2many(
comodel_name='stock.inventory.line.empty', inverse_name='inventory_id',
string='Capture Lines')
@api.model
def _get_inventory_lines(self, inventory):
vals = []
product_tmpl_obj = self.env['product.template']
product_obj = self.env['product.product']
if inventory.filter in ('categories', 'products'):
products = product_obj
if inventory.filter == 'categories':
product_tmpls = product_tmpl_obj.search(
[('categ_id', 'in', inventory.categ_ids.ids)])
products = product_obj.search(
[('product_tmpl_id', 'in', product_tmpls.ids)])
elif inventory.filter == 'products':
products = inventory.product_ids
for product in products:
fake_inventory = StockInventoryFake(inventory, product=product)
vals += super(StockInventory, self)._get_inventory_lines(
fake_inventory)
elif inventory.filter == 'lots':
for lot in inventory.lot_ids:
fake_inventory = StockInventoryFake(inventory, lot=lot)
vals += super(StockInventory, self)._get_inventory_lines(
fake_inventory)
elif inventory.filter == 'empty':
tmp_lines = {}
empty_line_obj = self.env['stock.inventory.line.empty']
for line in inventory.empty_line_ids:
if line.product_code in tmp_lines:
tmp_lines[line.product_code] += line.product_qty
else:
tmp_lines[line.product_code] = line.product_qty
inventory.empty_line_ids.unlink()
for product_code in tmp_lines.keys():
products = product_obj.search(
[('default_code', '=', product_code)])
if products:
product = products[0]
fake_inventory = StockInventoryFake(
inventory, product=product)
values = super(StockInventory, self)._get_inventory_lines(
fake_inventory)
if values:
values[0]['product_qty'] = tmp_lines[product_code]
else:
empty_line_obj.create(
{
'product_code': product_code,
'product_qty': tmp_lines[product_code],
'inventory_id': inventory.id,
})
vals += values
else:
vals = super(StockInventory, self)._get_inventory_lines(
inventory)
return vals

View File

@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_stock_inventory_line_empty_user,access_stock_inventory_line_empty_user,model_stock_inventory_line_empty,stock.group_stock_user,1,0,0,0
access_stock_inventory_line_empty_manager,access_stock_inventory_line_empty_manager,model_stock_inventory_line_empty,stock.group_stock_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_stock_inventory_line_empty_user access_stock_inventory_line_empty_user model_stock_inventory_line_empty stock.group_stock_user 1 0 0 0
3 access_stock_inventory_line_empty_manager access_stock_inventory_line_empty_manager model_stock_inventory_line_empty stock.group_stock_manager 1 1 1 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,17 @@
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import test_stock_inventory_preparation_filter

View File

@@ -0,0 +1,147 @@
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import openerp.tests.common as common
class TestStockInventoryPreparationFilterCategories(common.TransactionCase):
def setUp(self):
super(TestStockInventoryPreparationFilterCategories, self).setUp()
self.inventory_model = self.env['stock.inventory']
# Create a category
self.category = self.env['product.category'].create(
{
'name': 'Category for inventory',
'type': 'normal',
})
# Create some products in the category
self.product1 = self.env['product.product'].create(
{
'name': 'Product for inventory 1',
'type': 'product',
'categ_id': self.category.id,
'default_code': 'PROD1',
}
)
self.product2 = self.env['product.product'].create(
{
'name': 'Product for inventory 2',
'type': 'product',
'categ_id': self.category.id,
'default_code': 'PROD2',
}
)
# And have some stock in a location
self.location = self.env['stock.location'].create(
{
'name': 'Inventory tests',
'usage': 'internal',
}
)
inventory = self.inventory_model.create(
{
'name': 'Product1 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,
}),
(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.location.id,
}),
],
})
inventory.action_done()
def test_inventory_category_filter(self):
inventory = self.inventory_model.create(
{
'name': 'Category inventory',
'filter': 'categories',
'location_id': self.location.id,
'categ_ids': [(6, 0, [self.category.id])],
}
)
inventory.prepare_inventory()
self.assertEqual(len(inventory.line_ids), 2)
line1 = inventory.line_ids[0]
self.assertEqual(line1.product_id, self.product1)
self.assertEqual(line1.theoretical_qty, 2.0)
self.assertEqual(line1.location_id, self.location)
line2 = inventory.line_ids[1]
self.assertEqual(line2.product_id, self.product2)
self.assertEqual(line2.theoretical_qty, 4.0)
self.assertEqual(line2.location_id, self.location)
def test_inventory_products_filter(self):
inventory = self.inventory_model.create(
{
'name': 'Products inventory',
'filter': 'products',
'location_id': self.location.id,
'product_ids': [(6, 0, [self.product1.id, self.product2.id])],
}
)
inventory.prepare_inventory()
self.assertEqual(len(inventory.line_ids), 2)
line1 = inventory.line_ids[0]
self.assertEqual(line1.product_id, self.product1)
self.assertEqual(line1.theoretical_qty, 2.0)
self.assertEqual(line1.location_id, self.location)
line2 = inventory.line_ids[1]
self.assertEqual(line2.product_id, self.product2)
self.assertEqual(line2.theoretical_qty, 4.0)
self.assertEqual(line2.location_id, self.location)
def test_inventory_empty_filter(self):
inventory = self.inventory_model.create(
{
'name': 'Products inventory',
'filter': 'empty',
'location_id': self.location.id,
'empty_line_ids': [
(0, 0, {
'product_code': 'PROD1',
'product_qty': 3.0,
}),
(0, 0, {
'product_code': 'PROD2',
'product_qty': 7.0,
}),
],
}
)
inventory.prepare_inventory()
self.assertEqual(len(inventory.line_ids), 2)
line1 = inventory.line_ids[0]
self.assertEqual(line1.product_id, self.product1)
self.assertEqual(line1.theoretical_qty, 2.0)
self.assertEqual(line1.product_qty, 3.0)
self.assertEqual(line1.location_id, self.location)
line2 = inventory.line_ids[1]
self.assertEqual(line2.product_id, self.product2)
self.assertEqual(line2.theoretical_qty, 4.0)
self.assertEqual(line2.product_qty, 7.0)
self.assertEqual(line2.location_id, self.location)

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="stock_inventory_form">
<field name="name">stock.inventory.form</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form" />
<field name="arch" type="xml">
<data>
<notebook position="attributes">
<attribute name="attrs" />
</notebook>
<page string="Inventory Details" position="attributes">
<attribute name="attrs">{'invisible':[('state','=','draft')]}</attribute>
</page>
<notebook position="before">
<group>
<field name="categ_ids"
nolabel="1"
attrs="{'invisible':[('filter','!=','categories')]}" />
<field name="product_ids"
nolabel="1"
attrs="{'invisible':[('filter','!=','products')]}" />
<field name="lot_ids"
nolabel="1"
attrs="{'invisible':[('filter','!=','lots')]}" />
</group>
</notebook>
<notebook position="inside">
<page string="Capture Lines"
attrs="{'invisible':[('filter','!=','empty')]}">
<field name="empty_line_ids" nolabel="1">
<tree editable="bottom">
<field name="product_code"/>
<field name="product_qty"/>
</tree>
</field>
</page>
</notebook>
</data>
</field>
</record>
</data>
</openerp>