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