Merge lp:~unifield-team/unifield-addons/unisup-adjustment-move-report into lp:unifield-addons

Proposed by Quentin THEURET @Amaris
Status: Merged
Merged at revision: 4455
Proposed branch: lp:~unifield-team/unifield-addons/unisup-adjustment-move-report
Merge into: lp:unifield-addons
Diff against target: 717 lines (+674/-0)
8 files modified
stock_inventory_type/__init__.py (+28/-0)
stock_inventory_type/__openerp__.py (+50/-0)
stock_inventory_type/security/ir.model.access.csv (+2/-0)
stock_inventory_type/stock.py (+133/-0)
stock_inventory_type/stock_data.xml (+23/-0)
stock_inventory_type/stock_move_report.py (+128/-0)
stock_inventory_type/stock_view.xml (+193/-0)
stock_inventory_type/test/adjustment_type.yml (+117/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-addons/unisup-adjustment-move-report
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+53456@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'stock_inventory_type'
2=== added file 'stock_inventory_type/__init__.py'
3--- stock_inventory_type/__init__.py 1970-01-01 00:00:00 +0000
4+++ stock_inventory_type/__init__.py 2011-03-15 15:12:37 +0000
5@@ -0,0 +1,28 @@
6+#!/usr/bin/env python
7+# -*- encoding: utf-8 -*-
8+##############################################################################
9+#
10+# OpenERP, Open Source Management Solution
11+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as
15+# published by the Free Software Foundation, either version 3 of the
16+# License, or (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+
29+import stock
30+import stock_move_report
31+
32+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
33+
34
35=== added file 'stock_inventory_type/__openerp__.py'
36--- stock_inventory_type/__openerp__.py 1970-01-01 00:00:00 +0000
37+++ stock_inventory_type/__openerp__.py 2011-03-15 15:12:37 +0000
38@@ -0,0 +1,50 @@
39+# -*- coding: utf-8 -*-
40+##############################################################################
41+#
42+# OpenERP, Open Source Management Solution
43+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
44+#
45+# This program is free software: you can redistribute it and/or modify
46+# it under the terms of the GNU Affero General Public License as
47+# published by the Free Software Foundation, either version 3 of the
48+# License, or (at your option) any later version.
49+#
50+# This program is distributed in the hope that it will be useful,
51+# but WITHOUT ANY WARRANTY; without even the implied warranty of
52+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53+# GNU Affero General Public License for more details.
54+#
55+# You should have received a copy of the GNU Affero General Public License
56+# along with this program. If not, see <http://www.gnu.org/licenses/>.
57+#
58+##############################################################################
59+{
60+ "name" : "Stock Adjustment/Move Report",
61+ "version" : "1.0",
62+ "author" : "TeMPO Consulting, MSF",
63+ "category": "Inventory Control",
64+ "description": """
65+ This module aims to help you to determine the type \
66+ of your inventory adjustment and to search stock move \
67+ by type of adjustment.
68+ """,
69+ "website": "http://unifield.msf.org",
70+ "init_xml": [
71+ ],
72+ "depends" : [
73+ "stock",
74+ ],
75+ "update_xml": [
76+ "stock_view.xml",
77+ "stock_data.xml",
78+ "security/ir.model.access.csv",
79+ ],
80+ "demo_xml": [
81+ "test/adjustment_type.yml",
82+ ],
83+ "test": [
84+ "test/adjustment_type.yml",
85+ ],
86+ "installable": True,
87+ "active": False,
88+}
89
90=== added directory 'stock_inventory_type/security'
91=== added file 'stock_inventory_type/security/ir.model.access.csv'
92--- stock_inventory_type/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
93+++ stock_inventory_type/security/ir.model.access.csv 2011-03-15 15:12:37 +0000
94@@ -0,0 +1,2 @@
95+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
96+"access_stock_adjustment_type_all","stock.adjustment.type all","model_stock_adjustment_type",,1,1,1,1
97
98=== added file 'stock_inventory_type/stock.py'
99--- stock_inventory_type/stock.py 1970-01-01 00:00:00 +0000
100+++ stock_inventory_type/stock.py 2011-03-15 15:12:37 +0000
101@@ -0,0 +1,133 @@
102+#!/usr/bin/env python
103+# -*- encoding: utf-8 -*-
104+##############################################################################
105+#
106+# OpenERP, Open Source Management Solution
107+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
108+#
109+# This program is free software: you can redistribute it and/or modify
110+# it under the terms of the GNU Affero General Public License as
111+# published by the Free Software Foundation, either version 3 of the
112+# License, or (at your option) any later version.
113+#
114+# This program is distributed in the hope that it will be useful,
115+# but WITHOUT ANY WARRANTY; without even the implied warranty of
116+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+# GNU Affero General Public License for more details.
118+#
119+# You should have received a copy of the GNU Affero General Public License
120+# along with this program. If not, see <http://www.gnu.org/licenses/>.
121+#
122+##############################################################################
123+
124+
125+from osv import osv
126+from osv import fields
127+
128+from tools.translate import _
129+
130+
131+class stock_adjustment_type(osv.osv):
132+ _name = 'stock.adjustment.type'
133+ _description = 'Inventory/Move Adjustment Types'
134+
135+ _columns = {
136+ 'name': fields.char(size=64, string='Name', required=True),
137+ }
138+
139+stock_adjustment_type()
140+
141+
142+class stock_inventory_line(osv.osv):
143+ _name = 'stock.inventory.line'
144+ _inherit = 'stock.inventory.line'
145+
146+ _columns = {
147+ 'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type'),
148+ 'comment': fields.char(size=128, string='Comment'),
149+ }
150+
151+stock_inventory_line()
152+
153+
154+class stock_move(osv.osv):
155+ _name = 'stock.move'
156+ _inherit = 'stock.move'
157+
158+ _columns = {
159+ 'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type', readonly=True),
160+ 'comment': fields.char(size=128, string='Comment'),
161+ }
162+
163+stock_move()
164+
165+
166+class stock_inventory(osv.osv):
167+ _name = 'stock.inventory'
168+ _inherit = 'stock.inventory'
169+
170+ def action_confirm(self, cr, uid, ids, context={}):
171+ """ Confirm the inventory and writes its finished date
172+ @return True
173+ """
174+ # to perform the correct inventory corrections we need analyze stock location by
175+ # location, never recursively, so we use a special context
176+ product_context = dict(context, compute_child=False)
177+
178+ location_obj = self.pool.get('stock.location')
179+ for inv in self.browse(cr, uid, ids, context=context):
180+ move_ids = []
181+ for line in inv.inventory_line_id:
182+ pid = line.product_id.id
183+ product_context.update(uom=line.product_uom.id,date=inv.date)
184+ amount = location_obj._product_get(cr, uid, line.location_id.id, [pid], product_context)[pid]
185+
186+ change = line.product_qty - amount
187+ lot_id = line.prod_lot_id.id
188+ type_id = line.type_id.id
189+ if change:
190+ location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
191+ value = {
192+ 'name': 'INV:' + str(line.inventory_id.id) + ':' + line.inventory_id.name,
193+ 'product_id': line.product_id.id,
194+ 'product_uom': line.product_uom.id,
195+ 'prodlot_id': lot_id,
196+ 'date': inv.date,
197+ # @@@override@ stock.stock_inventory.action_confirm()
198+ 'comment': line.comment,
199+ # @@@end
200+ }
201+ if change > 0:
202+ value.update( {
203+ 'product_qty': change,
204+ 'location_id': location_id,
205+ 'location_dest_id': line.location_id.id,
206+ })
207+ else:
208+ value.update( {
209+ 'product_qty': -change,
210+ 'location_id': line.location_id.id,
211+ 'location_dest_id': location_id,
212+ })
213+ if lot_id:
214+ value.update({
215+ 'prodlot_id': lot_id,
216+ 'product_qty': line.product_qty
217+ })
218+ # @@@override@ stock.stock_inventory.action_confirm()
219+ if type_id:
220+ value.update({
221+ 'type_id': type_id,
222+ })
223+ # @@@end
224+ move_ids.append(self._inventory_line_hook(cr, uid, line, value))
225+ message = _('Inventory') + " '" + inv.name + "' "+ _("is done.")
226+ self.log(cr, uid, inv.id, message)
227+ self.write(cr, uid, [inv.id], {'state': 'confirm', 'move_ids': [(6, 0, move_ids)]})
228+
229+ return True
230+
231+stock_inventory()
232+
233+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
234+
235
236=== added file 'stock_inventory_type/stock_data.xml'
237--- stock_inventory_type/stock_data.xml 1970-01-01 00:00:00 +0000
238+++ stock_inventory_type/stock_data.xml 2011-03-15 15:12:37 +0000
239@@ -0,0 +1,23 @@
240+<?xml version="1.0" encoding="utf-8" ?>
241+<openerp>
242+ <data>
243+
244+ <record id="adjustment_type_loss" model="stock.adjustment.type">
245+ <field name="name">Loss</field>
246+ </record>
247+
248+ <record id="adjustment_type_scrap" model="stock.adjustment.type">
249+ <field name="name">Scrap</field>
250+ </record>
251+
252+ <record id="adjustment_type_expired" model="stock.adjustment.type">
253+ <field name="name">Expired</field>
254+ </record>
255+
256+ <record id="adjustment_type_broken" model="stock.adjustment.type">
257+ <field name="name">Broken</field>
258+ </record>
259+
260+ </data>
261+</openerp>
262+
263
264=== added file 'stock_inventory_type/stock_move_report.py'
265--- stock_inventory_type/stock_move_report.py 1970-01-01 00:00:00 +0000
266+++ stock_inventory_type/stock_move_report.py 2011-03-15 15:12:37 +0000
267@@ -0,0 +1,128 @@
268+# -*- coding: utf-8 -*-
269+##############################################################################
270+#
271+# OpenERP, Open Source Management Solution
272+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
273+#
274+# This program is free software: you can redistribute it and/or modify
275+# it under the terms of the GNU Affero General Public License as
276+# published by the Free Software Foundation, either version 3 of the
277+# License, or (at your option) any later version.
278+#
279+# This program is distributed in the hope that it will be useful,
280+# but WITHOUT ANY WARRANTY; without even the implied warranty of
281+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
282+# GNU Affero General Public License for more details.
283+#
284+# You should have received a copy of the GNU Affero General Public License
285+# along with this program. If not, see <http://www.gnu.org/licenses/>.
286+#
287+##############################################################################
288+
289+from osv import osv
290+from osv import fields
291+
292+from decimal_precision import decimal_precision as dp
293+
294+import tools
295+
296+
297+class report_stock_move(osv.osv):
298+ _name = 'report.stock.move'
299+ _inherit = 'report.stock.move'
300+
301+ _columns = {
302+ 'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type'),
303+ }
304+
305+ def init(self, cr):
306+ tools.drop_view_if_exists(cr, 'report_stock_move')
307+ cr.execute("""
308+ CREATE OR REPLACE view report_stock_move AS (
309+ SELECT
310+ min(sm_id) as id,
311+ sm_type_id as type_id,
312+ date_trunc('day',al.dp) as date,
313+ al.curr_year as year,
314+ al.curr_month as month,
315+ al.curr_day as day,
316+ al.curr_day_diff as day_diff,
317+ al.curr_day_diff1 as day_diff1,
318+ al.curr_day_diff2 as day_diff2,
319+ al.location_id as location_id,
320+ al.picking_id as picking_id,
321+ al.company_id as company_id,
322+ al.location_dest_id as location_dest_id,
323+ al.product_qty,
324+ al.out_qty as product_qty_out,
325+ al.in_qty as product_qty_in,
326+ al.address_id as partner_id,
327+ al.product_id as product_id,
328+ al.state as state ,
329+ al.product_uom as product_uom,
330+ al.categ_id as categ_id,
331+ coalesce(al.type, 'other') as type,
332+ al.stock_journal as stock_journal,
333+ sum(al.in_value - al.out_value) as value
334+ FROM (SELECT
335+ CASE WHEN sp.type in ('out') THEN
336+ sum(sm.product_qty * pu.factor)
337+ ELSE 0.0
338+ END AS out_qty,
339+ CASE WHEN sp.type in ('in') THEN
340+ sum(sm.product_qty * pu.factor)
341+ ELSE 0.0
342+ END AS in_qty,
343+ CASE WHEN sp.type in ('out') THEN
344+ sum(sm.product_qty * pu.factor) * pt.standard_price
345+ ELSE 0.0
346+ END AS out_value,
347+ CASE WHEN sp.type in ('in') THEN
348+ sum(sm.product_qty * pu.factor) * pt.standard_price
349+ ELSE 0.0
350+ END AS in_value,
351+ min(sm.id) as sm_id,
352+ sm.date as dp,
353+ sm.type_id as sm_type_id,
354+ to_char(date_trunc('day',sm.date), 'YYYY') as curr_year,
355+ to_char(date_trunc('day',sm.date), 'MM') as curr_month,
356+ to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as curr_day,
357+ avg(date(sm.date)-date(sm.create_date)) as curr_day_diff,
358+ avg(date(sm.date_expected)-date(sm.create_date)) as curr_day_diff1,
359+ avg(date(sm.date)-date(sm.date_expected)) as curr_day_diff2,
360+ sm.location_id as location_id,
361+ sm.location_dest_id as location_dest_id,
362+ sum(sm.product_qty) as product_qty,
363+ pt.categ_id as categ_id ,
364+ sm.address_id as address_id,
365+ sm.product_id as product_id,
366+ sm.picking_id as picking_id,
367+ sm.company_id as company_id,
368+ sm.state as state,
369+ sm.product_uom as product_uom,
370+ sp.type as type,
371+ sp.stock_journal_id AS stock_journal
372+ FROM
373+ stock_move sm
374+ LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id)
375+ LEFT JOIN product_product pp ON (sm.product_id=pp.id)
376+ LEFT JOIN product_uom pu ON (sm.product_uom=pu.id)
377+ LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
378+ LEFT JOIN stock_location sl ON (sm.location_id = sl.id)
379+
380+ GROUP BY
381+ sm.id,sp.type, sm.date,sm.address_id, sm.type_id,
382+ sm.product_id,sm.state,sm.product_uom,sm.date_expected,
383+ sm.product_id,pt.standard_price, sm.picking_id, sm.product_qty,
384+ sm.company_id,sm.product_qty, sm.location_id,sm.location_dest_id,pu.factor,pt.categ_id, sp.stock_journal_id)
385+ AS al
386+
387+ GROUP BY
388+ al.out_qty,al.in_qty,al.curr_year,al.curr_month, al.sm_type_id,
389+ al.curr_day,al.curr_day_diff,al.curr_day_diff1,al.curr_day_diff2,al.dp,al.location_id,al.location_dest_id,
390+ al.address_id,al.product_id,al.state,al.product_uom,
391+ al.picking_id,al.company_id,al.type,al.product_qty, al.categ_id, al.stock_journal
392+ )
393+ """)
394+
395+report_stock_move()
396\ No newline at end of file
397
398=== added file 'stock_inventory_type/stock_view.xml'
399--- stock_inventory_type/stock_view.xml 1970-01-01 00:00:00 +0000
400+++ stock_inventory_type/stock_view.xml 2011-03-15 15:12:37 +0000
401@@ -0,0 +1,193 @@
402+<?xml version="1.0" encoding="utf-8" ?>
403+<openerp>
404+ <data>
405+
406+ <!-- Stock Adjustment Types -->
407+
408+ <record id="stock_adjustment_type_form_view" model="ir.ui.view">
409+ <field name="name">stock.adjustment.type.form.view</field>
410+ <field name="model">stock.adjustment.type</field>
411+ <field name="type">form</field>
412+ <field name="arch" type="xml">
413+ <form string="Adjustment Type">
414+ <field name="name" colspan="4" select="1" />
415+ </form>
416+ </field>
417+ </record>
418+
419+ <record id="stock_adjustment_type_tree_view" model="ir.ui.view">
420+ <field name="name">stock.adjustment.type.tree.view</field>
421+ <field name="model">stock.adjustment.type</field>
422+ <field name="type">tree</field>
423+ <field name="arch" type="xml">
424+ <tree string="Adjustment Types">
425+ <field name="name" />
426+ </tree>
427+ </field>
428+ </record>
429+
430+ <record id="action_stock_adjustment_type" model="ir.actions.act_window">
431+ <field name="name">Stock Adjustment Types</field>
432+ <field name="res_model">stock.adjustment.type</field>
433+ <field name="view_type">form</field>
434+ <field name="view_mode">tree,form</field>
435+ </record>
436+
437+ <menuitem
438+ name="Inventory"
439+ id="menu_configuration_inventory"
440+ parent="stock.menu_stock_configuration" />
441+
442+ <menuitem
443+ action="action_stock_adjustment_type"
444+ id="menu_stock_adjustment_type"
445+ parent="menu_configuration_inventory" />
446+
447+
448+ <!-- Overrirde Stock Inventory Lines -->
449+ <record id="stock_inventory_line_tree_type_id" model="ir.ui.view">
450+ <field name="name">stock.inventory.line.tree.type.id</field>
451+ <field name="model">stock.inventory.line</field>
452+ <field name="type">tree</field>
453+ <field name="inherit_id" ref="stock.stock_inventory_line_tree" />
454+ <field name="arch" type="xml">
455+ <xpath expr="/tree/field[@name='prodlot_id']" position="after">
456+ <field name="type_id" widget="selection" />
457+ <field name="comment" />
458+ </xpath>
459+ </field>
460+ </record>
461+
462+ <record id="stock_inventory_line_form_type_id" model="ir.ui.view">
463+ <field name="name">stock.inventory.line.form.type.id</field>
464+ <field name="model">stock.inventory.line</field>
465+ <field name="type">form</field>
466+ <field name="inherit_id" ref="stock.stock_inventory_line_tree" />
467+ <field name="arch" type="xml">
468+ <xpath expr="/form/field[@name='prodlot_id']" position="after">
469+ <field name="type_id" widget="selection" />
470+ <field name="comment" />
471+ </xpath>
472+ </field>
473+ </record>
474+
475+ <record id="stock_inventory_form_type_id" model="ir.ui.view">
476+ <field name="name">stock.inventory.form.type.id</field>
477+ <field name="model">stock.inventory</field>
478+ <field name="type">form</field>
479+ <field name="inherit_id" ref="stock.view_inventory_form" />
480+ <field name="arch" type="xml">
481+ <data>
482+ <xpath expr="/form/notebook/page/field[@name='inventory_line_id']/tree/field[@name='product_id']" position="after">
483+ <field name="type_id" widget="selection" />
484+ <field name="comment" />
485+ </xpath>
486+ <xpath expr="/form/notebook/page/field[@name='inventory_line_id']/form/field[@name='product_id']" position="after">
487+ <field name="type_id" widget="selection" />
488+ <field name="comment" />
489+ </xpath>
490+ <xpath expr="/form/notebook/page[@string='Posted Inventory']/field[@name='move_ids']/tree/field[@name='prodlot_id']" position="after">
491+ <field name="type_id" widget="selection" />
492+ </xpath>
493+ </data>
494+ </field>
495+ </record>
496+
497+ <!-- Override Stock Moves -->
498+ <record id="stock_move_tree_type_id" model="ir.ui.view">
499+ <field name="name">stock.move.tree.type.id</field>
500+ <field name="model">stock.move</field>
501+ <field name="type">tree</field>
502+ <field name="inherit_id" ref="stock.stock_move_tree" />
503+ <field name="arch" type="xml">
504+ <xpath expr="/tree/field[@name='prodlot_id']" position="after">
505+ <field name="type_id" widget="selection" />
506+ <field name="comment" />
507+ </xpath>
508+ </field>
509+ </record>
510+
511+ <record id="stock_move_tree2_type_id" model="ir.ui.view">
512+ <field name="name">stock.move.tree2.type.id</field>
513+ <field name="model">stock.move</field>
514+ <field name="type">tree</field>
515+ <field name="inherit_id" ref="stock.stock_move_tree2" />
516+ <field name="arch" type="xml">
517+ <xpath expr="/tree/field[@name='prodlot_id']" position="after">
518+ <field name="type_id" widget="selection" />
519+ <field name="comment" />
520+ </xpath>
521+ </field>
522+ </record>
523+
524+ <record id="view_move_tree_type_id" model="ir.ui.view">
525+ <field name="name">view.move.tree.type.id</field>
526+ <field name="model">stock.move</field>
527+ <field name="type">tree</field>
528+ <field name="inherit_id" ref="stock.view_move_tree" />
529+ <field name="arch" type="xml">
530+ <xpath expr="/tree/field[@name='create_date']" position="after">
531+ <field name="type_id" widget="selection" />
532+ <field name="comment" />
533+ </xpath>
534+ </field>
535+ </record>
536+
537+ <record id="view_move_form_type_id" model="ir.ui.view">
538+ <field name="name">view.move.form.type.id</field>
539+ <field name="model">stock.move</field>
540+ <field name="type">form</field>
541+ <field name="inherit_id" ref="stock.view_move_form" />
542+ <field name="arch" type="xml">
543+ <xpath expr="/form/group/button[@string='Scrap']" position="after">
544+ <field name="type_id" widget="selection" />
545+ <field name="comment" />
546+ </xpath>
547+ </field>
548+ </record>
549+
550+ <record id="view_move_search_type_id" model="ir.ui.view">
551+ <field name="name">view.move.search.type.id</field>
552+ <field name="model">stock.move</field>
553+ <field name="type">search</field>
554+ <field name="inherit_id" ref="stock.view_move_search" />
555+ <field name="arch" type="xml">
556+ <xpath expr="/search/group/field[@name='product_id']" position="before">
557+ <field name="type_id" widget="selection" />
558+ <field name="comment" />
559+ </xpath>
560+ </field>
561+ </record>
562+
563+ <record id="view_stock_tree_type_id" model="ir.ui.view">
564+ <field name="name">view.stock.tree.type.id</field>
565+ <field name="model">report.stock.move</field>
566+ <field name="type">tree</field>
567+ <field name="inherit_id" ref="stock.view_stock_tree" />
568+ <field name="arch" type="xml">
569+ <xpath expr="/tree/field[@name='type']" position="after">
570+ <field name="type_id" />
571+ </xpath>
572+ </field>
573+ </record>
574+
575+ <record id="view_stock_search_type_id" model="ir.ui.view">
576+ <field name="name">view.stock.search.type.id</field>
577+ <field name="model">report.stock.move</field>
578+ <field name="type">search</field>
579+ <field name="inherit_id" ref="stock.view_stock_search" />
580+ <field name="arch" type="xml">
581+ <data>
582+ <xpath expr="/search/group/separator[3]" position="after">
583+ <field name="type_id" widget="selection" />
584+ </xpath>
585+ <xpath expr="/search/group[@string='Group By...']/filter[@name='group_type']" position="after">
586+ <filter string="Adjustment Type" name="group_type_id" icon="terp-stock_symbol-selection" context="{'group_by':'type_id'}" />
587+ </xpath>
588+ </data>
589+ </field>
590+ </record>
591+
592+ </data>
593+</openerp>
594+
595
596=== added directory 'stock_inventory_type/test'
597=== added file 'stock_inventory_type/test/adjustment_type.yml'
598--- stock_inventory_type/test/adjustment_type.yml 1970-01-01 00:00:00 +0000
599+++ stock_inventory_type/test/adjustment_type.yml 2011-03-15 15:12:37 +0000
600@@ -0,0 +1,117 @@
601+-
602+ In order to test the stock_inventory_type module, I will create product,
603+ create a physical inventory, fill inventory lines from location
604+-
605+ I create a product category
606+-
607+ !record {model: product.category, id: product_category1}:
608+ name: Categ1
609+-
610+ I create the first product (P1)
611+-
612+ !record {model: product.product, id: product_p1}:
613+ valuation: manual_periodic
614+ supply_method: produce
615+ mes_type: fixed
616+ uom_id: product.product_uom_unit
617+ uom_po_id: product.product_uom_unit
618+ type: product
619+ procure_method: make_to_stock
620+ cost_method: standard
621+ categ_id: stock_inventory_type.product_category1
622+ name: P1
623+ standard_price: 10.0
624+-
625+ I create the second product (P2)
626+-
627+ !record {model: product.product, id: product_p2}:
628+ valuation: manual_periodic
629+ supply_method: produce
630+ mes_type: fixed
631+ uom_id: product.product_uom_unit
632+ uom_po_id: product.product_uom_unit
633+ type: product
634+ procure_method: make_to_stock
635+ cost_method: standard
636+ categ_id: stock_inventory_type.product_category1
637+ name: P2
638+ standard_price: 20.0
639+-
640+ I create the third product (P3)
641+-
642+ !record {model: product.product, id: product_p3}:
643+ valuation: manual_periodic
644+ supply_method: produce
645+ mes_type: fixed
646+ uom_id: product.product_uom_unit
647+ uom_po_id: product.product_uom_unit
648+ type: product
649+ procure_method: make_to_stock
650+ cost_method: standard
651+ categ_id: stock_inventory_type.product_category1
652+ name: P3
653+ standard_price: 30.0
654+-
655+ I create a physical inventory
656+-
657+ !record {model: stock.inventory, id: stock_inventory1}:
658+ company_id: base.main_company
659+ date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
660+ inventory_line_id:
661+ - company_id: base.main_company
662+ location_id: stock.stock_location_stock
663+ product_id: stock_inventory_type.product_p1
664+ product_qty: 70.0
665+ product_uom: product.product_uom_unit
666+ type_id: stock_inventory_type.adjustment_type_loss
667+ comment: Loss items
668+ - company_id: base.main_company
669+ location_id: stock.stock_location_stock
670+ product_id: stock_inventory_type.product_p2
671+ product_qty: 50.0
672+ product_uom: product.product_uom_unit
673+ type_id: stock_inventory_type.adjustment_type_expired
674+ comment: Expired product at 12/12/2012
675+ - company_id: base.main_company
676+ location_id: stock.stock_location_stock
677+ product_id: stock_inventory_type.product_p3
678+ product_qty: 10.0
679+ product_uom: product.product_uom_unit
680+ type_id: stock_inventory_type.adjustment_type_scrap
681+ name: Test of UNI-SUP-1.15
682+ state: draft
683+-
684+ I confirm the Inventory
685+-
686+ !python {model: stock.inventory}: |
687+ self.action_confirm(cr, uid, [ref('stock_inventory1')])
688+ self.action_done(cr, uid, [ref('stock_inventory1')])
689+-
690+ I check the 'Loss' stock moves
691+-
692+ !python {model: stock.move}: |
693+ move_ids = self.search(cr, uid, [('type_id', '=', ref('stock_inventory_type.adjustment_type_loss'))])
694+ assert move_ids, "No lines with 'Loss' type"
695+ move = self.browse(cr, uid, move_ids[0])
696+ assert move.product_id.id == ref('stock_inventory_type.product_p1'), "Move product (P1) is not correct"
697+ assert move.product_qty == 70.0, "Move quatity (70.0) is not correct"
698+ assert move.comment == 'Loss items', "Move comment (Loss items) is not correct"
699+-
700+ I check the 'Expired' stock moves
701+-
702+ !python {model: stock.move}: |
703+ move_ids = self.search(cr, uid, [('type_id', '=', ref('stock_inventory_type.adjustment_type_expired'))])
704+ assert move_ids, "No lines with 'Expired' type"
705+ move = self.browse(cr, uid, move_ids[0])
706+ assert move.product_id.id == ref('stock_inventory_type.product_p2'), "Move product (P2) is not correct"
707+ assert move.product_qty == 50.0, "Move quatity (50.0) is not correct"
708+ assert move.comment == 'Expired product at 12/12/2012', "Move comment (Expired product at 12/12/2012) is not correct"
709+-
710+ I check the 'Scrapped' stock moves
711+-
712+ !python {model: stock.move}: |
713+ move_ids = self.search(cr, uid, [('type_id', '=', ref('stock_inventory_type.adjustment_type_scrap'))])
714+ assert move_ids, "No lines with 'Scrap' type"
715+ move = self.browse(cr, uid, move_ids[0])
716+ assert move.product_id.id == ref('stock_inventory_type.product_p3'), "Move product (P3) is not correct"
717+ assert move.product_qty == 10.0, "Move quatity (10.0) is not correct"

Subscribers

People subscribed via source and target branches

to all changes: