Merge lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-location into lp:stock-logistic-warehouse

Proposed by Loïc Bellier - Numérigraphe
Status: Rejected
Rejected by: Pedro Manuel Baeza
Proposed branch: lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-location
Merge into: lp:stock-logistic-warehouse
Diff against target: 1703 lines (+1592/-0)
18 files modified
stock_inventory_location/__init__.py (+24/-0)
stock_inventory_location/__openerp__.py (+77/-0)
stock_inventory_location/exceptions.py (+26/-0)
stock_inventory_location/i18n/fr.po (+250/-0)
stock_inventory_location/i18n/stock_inventory_location.pot (+239/-0)
stock_inventory_location/stock_inventory_location.py (+353/-0)
stock_inventory_location/stock_inventory_location_demo.xml (+26/-0)
stock_inventory_location/stock_inventory_location_view.xml (+81/-0)
stock_inventory_location/tests/__init__.py (+39/-0)
stock_inventory_location/tests/inventory_exhaustive_test.yml (+128/-0)
stock_inventory_location/tests/inventory_future_test.yml (+13/-0)
stock_inventory_location/tests/inventory_standard_test.yml (+100/-0)
stock_inventory_location/tests/stock_inventory_location_test.py (+47/-0)
stock_inventory_location/wizard/__init__.py (+22/-0)
stock_inventory_location/wizard/stock_confirm_uninventoried_location.py (+69/-0)
stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml (+33/-0)
stock_inventory_location/wizard/stock_fill_location_inventory.py (+47/-0)
stock_inventory_location/wizard/stock_fill_location_inventory_view.xml (+18/-0)
To merge this branch: bzr merge lp:~numerigraphe-team/stock-logistic-warehouse/7.0-inventory-location
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp Needs Resubmitting
Lionel Sausin - Initiatives/Numérigraphe (community) i'm a contributor Abstain
Laetitia Gangloff (Acsone) (community) code, test, functional test Approve
Stock and Logistic Core Editors Pending
Review via email: mp+223880@code.launchpad.net

This proposal supersedes a proposal from 2014-03-12.

Description of the change

New version of the branch which only one location is permit by inventory to be inline with the v8.

This proposal feature obsoletes Tiny's "stock_alternative_inventory", and
implements exhaustive inventory in a much more practical way.

It lets you explicitly state which locations are being inventoried, and makes
sure the stock levels exactly reflect the physical inventory for those
locations.

It also checks that all locations been entered in the inventory lines,
and no other locations.

Finally it will block Stock Moves during the inventory, to keep
warehouse workers from changing the stock while the inventory is not
finished.

Thanks to Laetitia GANGLOFF of Acsone.eu for her help.

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : Posted in a previous version of this proposal

Hello,

Thanks for this contribution, the functionality is great and I'd love to see it in OCA. And thanks for including tests.

A few minor changes are needed to bring the module to the coding standards

* use orm.Model / orm.TransientModel as base classes instead of osv.osv and osv.osv_memory
* model column default values: in OpenERP 7.0, not need to use a lambda for a constant value, just use the constant

Additionally:

* in __openerp__.py, I think you should use 'Warehouse Management' for the category (i.e. the same one as the official 'stock' addon
* no space before '!' in english (I'd remove the exclamation marks in exception messages altogether, that the UI job to display an icon)
* in confirm_uninventoried_location_wizard: you should add a 'if context is None: context = {}' at the beginning.
* in confirm_uninventoried_locations: you are ignoring an osv_except exception. Could you add a comment in the code explaining why this is safe? If this is about the "No product in this location" warning raised in the reimplementation of _fill_location_lines, then I think a check that we are ignoring the correct exception should be added. You could for instance subclass except_osv and raise + ignore the subclass. Otherwise I think the code may hide things we do not want to hide (or even fail because of an except_osv

review: Needs Fixing (code review, test)
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : Posted in a previous version of this proposal

Recent developments in trunk-wms implement some features of this proposal but the implementation is different.
I suggest we refactor this proposal and the following patches, to make it easy to port the module to v8 later on.
- Add locations as many2one instead of one2many
  http://bazaar.launchpad.net/~openerp-dev/openobject-addons/trunk-wms/revision/9596
- forbid inventories in the future
  http://bazaar.launchpad.net/~openerp-dev/openobject-addons/trunk-wms/revision/9598

review: Needs Resubmitting
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote : Posted in a previous version of this proposal

Loïc and I are still working on this proposal. Good progress was made: we re-aligned the features with v8 in mind, and improved the code style and the views.
Acsone joined in and we're still making tests, and i hope Loïc can make a new proposal in the coming days.

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

Hello,

I see some little mistake that I correct in :
http://bazaar.launchpad.net/~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-fill2-lga/revision/40
http://bazaar.launchpad.net/~acsone-openerp/stock-logistic-warehouse/7.0-inventory-hierarchical-fill2-lga/revision/41

It seems I forgot to report them on this branch :(.

The most important of them is the second one.

The change is the following:

l.699 ids_to_check = ids
should be : ids_to_check = list(ids)

review: Needs Fixing
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

laetitia-gangloff you're right, Loïc had to split the proposal in 2 branches to make the review easier but I forgot to push back the fixes he an you made to the modules in this branch.
I'll fix it now.

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

laetitia-gangloff,
Can you please explain this change in your branch? I don't see the point because ids is already sure to be Iterable. Does it really have to be a list?

@@ -285,11 +285,11 @@
     def write(self, cr, uid, ids, vals, context=None):
         """Refuse write if an inventory is being conducted"""
         self._check_inventory(cr, uid, ids, context=context)
         if not isinstance(ids, Iterable):
             ids = [ids]
- ids_to_check = list(ids)
+ ids_to_check = ids
         # If changing the parent, no inventory must conducted there either
         if vals.get('location_id'):
             ids_to_check.append(vals['location_id'])
         self._check_inventory(cr, uid, ids_to_check, context=context)
         return super(StockLocation, self).write(cr, uid, ids, vals,

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

It is to avoid a "RuntimeError: maximum recursion depth exceeded" when change location_id.

ids was just assigned in ids_to_check so, when ids_to_check change, ids change too and the write is not done with right parameter, an we get the above error.

With list(ids) we create a new list, so ids and ids_to_check are not same.

41. By Laetitia Gangloff (Acsone)

[FIX] read inventories as superuser to allow the control on locations even when the user has no permission on inventories. Courtesy of ACSONE.

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

laetitia-gangloff, right you are again.
I propose to write it explicitly this way, is it OK for you?
        if not isinstance(ids, Iterable):
            ids_to_check = [ids]
        else:
            # Copy the date to avoid changing 'ids', it would trigger an infinite recursion
            ids_to_check = list(ids)

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

I meant "copy the datA", not "copy the date" of course...

42. By Laetitia Gangloff (Acsone)

[FIX] don't mutate the data received by the method, it causes an infinite recursion. Fix provided by ACSONE.

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

Your proposition is OK for me.

Maybe, can you take test of this problem ?

43. By Laetitia Gangloff (Acsone)

[FIX] missing test files from the previous fixes by ASCONE

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

l. 509/l. 516 : raise osv.except_osv

Is it not better to use orm.except_orm ?

Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

laetitia-gangloff: that part of the code was backported from trunk-wms at the time, and I wanted to ease the migration to v8.
But eventually Odoo's Quentin Di Paoli changed his mind about that feature and removed it from odoo/master. But he still uses osv.except_osv all over the WMS code.
So I have no idea what's best, opinions welcome.

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

Thank you for the explanation.
I have no idea what's best.

I retested this module and it seems now OK.

review: Approve (code, test, functional test)
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) :
review: Abstain (i'm a contributor)
44. By Laetitia Gangloff (Acsone)

[FIX] exhaustive was not passed to the wizard when emptying the locations that were not in the inventory

45. By Numérigraphe

[REF] remove TODO

46. By Laetitia Gangloff (Acsone)

[FIX] missing import

47. By Numérigraphe

[IMP] French translation

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

The source code management for this project has been moved to https://github.com/OCA/stock-logistics-warehouse

Could you resubmit this MP on the new site?

review: Needs Resubmitting
Revision history for this message
Lionel Sausin - Initiatives/Numérigraphe (ls-initiatives) wrote :

I've finally resubmitted this as part of the pull request at https://github.com/OCA/stock-logistics-warehouse/pull/17.
Please reject the merge proposal here to make it clear it won't be processed on Launchpad.

Unmerged revisions

47. By Numérigraphe

[IMP] French translation

46. By Laetitia Gangloff (Acsone)

[FIX] missing import

45. By Numérigraphe

[REF] remove TODO

44. By Laetitia Gangloff (Acsone)

[FIX] exhaustive was not passed to the wizard when emptying the locations that were not in the inventory

43. By Laetitia Gangloff (Acsone)

[FIX] missing test files from the previous fixes by ASCONE

42. By Laetitia Gangloff (Acsone)

[FIX] don't mutate the data received by the method, it causes an infinite recursion. Fix provided by ACSONE.

41. By Laetitia Gangloff (Acsone)

[FIX] read inventories as superuser to allow the control on locations even when the user has no permission on inventories. Courtesy of ACSONE.

40. By Numérigraphe

[FIX] wrong nesting in list comprehension

39. By Numérigraphe

[FIX] test and add a test for the refactored function

38. By Numérigraphe

[MERGE] only allow one location per inventory to make it easier to migrate to v8 when the time comes. code & views cleaned up.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'stock_inventory_location'
=== added file 'stock_inventory_location/__init__.py'
--- stock_inventory_location/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/__init__.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,24 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21import stock_inventory_location
22import wizard
23# Bring the main exception into the package's scope for easier reuse
24from .exceptions import ExhaustiveInventoryException
025
=== added file 'stock_inventory_location/__openerp__.py'
--- stock_inventory_location/__openerp__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/__openerp__.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,77 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21{
22 "name": "Exhaustive Stock Inventories",
23 "version": "1.1",
24 "depends": ["stock"],
25 "author": u"Numérigraphe",
26 "category": "Warehouse Management",
27 "description": """
28Let users make exhaustive Inventories
29=====================================
30
31Standard Physical Inventories in OpenERP only contain a generic list of
32products by locations, which is well suited to partial Inventories and simple
33warehouses. When the a standard Inventory is confirmed, only the products in
34the inventory are checked. If a Product is present in the computed stock and
35not in the recorded Inventory, OpenERP will consider that it remains unchanged.
36
37But for exhaustive inventories in complex warehouses, it is not practical:
38 - you want to avoid Stock Moves to/from these Locations while counting goods
39 - you must make sure all the locations you want have been counted
40 - you must make sure no other location has been counted by mistake
41 - you want the computed stock to perfectly match the inventory when you
42 confirm it.
43
44This module lets choose whether an Physical Inventory is exhaustive or
45standard.
46For an exhaustive Inventory:
47 - in the state "Draft" you define the Location where goods must be counted.
48 - the new Inventory status "Open" lets you indicate that the list of Locations
49 is final and you are now counting the goods.
50 In that status, no Stock Moves can be recorded in/out of the Inventory's
51 Locations.
52 - if the Location or some of it's children have not been entered in the
53 Inventory Lines, OpenERP warns you when you confirm the Inventory.
54 - only the Inventory's Location or its children can be entered in the
55 Inventory Lines.
56 - every good that is not in the Inventory Lines is considered lost, and gets
57 moved out of the stock when you confirm the Inventory.
58""",
59 "data": [
60 "wizard/stock_confirm_uninventoried_location.xml",
61 "stock_inventory_location_view.xml",
62 "wizard/stock_fill_location_inventory_view.xml",
63 ],
64 "test": [
65 "tests/inventory_standard_test.yml",
66 "tests/inventory_exhaustive_test.yml",
67 "tests/inventory_future_test.yml",
68 ],
69 "images": [
70 "images/inventory_form.png",
71 "inventory_empty_locations.png",
72 "images/move_error.png",
73 "images/location_locked.png",
74 "images/future_inventory.png",
75 ],
76 "demo": ["stock_inventory_location_demo.xml"]
77}
078
=== added file 'stock_inventory_location/exceptions.py'
--- stock_inventory_location/exceptions.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/exceptions.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,26 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from openerp.osv import orm
22
23
24class ExhaustiveInventoryException(orm.except_orm):
25 """The operation is not possible for an exhaustive inventory"""
26 pass
027
=== added directory 'stock_inventory_location/i18n'
=== added file 'stock_inventory_location/i18n/fr.po'
--- stock_inventory_location/i18n/fr.po 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/i18n/fr.po 2014-07-01 12:00:29 +0000
@@ -0,0 +1,250 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * stock_inventory_location
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-07-01 11:55+0000\n"
10"PO-Revision-Date: 2014-07-01 11:55+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: stock_inventory_location
19#: code:addons/stock_inventory_location/stock_inventory_location.py:345
20#: code:addons/stock_inventory_location/stock_inventory_location.py:346
21#, python-format
22msgid "A Physical Inventory is being conducted at the following location(s):\n"
23"%s"
24msgstr "Les emplacements suivants sont en inventaire :\n"
25"%s"
26
27#. module: stock_inventory_location
28#: code:addons/stock_inventory_location/stock_inventory_location.py:280
29#: code:addons/stock_inventory_location/stock_inventory_location.py:281
30#: constraint:stock.move:0
31#, python-format
32msgid "A Physical Inventory is being conducted at this location"
33msgstr "Un inventaire est en cours à cet emplacement"
34
35#. module: stock_inventory_location
36#: view:stock.inventory.uninventoried.locations:0
37msgid "Cancel"
38msgstr "Annuler"
39
40#. module: stock_inventory_location
41#: help:stock.inventory,exhaustive:0
42msgid "Check the box if you are conducting an exhaustive Inventory.\n"
43"Leave the box unchecked if you are conducting a standard Inventory (partial inventory for example).\n"
44"For an exhaustive Inventory:\n"
45" - the status \"Draft\" lets you define the list of Locations where goods must be counted\n"
46" - the status \"Open\" indicates that the list of Locations is definitive and you are now counting the goods. In that status, no Stock Moves can be recorded in/out of the Inventory's Locations\n"
47" - only the Inventory's Locations can be entered in the Inventory Lines\n"
48" - if some of the Inventory's Locations have not been entered in the Inventory Lines, OpenERP warns you when you confirm the Inventory\n"
49" - every good that is not in the Inventory Lines is considered lost, and gets moved out of the stock when you confirm the Inventory"
50msgstr "Cochez la case si vous effectuez un inventaire exhaustif.\n"
51"Laissez la case non-dochée si vous effectuez un inventaire standard (par exmple un inventaire partiel).\n"
52"Pour les inventaires exhaustifs :\n"
53" - le statut \"Brouillon\" permet d'indiquer la liste des emplacements dont la marchandise doit être comptée\n"
54" - le statut \"Ouvert\" indiqueque la liste des emplacements est définitive, et que le comptage est en cours. Dans ce statut, aucun mouvement de stock ne peut être enregistré depuis/vers les emplacements de l'inventaire\n"
55" - seuls les emplacements de l'inventaire peuvent être saisis dans les lignes d'inventaire\n"
56" - si certains emplacements sont absent des lignes d'inventaire, OpenERP vous en avertit lors de la confirmation de l'inventaire\n"
57" - toutes les marchandises qui ne sont pas dans les lignes d'inventaire sont considérées comme perdues, et sont supprimées lors de la confirmation de l'inventaire"
58
59#. module: stock_inventory_location
60#: view:stock.inventory.uninventoried.locations:0
61msgid "Confirm empty locations"
62msgstr "Confirmez les emplacements vides"
63
64#. module: stock_inventory_location
65#: code:_description:0
66#: model:ir.model,name:stock_inventory_location.model_stock_inventory_uninventoried_locations
67#, python-format
68msgid "Confirm the uninventoried Locations."
69msgstr "Confirmer les emplacements non inventoriés."
70
71#. module: stock_inventory_location
72#: code:addons/stock_inventory_location/stock_inventory_location.py:107
73#, python-format
74msgid "Error!"
75msgstr "Erreur!"
76
77#. module: stock_inventory_location
78#: code:addons/stock_inventory_location/stock_inventory_location.py:279
79#: code:addons/stock_inventory_location/stock_inventory_location.py:280
80#: code:addons/stock_inventory_location/stock_inventory_location.py:344
81#: code:addons/stock_inventory_location/stock_inventory_location.py:345
82#, python-format
83msgid "Error: Location locked down"
84msgstr "Erreur: emplacement en inventaire"
85
86#. module: stock_inventory_location
87#: field:stock.fill.inventory,exhaustive:0
88#: view:stock.inventory:0
89#: field:stock.inventory,exhaustive:0
90msgid "Exhaustive"
91msgstr "Exhaustif"
92
93#. module: stock_inventory_location
94#: view:stock.inventory.uninventoried.locations:0
95msgid "If you confirm the Inventory, these Locations will be considered empty and their content will be purged."
96msgstr "Si vous confirmez l'inventaire, ces emplacements seront considérés comme vides et leur contenu sera supprimé."
97
98#. module: stock_inventory_location
99#: code:_description:0
100#: model:ir.model,name:stock_inventory_location.model_stock_fill_inventory
101#, python-format
102msgid "Import Inventory"
103msgstr "Importer un inventaire"
104
105#. module: stock_inventory_location
106#: field:stock.inventory,location_id:0
107msgid "Inventoried Location"
108msgstr "Emplacement inventorié"
109
110#. module: stock_inventory_location
111#: code:_description:0
112#: model:ir.model,name:stock_inventory_location.model_stock_inventory
113#, python-format
114msgid "Inventory"
115msgstr "Inventaire"
116
117#. module: stock_inventory_location
118#: code:_description:0
119#: model:ir.model,name:stock_inventory_location.model_stock_inventory_line
120#, python-format
121msgid "Inventory Line"
122msgstr "Ligne d'inventaire"
123
124#. module: stock_inventory_location
125#: view:stock.inventory.uninventoried.locations:0
126msgid "It could either mean that the Locations are empty, or that the Inventory is not yet complete."
127msgstr "Cela peut vouloir dire soit que l'inventaire n'est pas terminé, soit que ces emplacements sont effectivement vides."
128
129#. module: stock_inventory_location
130#: code:addons/stock_inventory_location/stock_inventory_location.py:108
131#, python-format
132msgid "It's impossible to confirm an inventory in the future. Please change the inventory date to proceed further."
133msgstr "Il n'est pas possible de confirmer un inventaire à une date future. Veuillez changer la date de l'inventaire pour continuer."
134
135#. module: stock_inventory_location
136#: code:_description:0
137#: model:ir.model,name:stock_inventory_location.model_stock_location
138#, python-format
139msgid "Location"
140msgstr "Emplacement"
141
142#. module: stock_inventory_location
143#: code:addons/stock_inventory_location/wizard/stock_confirm_uninventoried_location.py:65
144#, python-format
145msgid "No product in this location. Please select a location in the product form."
146msgstr ""
147"Aucun article dans cet emplacement. Veuillez choisir un emplacement dans le "
148"formulaire produit."
149
150#. module: stock_inventory_location
151#: view:stock.inventory:0
152msgid "Only select exhaustive Inventories."
153msgstr "Ne sélectionne que les inventaires exhaustifs."
154
155#. module: stock_inventory_location
156#: view:stock.inventory:0
157msgid "Open Inventory"
158msgstr "Ouvrir l'inventaire"
159
160#. module: stock_inventory_location
161#: constraint:stock.inventory:0
162msgid "Other Physical inventories are being conducted using the same Locations."
163msgstr "Certains emplacements sont déjà dans un autre inventaire."
164
165#. module: stock_inventory_location
166#: view:stock.inventory.uninventoried.locations:0
167msgid "Purge contents and confirm Inventory"
168msgstr "Supprimer le contenu et confirmer l'inventaire"
169
170#. module: stock_inventory_location
171#: code:_description:0
172#: model:ir.model,name:stock_inventory_location.model_stock_move
173#, python-format
174msgid "Stock Move"
175msgstr "Mouvement de stock"
176
177#. module: stock_inventory_location
178#: view:stock.inventory.uninventoried.locations:0
179msgid "The following Locations are empty"
180msgstr "Les emplacements suivants sont vides"
181
182#. module: stock_inventory_location
183#: view:stock.inventory.uninventoried.locations:0
184msgid "The following Stock Locations are part of the current Physical Inventory, but no Inventory Line has been recorded for them."
185msgstr "Les emplacements suivants font partie de l'inventaire en cours, mais aucune ligne d'inventaire les concernant n'a été enregistrée."
186
187#. module: stock_inventory_location
188#: field:stock.inventory.uninventoried.locations,location_ids:0
189msgid "Uninventoried location"
190msgstr "Emplacements non inventoriés"
191
192#. module: stock_inventory_location
193#: code:addons/stock_inventory_location/stock_inventory_location.py:254
194#, python-format
195msgid "Warning: Wrong location"
196msgstr "Attention: emplacement incorrect"
197
198#. module: stock_inventory_location
199#: code:addons/stock_inventory_location/stock_inventory_location.py:255
200#, python-format
201msgid "You cannot record an Inventory Line for this Location.\n"
202"You must first add this Location to the list of affected Locations on the Inventory form."
203msgstr "Vous ne pouvez pas ajouter cet emplacement.\n"
204"Il ne fait pas partie de la liste des emplacements à inventorier"
205
206#. module: stock_inventory_location
207#: view:stock.inventory:0
208msgid "confirm_missing_locations"
209msgstr "confirm_missing_locations"
210
211#. module: stock_inventory_location
212#: view:stock.inventory:0
213msgid "draft,open,confirm"
214msgstr "draft,open,confirm"
215
216#. module: stock_inventory_location
217#: view:stock.inventory:0
218msgid "draft,open,confirm,done"
219msgstr "draft,open,confirm,done"
220
221#. module: stock_inventory_location
222#: view:stock.inventory:0
223msgid "onchange_location_id(parent.location_id, parent.exhaustive, location_id)"
224msgstr "onchange_location_id(parent.location_id, parent.exhaustive, location_id)"
225
226#. module: stock_inventory_location
227#: view:stock.inventory:0
228msgid "open"
229msgstr "open"
230
231#. module: stock_inventory_location
232#: view:stock.inventory.uninventoried.locations:0
233msgid "or"
234msgstr "ou"
235
236#. module: stock_inventory_location
237#: view:stock.inventory:0
238msgid "{'default_exhaustive': exhaustive}"
239msgstr "{'default_exhaustive': exhaustive}"
240
241#. module: stock_inventory_location
242#: view:stock.inventory:0
243msgid "{'location_id': location_id}"
244msgstr "{'location_id': location_id}"
245
246#. module: stock_inventory_location
247#: view:stock.fill.inventory:0
248msgid "{'readonly':[('exhaustive','=',True)]}"
249msgstr "{'readonly':[('exhaustive','=',True)]}"
250
0251
=== added file 'stock_inventory_location/i18n/stock_inventory_location.pot'
--- stock_inventory_location/i18n/stock_inventory_location.pot 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/i18n/stock_inventory_location.pot 2014-07-01 12:00:29 +0000
@@ -0,0 +1,239 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * stock_inventory_location
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-07-01 11:54+0000\n"
10"PO-Revision-Date: 2014-07-01 11:54+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: stock_inventory_location
19#: code:addons/stock_inventory_location/stock_inventory_location.py:345
20#: code:addons/stock_inventory_location/stock_inventory_location.py:346
21#, python-format
22msgid "A Physical Inventory is being conducted at the following location(s):\n"
23"%s"
24msgstr ""
25
26#. module: stock_inventory_location
27#: code:addons/stock_inventory_location/stock_inventory_location.py:280
28#: code:addons/stock_inventory_location/stock_inventory_location.py:281
29#: constraint:stock.move:0
30#, python-format
31msgid "A Physical Inventory is being conducted at this location"
32msgstr ""
33
34#. module: stock_inventory_location
35#: view:stock.inventory.uninventoried.locations:0
36msgid "Cancel"
37msgstr ""
38
39#. module: stock_inventory_location
40#: help:stock.inventory,exhaustive:0
41msgid "Check the box if you are conducting an exhaustive Inventory.\n"
42"Leave the box unchecked if you are conducting a standard Inventory (partial inventory for example).\n"
43"For an exhaustive Inventory:\n"
44" - the status \"Draft\" lets you define the list of Locations where goods must be counted\n"
45" - the status \"Open\" indicates that the list of Locations is definitive and you are now counting the goods. In that status, no Stock Moves can be recorded in/out of the Inventory's Locations\n"
46" - only the Inventory's Locations can be entered in the Inventory Lines\n"
47" - if some of the Inventory's Locations have not been entered in the Inventory Lines, OpenERP warns you when you confirm the Inventory\n"
48" - every good that is not in the Inventory Lines is considered lost, and gets moved out of the stock when you confirm the Inventory"
49msgstr ""
50
51#. module: stock_inventory_location
52#: view:stock.inventory.uninventoried.locations:0
53msgid "Confirm empty locations"
54msgstr ""
55
56#. module: stock_inventory_location
57#: code:_description:0
58#: model:ir.model,name:stock_inventory_location.model_stock_inventory_uninventoried_locations
59#, python-format
60msgid "Confirm the uninventoried Locations."
61msgstr ""
62
63#. module: stock_inventory_location
64#: code:addons/stock_inventory_location/stock_inventory_location.py:107
65#, python-format
66msgid "Error!"
67msgstr ""
68
69#. module: stock_inventory_location
70#: code:addons/stock_inventory_location/stock_inventory_location.py:279
71#: code:addons/stock_inventory_location/stock_inventory_location.py:280
72#: code:addons/stock_inventory_location/stock_inventory_location.py:344
73#: code:addons/stock_inventory_location/stock_inventory_location.py:345
74#, python-format
75msgid "Error: Location locked down"
76msgstr ""
77
78#. module: stock_inventory_location
79#: field:stock.fill.inventory,exhaustive:0
80#: view:stock.inventory:0
81#: field:stock.inventory,exhaustive:0
82msgid "Exhaustive"
83msgstr ""
84
85#. module: stock_inventory_location
86#: view:stock.inventory.uninventoried.locations:0
87msgid "If you confirm the Inventory, these Locations will be considered empty and their content will be purged."
88msgstr ""
89
90#. module: stock_inventory_location
91#: code:_description:0
92#: model:ir.model,name:stock_inventory_location.model_stock_fill_inventory
93#, python-format
94msgid "Import Inventory"
95msgstr ""
96
97#. module: stock_inventory_location
98#: field:stock.inventory,location_id:0
99msgid "Inventoried Location"
100msgstr ""
101
102#. module: stock_inventory_location
103#: code:_description:0
104#: model:ir.model,name:stock_inventory_location.model_stock_inventory
105#, python-format
106msgid "Inventory"
107msgstr ""
108
109#. module: stock_inventory_location
110#: code:_description:0
111#: model:ir.model,name:stock_inventory_location.model_stock_inventory_line
112#, python-format
113msgid "Inventory Line"
114msgstr ""
115
116#. module: stock_inventory_location
117#: view:stock.inventory.uninventoried.locations:0
118msgid "It could either mean that the Locations are empty, or that the Inventory is not yet complete."
119msgstr ""
120
121#. module: stock_inventory_location
122#: code:addons/stock_inventory_location/stock_inventory_location.py:108
123#, python-format
124msgid "It's impossible to confirm an inventory in the future. Please change the inventory date to proceed further."
125msgstr ""
126
127#. module: stock_inventory_location
128#: code:_description:0
129#: model:ir.model,name:stock_inventory_location.model_stock_location
130#, python-format
131msgid "Location"
132msgstr ""
133
134#. module: stock_inventory_location
135#: code:addons/stock_inventory_location/wizard/stock_confirm_uninventoried_location.py:65
136#, python-format
137msgid "No product in this location. Please select a location in the product form."
138msgstr ""
139
140#. module: stock_inventory_location
141#: view:stock.inventory:0
142msgid "Only select exhaustive Inventories."
143msgstr ""
144
145#. module: stock_inventory_location
146#: view:stock.inventory:0
147msgid "Open Inventory"
148msgstr ""
149
150#. module: stock_inventory_location
151#: constraint:stock.inventory:0
152msgid "Other Physical inventories are being conducted using the same Locations."
153msgstr ""
154
155#. module: stock_inventory_location
156#: view:stock.inventory.uninventoried.locations:0
157msgid "Purge contents and confirm Inventory"
158msgstr ""
159
160#. module: stock_inventory_location
161#: code:_description:0
162#: model:ir.model,name:stock_inventory_location.model_stock_move
163#, python-format
164msgid "Stock Move"
165msgstr ""
166
167#. module: stock_inventory_location
168#: view:stock.inventory.uninventoried.locations:0
169msgid "The following Locations are empty"
170msgstr ""
171
172#. module: stock_inventory_location
173#: view:stock.inventory.uninventoried.locations:0
174msgid "The following Stock Locations are part of the current Physical Inventory, but no Inventory Line has been recorded for them."
175msgstr ""
176
177#. module: stock_inventory_location
178#: field:stock.inventory.uninventoried.locations,location_ids:0
179msgid "Uninventoried location"
180msgstr ""
181
182#. module: stock_inventory_location
183#: code:addons/stock_inventory_location/stock_inventory_location.py:254
184#, python-format
185msgid "Warning: Wrong location"
186msgstr ""
187
188#. module: stock_inventory_location
189#: code:addons/stock_inventory_location/stock_inventory_location.py:255
190#, python-format
191msgid "You cannot record an Inventory Line for this Location.\n"
192"You must first add this Location to the list of affected Locations on the Inventory form."
193msgstr ""
194
195#. module: stock_inventory_location
196#: view:stock.inventory:0
197msgid "confirm_missing_locations"
198msgstr ""
199
200#. module: stock_inventory_location
201#: view:stock.inventory:0
202msgid "draft,open,confirm"
203msgstr ""
204
205#. module: stock_inventory_location
206#: view:stock.inventory:0
207msgid "draft,open,confirm,done"
208msgstr ""
209
210#. module: stock_inventory_location
211#: view:stock.inventory:0
212msgid "onchange_location_id(parent.location_id, parent.exhaustive, location_id)"
213msgstr ""
214
215#. module: stock_inventory_location
216#: view:stock.inventory:0
217msgid "open"
218msgstr ""
219
220#. module: stock_inventory_location
221#: view:stock.inventory.uninventoried.locations:0
222msgid "or"
223msgstr ""
224
225#. module: stock_inventory_location
226#: view:stock.inventory:0
227msgid "{'default_exhaustive': exhaustive}"
228msgstr ""
229
230#. module: stock_inventory_location
231#: view:stock.inventory:0
232msgid "{'location_id': location_id}"
233msgstr ""
234
235#. module: stock_inventory_location
236#: view:stock.fill.inventory:0
237msgid "{'readonly':[('exhaustive','=',True)]}"
238msgstr ""
239
0240
=== added directory 'stock_inventory_location/images'
=== added file 'stock_inventory_location/images/future_inventory.png'
1Binary files stock_inventory_location/images/future_inventory.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/future_inventory.png 2014-07-01 12:00:29 +0000 differ241Binary files stock_inventory_location/images/future_inventory.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/future_inventory.png 2014-07-01 12:00:29 +0000 differ
=== added file 'stock_inventory_location/images/inventory_empty_locations.png'
2Binary files stock_inventory_location/images/inventory_empty_locations.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_empty_locations.png 2014-07-01 12:00:29 +0000 differ242Binary files stock_inventory_location/images/inventory_empty_locations.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_empty_locations.png 2014-07-01 12:00:29 +0000 differ
=== added file 'stock_inventory_location/images/inventory_form.png'
3Binary files stock_inventory_location/images/inventory_form.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_form.png 2014-07-01 12:00:29 +0000 differ243Binary files stock_inventory_location/images/inventory_form.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/inventory_form.png 2014-07-01 12:00:29 +0000 differ
=== added file 'stock_inventory_location/images/location_locked.png'
4Binary files stock_inventory_location/images/location_locked.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/location_locked.png 2014-07-01 12:00:29 +0000 differ244Binary files stock_inventory_location/images/location_locked.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/location_locked.png 2014-07-01 12:00:29 +0000 differ
=== added file 'stock_inventory_location/images/move_error.png'
5Binary files stock_inventory_location/images/move_error.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/move_error.png 2014-07-01 12:00:29 +0000 differ245Binary files stock_inventory_location/images/move_error.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/images/move_error.png 2014-07-01 12:00:29 +0000 differ
=== added directory 'stock_inventory_location/static'
=== added directory 'stock_inventory_location/static/src'
=== added directory 'stock_inventory_location/static/src/img'
=== added file 'stock_inventory_location/static/src/img/icon.png'
6Binary files stock_inventory_location/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/static/src/img/icon.png 2014-07-01 12:00:29 +0000 differ246Binary files stock_inventory_location/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and stock_inventory_location/static/src/img/icon.png 2014-07-01 12:00:29 +0000 differ
=== added file 'stock_inventory_location/stock_inventory_location.py'
--- stock_inventory_location/stock_inventory_location.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/stock_inventory_location.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,353 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21import time
22from collections import Iterable
23
24from openerp.osv import orm, fields
25from openerp.tools.translate import _
26# The next 2 imports are only needed for a feature backported from trunk-wms
27# TODOv8! remove, feature is included upstream
28from openerp.osv import osv
29from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
30from openerp import SUPERUSER_ID
31
32from .exceptions import ExhaustiveInventoryException
33
34
35class StockInventory(orm.Model):
36 """Add locations to the inventories"""
37 _inherit = 'stock.inventory'
38
39 INVENTORY_STATE_SELECTION = [
40 ('draft', 'Draft'),
41 ('open', 'Open'),
42 ('done', 'Done'),
43 ('confirm', 'Confirmed'),
44 ('cancel', 'Cancelled')
45 ]
46
47 _columns = {
48 # TODO v8: should we use "confirm" instead of adding "open"?
49 'state': fields.selection(
50 INVENTORY_STATE_SELECTION, 'State', readonly=True, select=True),
51 # TODO v8: remove this, should not be needed anymore
52 # Make the inventory lines read-only in all states except "Open",
53 # to ensure that no unwanted Location can be inserted
54 'inventory_line_id': fields.one2many(
55 'stock.inventory.line', 'inventory_id', 'Inventory lines',
56 readonly=True, states={'open': [('readonly', False)]}),
57 # TODO v8: remove this, it's backported from v8
58 'location_id': fields.many2one(
59 'stock.location', 'Inventoried Location',
60 readonly=True, states={'draft': [('readonly', False)]}),
61 'exhaustive': fields.boolean(
62 'Exhaustive', readonly=True,
63 states={'draft': [('readonly', False)]},
64 help="Check the box if you are conducting an exhaustive "
65 "Inventory.\n"
66 "Leave the box unchecked if you are conducting a standard "
67 "Inventory (partial inventory for example).\n"
68 "For an exhaustive Inventory:\n"
69 " - the status \"Draft\" lets you define the list of "
70 "Locations where goods must be counted\n"
71 " - the status \"Open\" indicates that the list of Locations "
72 "is definitive and you are now counting the goods. In that "
73 "status, no Stock Moves can be recorded in/out of the "
74 "Inventory's Locations\n"
75 " - only the Inventory's Locations can be entered in the "
76 "Inventory Lines\n"
77 " - if some of the Inventory's Locations have not been "
78 "entered in the Inventory Lines, OpenERP warns you "
79 "when you confirm the Inventory\n"
80 " - every good that is not in the Inventory Lines is "
81 "considered lost, and gets moved out of the stock when you "
82 "confirm the Inventory"),
83 }
84
85 def action_open(self, cr, uid, ids, context=None):
86 """Change the state of the inventory to 'open'"""
87 return self.write(cr, uid, ids, {'state': 'open'}, context=context)
88
89 # TODO v8: remove this method? the feature looks already done upstream
90 def action_done(self, cr, uid, ids, context=None):
91 """
92 Don't allow to make an inventory with a date in the future.
93
94 This makes sure no stock moves will be introduced between the
95 moment you finish the inventory and the date of the Stock Moves.
96 Backported from trunk-wms:
97 revid:qdp-launchpad@openerp.com-20140317090656-o7lo22tzm8yuv3r8
98
99 @raise osv.except_osv:
100 We raise this exception on purpose instead of
101 ExhaustiveInventoryException to ensure forward-compatibility
102 with v8.
103 """
104 for inventory in self.browse(cr, uid, ids, context=None):
105 if inventory.date > time.strftime(DEFAULT_SERVER_DATETIME_FORMAT):
106 raise osv.except_osv(
107 _('Error!'),
108 _('It\'s impossible to confirm an inventory in the '
109 'future. Please change the inventory date to proceed '
110 'further.'))
111 return super(StockInventory, self).action_done(cr, uid, ids,
112 context=context)
113
114 # TODO: remove this in v8
115 def _default_location(self, cr, uid, ids, context=None):
116 """Default stock location
117
118 @return: id of the stock location of the first warehouse of the
119 default company"""
120 location_id = False
121 company_id = self.pool['res.company']._company_default_get(
122 cr, uid, 'stock.warehouse', context=context)
123 warehouse_id = self.pool['stock.warehouse'].search(
124 cr, uid, [('company_id', '=', company_id)], limit=1)
125 if warehouse_id:
126 location_id = self.pool['stock.warehouse'].read(
127 cr, uid, warehouse_id[0], ['lot_stock_id'])['lot_stock_id'][0]
128 return location_id
129
130 _defaults = {
131 'state': 'draft',
132 'exhaustive': False,
133 # TODO: remove this in v8
134 'location_id': _default_location,
135 }
136
137 def _check_location_free_from_inventories(self, cr, uid, ids):
138 """
139 Verify that no other Inventory is being conducted on the same locations
140
141 Open Inventories are matched using the exact Location IDs,
142 excluding children.
143 """
144 # We don't get a context because we're called from a _constraint
145 for inventory in self.browse(cr, uid, ids):
146 if not inventory.exhaustive:
147 # never block standard inventories
148 continue
149 if self.search(cr, uid,
150 [('location_id', '=', inventory.location_id.id),
151 ('id', '!=', inventory.id),
152 ('date', '=', inventory.date),
153 ('exhaustive', '=', True)]):
154 # Quit as soon as one offending inventory is found
155 return False
156 return True
157
158 _constraints = [
159 (_check_location_free_from_inventories,
160 'Other Physical inventories are being conducted using the same '
161 'Locations.',
162 ['location_id', 'date', 'exhaustive'])
163 ]
164
165 def _get_locations_open_inventories(self, cr, uid, context=None):
166 """IDs of location in open exhaustive inventories, with children"""
167 inv_ids = self.search(
168 cr, uid, [('state', '=', 'open'), ('exhaustive', '=', True)],
169 context=context)
170 if not inv_ids:
171 # Early exit if no match found
172 return []
173 # List the Locations - normally all exhaustive inventories have one
174 location_ids = [inventory.location_id.id
175 for inventory in self.browse(cr, uid, inv_ids,
176 context=context)]
177 # Extend to the children Locations
178 return self.pool['stock.location'].search(
179 cr, uid,
180 [('location_id', 'child_of', set(location_ids)),
181 ('usage', '=', 'internal')],
182 context=context)
183
184 def get_missing_locations(self, cr, uid, ids, context=None):
185 """Compute the list of location_ids which are missing from the lines
186
187 Here, "missing" means the location is the inventory's location or one
188 of it's children, and the inventory does not contain any line with
189 this location."""
190 inventories = self.browse(cr, uid, ids, context=context)
191 # Find the locations of the inventories
192 inv_location_ids = [i.location_id.id for i in inventories]
193 # Extend to the children locations
194 inv_location_ids = set(self.pool['stock.location'].search(
195 cr, uid, [
196 ('location_id', 'child_of', inv_location_ids),
197 ('usage', '=', 'internal')], context=context))
198 # Find the locations already recorded in inventory lines
199 line_locations_ids = set([l.location_id.id
200 for i in inventories
201 for l in i.inventory_line_id])
202 return list(inv_location_ids - line_locations_ids)
203
204 def confirm_missing_locations(self, cr, uid, ids, context=None):
205 """Open wizard to confirm empty locations on exhaustive inventories"""
206 for inventory in self.browse(cr, uid, ids, context=context):
207 if (self.get_missing_locations(cr, uid, ids, context=context)
208 and inventory.exhaustive):
209 return {
210 'type': 'ir.actions.act_window',
211 'view_type': 'form',
212 'view_mode': 'form',
213 'res_model': 'stock.inventory.uninventoried.locations',
214 'target': 'new',
215 'context': dict(context,
216 active_ids=ids,
217 active_id=ids[0]),
218 'nodestroy': True,
219 }
220 return self.action_confirm(cr, uid, ids, context=context)
221
222
223class StockInventoryLine(orm.Model):
224 """Only allow the Inventory's Locations"""
225
226 _inherit = 'stock.inventory.line'
227
228 def _default_stock_location(self, cr, uid, context=None):
229 res = super(StockInventoryLine, self)._default_stock_location(
230 cr, uid, context=context)
231 if context is None or not context.get('location_id', False):
232 return res
233 else:
234 return context['location_id']
235
236 _defaults = {
237 'location_id': _default_stock_location
238 }
239
240 def onchange_location_id(self, cr, uid, ids, inventory_location_id,
241 exhaustive, location_id, context=None):
242 """Warn if the new is not in the location list for this inventory."""
243 if not exhaustive:
244 # Don't check if partial inventory
245 return True
246
247 # search children of location
248 if location_id not in self.pool['stock.location'].search(
249 cr, uid, [('location_id', 'child_of', inventory_location_id)],
250 context=context):
251 return {
252 'value': {'location_id': False},
253 'warning': {
254 'title': _('Warning: Wrong location'),
255 'message': _(
256 "You cannot record an Inventory Line for this "
257 "Location.\n"
258 "You must first add this Location to the list of "
259 "affected Locations on the Inventory form.")}
260 }
261 return True
262
263
264class StockLocation(orm.Model):
265 """Refuse changes during exhaustive Inventories"""
266 _inherit = 'stock.location'
267 _order = 'name'
268
269 def _check_inventory(self, cr, uid, ids, context=None):
270 """Error if an exhaustive Inventory is being conducted here"""
271 inv_obj = self.pool['stock.inventory']
272 location_inventory_open_ids = inv_obj._get_locations_open_inventories(
273 cr, SUPERUSER_ID, context=context)
274 if not isinstance(ids, Iterable):
275 ids = [ids]
276 for inv_id in ids:
277 if inv_id in location_inventory_open_ids:
278 raise ExhaustiveInventoryException(
279 _('Error: Location locked down'),
280 _('A Physical Inventory is being conducted at this '
281 'location'))
282 return True
283
284 def write(self, cr, uid, ids, vals, context=None):
285 """Refuse write if an inventory is being conducted"""
286 self._check_inventory(cr, uid, ids, context=context)
287 if not isinstance(ids, Iterable):
288 ids_to_check = [ids]
289 else:
290 # Copy the data to avoid changing 'ids', it would trigger an infinite recursion
291 ids_to_check = list(ids)
292 # If changing the parent, no inventory must conducted there either
293 if vals.get('location_id'):
294 ids_to_check.append(vals['location_id'])
295 self._check_inventory(cr, uid, ids_to_check, context=context)
296 return super(StockLocation, self).write(cr, uid, ids, vals,
297 context=context)
298
299 def create(self, cr, uid, vals, context=None):
300 """Refuse create if an inventory is being conducted at the parent"""
301 self._check_inventory(cr, uid, vals.get('location_id'),
302 context=context)
303 return super(StockLocation, self).create(cr, uid, vals,
304 context=context)
305
306 def unlink(self, cr, uid, ids, context=None):
307 """Refuse unlink if an inventory is being conducted"""
308 self._check_inventory(cr, uid, ids, context=context)
309 return super(StockLocation, self).unlink(cr, uid, ids, context=context)
310
311
312class StockMove(orm.Model):
313 """Refuse Moves during exhaustive Inventories"""
314
315 _inherit = 'stock.move'
316
317 # TODOv7: adapt this to match trunk-wms
318 def _check_open_inventory_location(self, cr, uid, ids, context=None):
319 """
320 Check that the locations are not locked by an open inventory
321
322 Standard inventories are not checked.
323
324 @raise ExhaustiveInventoryException: an error is raised if locations
325 are locked, instead of returning False, in order to pass an
326 extensive error message back to users.
327 """
328 message = ""
329 inv_obj = self.pool['stock.inventory']
330 locked_location_ids = inv_obj._get_locations_open_inventories(
331 cr, SUPERUSER_ID, context=context)
332 if not locked_location_ids:
333 # Nothing to verify
334 return True
335 for move in self.browse(cr, uid, ids, context=context):
336 if (move.location_id.usage != 'inventory'
337 and move.location_dest_id.id in locked_location_ids):
338 message += " - %s\n" % (move.location_dest_id.name)
339 if (move.location_dest_id.usage != 'inventory'
340 and move.location_id.id in locked_location_ids):
341 message += " - %s\n" % (move.location_id.name)
342 if message:
343 raise ExhaustiveInventoryException(
344 _('Error: Location locked down'),
345 _('A Physical Inventory is being conducted at the following '
346 'location(s):\n%s') % message)
347 return True
348
349 _constraints = [
350 (_check_open_inventory_location,
351 "A Physical Inventory is being conducted at this location",
352 ['location_id', 'location_dest_id']),
353 ]
0354
=== added file 'stock_inventory_location/stock_inventory_location_demo.xml'
--- stock_inventory_location/stock_inventory_location_demo.xml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/stock_inventory_location_demo.xml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="0">
4 <!-- Record a non exhaustive inventory -->
5 <record id="inventory_standard" model="stock.inventory">
6 <field name="name">Standard inventory</field>
7 <field name="state">draft</field>
8 </record>
9
10 <!-- Record an exhaustive inventory -->
11 <record id="inventory_exhaustive" model="stock.inventory">
12 <field name="name">Exhaustive inventory</field>
13 <field name="state">draft</field>
14 <field name="exhaustive">True</field>
15 <field name="location_id" model="stock.location" search="[('name', '=', 'Shelf 2')]" />
16 </record>
17
18 <!-- Record an inventory dated in the future -->
19 <!-- TODOv8: remove this entry, only useful for a test already in trunk-wms -->
20 <record id="inventory_future" model="stock.inventory">
21 <field name="name">Inventory in the future</field>
22 <field name="state">draft</field>
23 <field name="date">2020-03-01 00:00:00</field>
24 </record>
25 </data>
26</openerp>
027
=== added file 'stock_inventory_location/stock_inventory_location_view.xml'
--- stock_inventory_location/stock_inventory_location_view.xml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/stock_inventory_location_view.xml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,81 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="stock_inventory_location_form_view">
6 <field name="name">stock.inventory.location.form</field>
7 <field name="model">stock.inventory</field>
8 <field name="inherit_id" ref="stock.view_inventory_form"/>
9 <field name="priority" eval="10"/>
10 <field name="arch" type="xml">
11 <!-- Show the state 'done' in the statusbar -->
12 <xpath expr="/form//field[@name='state']" position="attributes">
13 <attribute name="statusbar_visible">draft,open,confirm</attribute>
14 </xpath>
15
16 <!-- TODO v8 place "exhaustive" next to "location_id" -->
17 <!-- Add type of inventory: standard or exhaustive. -->
18 <xpath expr="/form//field[@name='name']" position="after">
19 <field name="exhaustive"/>
20 <field name="location_id" groups="stock.group_locations"
21 domain="[('usage','in',('view', 'internal'))]"
22 attrs="{'invisible':[('exhaustive','!=',True)], 'required':[('exhaustive','=',True)]}"/>
23 </xpath>
24
25 <!-- Enable Fill Inventory button when state is open -->
26 <xpath expr="//button[@string='Fill Inventory']" position="attributes">
27 <attribute name="states">open</attribute>
28 <attribute name="context">{'default_exhaustive': exhaustive}</attribute>
29 </xpath>
30
31 <!-- Control locations added by user on inventory line -->
32 <xpath expr="/form//field[@name='inventory_line_id']"
33 position="attributes">
34 <attribute name="context">{'location_id': location_id}</attribute>
35 </xpath>
36 <xpath expr="/form//field[@name='inventory_line_id']/tree//field[@name='location_id']"
37 position="attributes">
38 <attribute name="on_change">onchange_location_id(parent.location_id, parent.exhaustive, location_id)</attribute>
39 </xpath>
40 <xpath expr="/form//field[@name='inventory_line_id']/form//field[@name='location_id']"
41 position="attributes">
42 <attribute name="on_change">onchange_location_id(parent.location_id, parent.exhaustive, location_id)</attribute>
43 </xpath>
44
45 <!-- Add button to open an inventory. Call wizard on confirm inventory -->
46 <xpath expr="/form//button[@name='action_cancel_inventory']" position="before">
47 <button name="action_open" states="draft" string="Open Inventory" type="object" class="oe_highlight" groups="stock.group_stock_user"/>
48 </xpath>
49 <!-- Show the "cancel" button in state "open" -->
50 <xpath expr="/form//button[@name='action_cancel_inventory']" position="attributes">
51 <attribute name="states">draft,open,confirm,done</attribute>
52 </xpath>
53 <!-- hijack the "confirm" button -->
54 <xpath expr="/form//button[@name='action_confirm']" position="attributes">
55 <attribute name="states">open</attribute>
56 <attribute name="name">confirm_missing_locations</attribute>
57 </xpath>
58 </field>
59 </record>
60
61 <!-- Add filter for complete or partial inventory -->
62 <record model="ir.ui.view" id="view_inventory_complete_filter">
63 <field name="name">complete.inventory.filter</field>
64 <field name="model">stock.inventory</field>
65 <field name="inherit_id" ref="stock.view_inventory_filter"/>
66 <field name="arch" type="xml">
67 <xpath expr="//field[@name='name']" position="before">
68 <filter icon="terp-check" name="exhaustive" string="Exhaustive" domain="[('exhaustive', '=', True)]"
69 help="Only select exhaustive Inventories." />
70 <separator orientation="vertical"/>
71 </xpath>
72 </field>
73 </record>
74
75 <!-- Show exhaustive inventories by default -->
76 <record id="stock.action_inventory_form" model="ir.actions.act_window">
77 <field name="context">{'full':'1', 'search_default_exhaustive':1}</field>
78 </record>
79
80 </data>
81</openerp>
0\ No newline at end of file82\ No newline at end of file
183
=== added directory 'stock_inventory_location/tests'
=== added file 'stock_inventory_location/tests/__init__.py'
--- stock_inventory_location/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/__init__.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,39 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30import stock_inventory_location_test
31
32fast_suite = [
33]
34
35checks = [
36 stock_inventory_location_test,
37]
38
39# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
040
=== added file 'stock_inventory_location/tests/inventory_exhaustive_test.yml'
--- stock_inventory_location/tests/inventory_exhaustive_test.yml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/inventory_exhaustive_test.yml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,128 @@
1-
2 This file will test an exhaustive inventory.
3 I will call open_action method and check if state of inventories are 'open'.
4-
5 !python {model: stock.inventory}: |
6 self.action_open(cr, uid, [ref('inventory_exhaustive')])
7 inventory_state = self.read(cr, uid, [ref('inventory_exhaustive')], ['state'])[0]['state']
8 assert inventory_state == 'open', "Inventory in state '%s'. It should be 'open'" % inventory_state
9-
10 I will check that the function get_missing_locations return some locations.
11-
12 !python {model: stock.inventory}: |
13 missing_loc_ids = self.get_missing_locations(cr, uid, [ref('inventory_exhaustive')], context=context)
14 assert len(missing_loc_ids), "get_missing_locations did not return any ID."
15-
16 I create a wizard record for stock_confirm_uninventoried_location to verify that it contains the uninventoried locations
17-
18 !python {model: stock.inventory.uninventoried.locations}: |
19 ctx = dict(context, active_ids=[ref('inventory_exhaustive')])
20 wizard_id = self.create(cr, uid, {}, context=ctx)
21 wizard = self.browse(cr, uid, wizard_id, context=ctx)
22 assert len(wizard.location_ids) > 0 , "The wizard does not contain any lines."
23-
24 I add products to exhaustive inventory.
25 Adding 17” LCD Monitor.
26-
27 !record {model: stock.inventory.line, id: lines_inventory_location_pc1}:
28 product_id: product.product_product_7
29 product_uom: product.product_uom_unit
30 company_id: base.main_company
31 inventory_id: inventory_exhaustive
32 product_qty: 18.0
33 location_id: stock.stock_location_14
34
35-
36 Adding USB Keyboard, QWERTY.
37-
38 !record {model: stock.inventory.line, id: lines_inventory_location_pc3}:
39 product_id: product.product_product_8
40 product_uom: product.product_uom_unit
41 company_id: base.main_company
42 inventory_id: inventory_exhaustive
43 product_qty: 5.0
44 location_id: stock.stock_location_14
45
46-
47 I will call the function _get_locations_open_inventories and check the result.
48 The function will return only the location_id of the exhaustive inventory.
49-
50 !python {model: stock.inventory}: |
51 locations = self._get_locations_open_inventories(cr, uid)
52 assert len(locations) == 1, "Function return wrong results: %s" % locations
53 assert locations[0] == ref('stock.stock_location_14'), "Function '_get_locations_open_inventories' return wrong location_id. Should be '%s': '%s'" % (stock.stock_location_14, locations[0])
54-
55 I will call the function onchange_location_id.
56 The function must return True in the first case, and return a warning dictionnary in the second test.
57-
58 !python {model: stock.inventory.line}: |
59 res = self.onchange_location_id(cr, uid, [], ref('stock.stock_location_14'), True, ref('stock.stock_location_14'))
60 assert res == True, "Exhaustive: The function 'onchange_location_id' should return True and return '%s'" % res
61 res = self.onchange_location_id(cr, uid, [], ref('stock.stock_location_14'), True, ref('stock.stock_location_components'))
62 assert res.get('warning', False) != False , "Function 'onchange_location_id': Warning not raise. ('%s)" % res
63
64-
65 I will check that the function get_missing_locations does not return any locations.
66-
67 !python {model: stock.inventory}: |
68 missing_loc_ids = self.get_missing_locations(cr, uid, [ref('inventory_exhaustive')], context=context)
69 assert not missing_loc_ids, "get_missing_locations should not return IDs but returned %s" % missing_loc_ids
70-
71 I create a wizard record for stock_confirm_uninventoried_location and validate it
72-
73 !python {model: stock.inventory.uninventoried.locations}: |
74 ctx = dict(context, active_ids=[ref('inventory_exhaustive')])
75 wizard_id = self.create(cr, uid, {}, context=ctx)
76 wizard = self.browse(cr, uid, wizard_id, context=ctx)
77 assert len(wizard.location_ids) == 0 , "The wizard should not contain any lines but contains %s." % wizard.location_ids
78 self.confirm_uninventoried_locations(cr, uid, wizard_id, context=ctx)
79-
80 Stock moves are not allowed in the locations during the inventory.
81-
82 !python {model: stock.move}: |
83 # TODOv8: remove this test, this is already part of trunk-wms
84 from stock_inventory_location import ExhaustiveInventoryException
85 try:
86 self.create(
87 cr,uid, {
88 'name': 'Bad move',
89 'location_id': ref('stock.stock_location_14'),
90 'location_dest_id': ref('stock.stock_location_3'),
91 'product_id': ref('product.product_product_8'),
92 'product_uom': ref('product.product_uom_unit'),
93 'date_expected': '2020-01-01 00:00:00'
94 })
95 except ExhaustiveInventoryException as e:
96 log("Good! The Stock Move was refused: %s" % e)
97-
98 I will confirm the exhaustive inventory
99-
100 !python {model: stock.inventory}: |
101 self.action_confirm(cr, uid, [ref('inventory_exhaustive')])
102 inventory_state = self.read(cr, uid, [ref('inventory_exhaustive')], ['state'])[0]['state']
103 assert inventory_state == 'confirm', "Exhaustive inventory is in state '%s'. It should be 'confirm'" % inventory_state
104
105-
106 I will validate the exhaustive inventory
107-
108 !python {model: stock.inventory}: |
109 self.action_done(cr, uid, [ref('inventory_exhaustive')])
110 inventory_state = self.read(cr, uid, [ref('inventory_exhaustive')], ['state'])[0]['state']
111 assert inventory_state == 'done', "Exhaustive inventory is in state '%s'. It should be 'done'" % inventory_state
112
113-
114 I will verify the quantity for each products.
115-
116 !python {model: product.product}: |
117 ctx = dict(context, location=[ref('stock.stock_location_14')])
118 prod_qty_avail = self.read(cr, uid, [ref('product.product_product_7')], ['qty_available'], context=ctx)[0]['qty_available']
119 assert prod_qty_avail == 18.0, "The stock of PC1 was not set to 18.0: %s" % prod_qty_avail
120
121 prod_qty_avail = self.read(cr, uid, [ref('product.product_product_8')], ['qty_available'], context=ctx)[0]['qty_available']
122 assert prod_qty_avail == 5.0, "The stock of PC3 was not set to 5.0: %s" % prod_qty_avail
123
124 prod_qty_avail = self.read(cr, uid, [ref('product.product_product_24')], ['qty_available'], context=ctx)[0]['qty_available']
125 assert prod_qty_avail == 0.0, "The stock of KEYA was not set to 0: %s" % prod_qty_avail
126
127 prod_qty_avail = self.read(cr, uid, [ref('product.product_product_25')], ['qty_available'], context=ctx)[0]['qty_available']
128 assert prod_qty_avail == 0.0, "The stock of MOU was not set to 0: %s" % prod_qty_avail
0129
=== added file 'stock_inventory_location/tests/inventory_future_test.yml'
--- stock_inventory_location/tests/inventory_future_test.yml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/inventory_future_test.yml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,13 @@
1-
2 Check that an inventory with a date in the future cannot be opened.
3-
4 !python {model: stock.inventory}: |
5 # TODO v8: maybe this is already part of the new WMS
6 from osv.osv import except_osv
7 self.action_open(cr, uid, [ref('inventory_future')])
8 try:
9 self.action_done(cr, uid, [ref('inventory_future')])
10 except except_osv as e:
11 log("Good! The Inventory could not be opened: %s" % e)
12 inventory_state = self.read(cr, uid, [ref('inventory_future')], ['state'])[0]['state']
13 assert inventory_state != 'done', "Future inventory is done."
014
=== added file 'stock_inventory_location/tests/inventory_standard_test.yml'
--- stock_inventory_location/tests/inventory_standard_test.yml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/inventory_standard_test.yml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,100 @@
1-
2 This file will test a non exhaustive inventory.
3 I will call open_action method and check if state of inventories are 'open'.
4-
5 !python {model: stock.inventory}: |
6 self.action_open(cr, uid, [ref('inventory_standard')])
7 inventory_state = self.read(cr, uid, [ref('inventory_standard')], ['state'])[0]['state']
8 assert inventory_state == 'open', "Partial inventory have '%s' state. It should be 'open'" % inventory_state
9
10-
11 In order, I add products to inventory.
12 Adding Azerty Keyboard.
13-
14 !record {model: stock.inventory.line, id: lines_inventory_location_kbaz}:
15 product_id: product.product_product_9
16 product_uom: product.product_uom_unit
17 company_id: base.main_company
18 inventory_id: inventory_standard
19 product_qty: 18.0
20 location_id: stock.stock_location_components
21
22-
23 Adding Optical Mouse.
24-
25 !record {model: stock.inventory.line, id: lines_inventory_location_optm}:
26 product_id: product.product_product_10
27 product_uom: product.product_uom_unit
28 company_id: base.main_company
29 inventory_id: inventory_standard
30 product_qty: 12.0
31 location_id: stock.stock_location_components
32
33-
34 Adding Multimedia Speakers.
35-
36 !record {model: stock.inventory.line, id: lines_inventory_location_grca}:
37 product_id: product.product_template_31
38 product_uom: product.product_uom_unit
39 company_id: base.main_company
40 inventory_id: inventory_standard
41 product_qty: 32.0
42 location_id: stock.stock_location_components
43
44-
45 I will call the function _get_locations_open_inventories and check the result.
46 The function will return no locations because it's not an exhaustive inventory.
47-
48 !python {model: stock.inventory}: |
49 locations = self._get_locations_open_inventories(cr, uid)
50 assert len(locations) == 0, "Function return wrong results: %s" % locations
51
52-
53 I will call the function onchange_location_id.
54 The function must to return true in all test case.
55-
56 !python {model: stock.inventory.line}: |
57 res = self.onchange_location_id(cr, uid, [], [(6,0,[ref('stock.stock_location_components')])], False, ref('stock.stock_location_components'))
58 assert res == True, "The function 'onchange_location_id' should return True and return '%s'" % res
59 res = self.onchange_location_id(cr, uid, [], [(6,0,[ref('stock.stock_location_components')])], False, ref('stock.stock_location_14'))
60 assert res == True, "The function 'onchange_location_id' should return True and return '%s'" % res
61
62-
63 I will call the function _check_inventory.
64 The function must return True in all test cases.
65-
66 !python {model: stock.location}: |
67 res = self._check_inventory(cr, uid, ref('stock.stock_location_components'))
68 assert res == True, "The function '_check_inventory' should return True and return '%s'" % res
69 res = self._check_inventory(cr, uid, ref('stock.stock_location_14'))
70 assert res == True, "The function '_check_inventory' should return True and return '%s'" % res
71
72-
73 I will confirm inventory.
74-
75 !python {model: stock.inventory}: |
76 self.action_confirm(cr, uid, [ref('inventory_standard')])
77 inventory_state = self.read(cr, uid, [ref('inventory_standard')], ['state'])[0]['state']
78 assert inventory_state == 'confirm', "Partial inventory have '%s' state. It should be 'confirm'" % inventory_state
79
80-
81 I will validate inventory
82-
83 !python {model: stock.inventory}: |
84 self.action_done(cr, uid, [ref('inventory_standard')])
85 inventory_state = self.read(cr, uid, [ref('inventory_standard')], ['state'])[0]['state']
86 assert inventory_state == 'done', "Partial inventory have '%s' state. It should be 'done'" % inventory_state
87
88-
89 I will verify the quantity for each products.
90-
91 !python {model: product.product}: |
92 ctx={'location': [ref('stock.stock_location_components')]}
93 prod_qty_avail = self.read(cr, uid, [ref('product.product_product_9')], ['qty_available'], context=ctx)[0]['qty_available']
94 assert prod_qty_avail == 18.0, "The stock of CPU1 was not set to 18.0: %s" % prod_qty_avail
95
96 prod_qty_avail = self.read(cr, uid, [ref('product.product_product_10')], ['qty_available'], context=ctx)[0]['qty_available']
97 assert prod_qty_avail == 12.0, "The stock of CPU3 was not set to 12.0: %s" % prod_qty_avail
98
99 prod_qty_avail = self.read(cr, uid, [ref('product.product_template_31')], ['qty_available'], context=ctx)[0]['qty_available']
100 assert prod_qty_avail == 32.0, "The stock of FAN was not set to 32.0: %s" % prod_qty_avail
0101
=== added file 'stock_inventory_location/tests/stock_inventory_location_test.py'
--- stock_inventory_location/tests/stock_inventory_location_test.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/tests/stock_inventory_location_test.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,47 @@
1# -*- coding: utf-8 -*-
2#
3#
4# Authors: Laetitia Gangloff
5# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
6# All Rights Reserved
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsibility of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs.
11# End users who are looking for a ready-to-use solution with commercial
12# guarantees and support are strongly advised to contact a Free Software
13# Service Company.
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU Affero General Public License as
17# published by the Free Software Foundation, either version 3 of the
18# License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28#
29
30import openerp.tests.common as common
31
32DB = common.DB
33ADMIN_USER_ID = common.ADMIN_USER_ID
34
35
36class stock_inventory_location_test(common.TransactionCase):
37
38 def setUp(self):
39 super(stock_inventory_location_test, self).setUp()
40
41 def test_update_parent_location(self):
42 """
43 Test the update of the parent of a location (no inventory in progress
44 """
45 self.registry('stock.location').write(self.cr, self.uid, self.ref('stock.stock_location_5'), {'location_id': self.ref('stock.stock_location_4')})
46
47# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
048
=== added directory 'stock_inventory_location/wizard'
=== added file 'stock_inventory_location/wizard/__init__.py'
--- stock_inventory_location/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/wizard/__init__.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-1
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21import stock_fill_location_inventory
22import stock_confirm_uninventoried_location
023
=== added file 'stock_inventory_location/wizard/stock_confirm_uninventoried_location.py'
--- stock_inventory_location/wizard/stock_confirm_uninventoried_location.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/wizard/stock_confirm_uninventoried_location.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,69 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from openerp.tools.translate import _
22from openerp.osv import fields, orm, osv
23
24
25class stock_inventory_uninventoried_location(orm.TransientModel):
26 _name = 'stock.inventory.uninventoried.locations'
27 _description = 'Confirm the uninventoried Locations.'
28
29 _columns = {
30 'location_ids': fields.many2many(
31 'stock.location',
32 'stock_inventory_uninventoried_location_rel',
33 'location_id', 'wizard_id',
34 'Uninventoried location', readonly=True),
35 }
36
37 def default_locations(self, cr, uid, context=None):
38 """Initialize view with the list of uninventoried locations."""
39 return self.pool['stock.inventory'].get_missing_locations(
40 cr, uid, context['active_ids'], context=context)
41
42 _defaults = {
43 'location_ids': default_locations,
44 }
45
46 def confirm_uninventoried_locations(self, cr, uid, ids, context=None):
47 """Add the missing inventory lines with qty=0 and confirm inventory"""
48 inventory_ids = context['active_ids']
49 inventory_obj = self.pool['stock.inventory']
50 wizard_obj = self.pool['stock.fill.inventory']
51 for inventory in inventory_obj.browse(cr, uid, inventory_ids,
52 context=context):
53 if inventory.exhaustive:
54 # silently run the import wizard with qty=0
55 try:
56 # on parent inventory it is possible that fill inventory fail with no product
57 wizard_id = wizard_obj.create(
58 cr, uid, {'location_id': inventory.location_id.id,
59 'recursive': True,
60 'set_stock_zero': True,
61 'exhaustive': True}, context=context)
62 wizard_obj.fill_inventory(cr, uid, [wizard_id],
63 context=context)
64 except osv.except_osv, e:
65 if e.value == _('No product in this location. Please select a location in the product form.'):
66 pass
67
68 inventory_obj.action_confirm(cr, uid, inventory_ids, context=context)
69 return {'type': 'ir.actions.act_window_close'}
070
=== added file 'stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml'
--- stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/wizard/stock_confirm_uninventoried_location.xml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,33 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <!-- The view definition is similar with stock_inventory_hierarchical_location/wizard/stock_inventory_missing_locations_view.xml,
5 but the code is different.
6 This wizard compare declared locations with locations on inventory lines to present the uninventoried (empty) locations to user. -->
7 <record id="view_confirm_uninventoried_location" model="ir.ui.view">
8 <field name="name">stock.inventory.uninventoried.locations.form</field>
9 <field name="model">stock.inventory.uninventoried.locations</field>
10 <field name="arch" type="xml">
11 <form string="Confirm empty locations" version="7.0">
12 <group colspan="4" col="1">
13 <separator string="The following Locations are empty"/>
14 <label string="The following Stock Locations are part of the current Physical Inventory, but no Inventory Line has been recorded for them."/>
15 <label string="It could either mean that the Locations are empty, or that the Inventory is not yet complete."/>
16 <label string="If you confirm the Inventory, these Locations will be considered empty and their content will be purged."/>
17 <field name="location_ids" nolabel="1">
18 <tree>
19 <field name="name"/>
20 </tree>
21 </field>
22 <separator string=""/>
23 </group>
24 <footer>
25 <button name="confirm_uninventoried_locations" string="Purge contents and confirm Inventory" type="object" class="oe_highlight"/>
26 or
27 <button string="Cancel" class="oe_link" special="cancel" default_focus="1"/>
28 </footer>
29 </form>
30 </field>
31 </record>
32 </data>
33</openerp>
0\ No newline at end of file34\ No newline at end of file
135
=== added file 'stock_inventory_location/wizard/stock_fill_location_inventory.py'
--- stock_inventory_location/wizard/stock_fill_location_inventory.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/wizard/stock_fill_location_inventory.py 2014-07-01 12:00:29 +0000
@@ -0,0 +1,47 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# This module is copyright (C) 2013 Numérigraphe SARL. All Rights Reserved.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from openerp.osv import fields, orm
22
23
24class FillInventoryWizard(orm.TransientModel):
25 """Add a field that lets the client make the location read-only"""
26 _inherit = 'stock.fill.inventory'
27
28 _columns = {
29 'exhaustive': fields.boolean('Exhaustive', readonly=True)
30 }
31
32 def default_get(self, cr, uid, fields, context=None):
33 """Get 'location_id' and 'exhaustive' from the inventory"""
34 if context is None:
35 context = {}
36 inv_id = context.get('active_id')
37
38 res = super(FillInventoryWizard, self).default_get(
39 cr, uid, fields, context=context)
40 if (context.get('active_model') == 'stock.inventory'
41 and inv_id
42 and 'location_id' in fields):
43 inventory = self.pool['stock.inventory'].browse(
44 cr, uid, context['active_id'], context=context)
45 res.update({'location_id': inventory.location_id.id,
46 'exhaustive': inventory.exhaustive})
47 return res
048
=== added file 'stock_inventory_location/wizard/stock_fill_location_inventory_view.xml'
--- stock_inventory_location/wizard/stock_fill_location_inventory_view.xml 1970-01-01 00:00:00 +0000
+++ stock_inventory_location/wizard/stock_fill_location_inventory_view.xml 2014-07-01 12:00:29 +0000
@@ -0,0 +1,18 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="view_stock_fill_inventory_location" model="ir.ui.view">
5 <field name="name">Import Inventory</field>
6 <field name="model">stock.fill.inventory</field>
7 <field name="inherit_id" ref="stock.view_stock_fill_inventory" />
8 <field name="arch" type="xml">
9 <xpath expr="//field[@name='location_id']" position="after">
10 <field name="exhaustive" invisible="1" />
11 </xpath>
12 <xpath expr="//field[@name='location_id']" position="attributes">
13 <attribute name="attrs">{'readonly':[('exhaustive','=',True)]}</attribute>
14 </xpath>
15 </field>
16 </record>
17 </data>
18</openerp>