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
=== added directory 'stock_inventory_type'
=== added file 'stock_inventory_type/__init__.py'
--- stock_inventory_type/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/__init__.py 2011-03-15 15:12:37 +0000
@@ -0,0 +1,28 @@
1#!/usr/bin/env python
2# -*- encoding: utf-8 -*-
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23
24import stock
25import stock_move_report
26
27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
28
029
=== added file 'stock_inventory_type/__openerp__.py'
--- stock_inventory_type/__openerp__.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/__openerp__.py 2011-03-15 15:12:37 +0000
@@ -0,0 +1,50 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 "name" : "Stock Adjustment/Move Report",
23 "version" : "1.0",
24 "author" : "TeMPO Consulting, MSF",
25 "category": "Inventory Control",
26 "description": """
27 This module aims to help you to determine the type \
28 of your inventory adjustment and to search stock move \
29 by type of adjustment.
30 """,
31 "website": "http://unifield.msf.org",
32 "init_xml": [
33 ],
34 "depends" : [
35 "stock",
36 ],
37 "update_xml": [
38 "stock_view.xml",
39 "stock_data.xml",
40 "security/ir.model.access.csv",
41 ],
42 "demo_xml": [
43 "test/adjustment_type.yml",
44 ],
45 "test": [
46 "test/adjustment_type.yml",
47 ],
48 "installable": True,
49 "active": False,
50}
051
=== added directory 'stock_inventory_type/security'
=== added file 'stock_inventory_type/security/ir.model.access.csv'
--- stock_inventory_type/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/security/ir.model.access.csv 2011-03-15 15:12:37 +0000
@@ -0,0 +1,2 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_stock_adjustment_type_all","stock.adjustment.type all","model_stock_adjustment_type",,1,1,1,1
03
=== added file 'stock_inventory_type/stock.py'
--- stock_inventory_type/stock.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/stock.py 2011-03-15 15:12:37 +0000
@@ -0,0 +1,133 @@
1#!/usr/bin/env python
2# -*- encoding: utf-8 -*-
3##############################################################################
4#
5# OpenERP, Open Source Management Solution
6# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23
24from osv import osv
25from osv import fields
26
27from tools.translate import _
28
29
30class stock_adjustment_type(osv.osv):
31 _name = 'stock.adjustment.type'
32 _description = 'Inventory/Move Adjustment Types'
33
34 _columns = {
35 'name': fields.char(size=64, string='Name', required=True),
36 }
37
38stock_adjustment_type()
39
40
41class stock_inventory_line(osv.osv):
42 _name = 'stock.inventory.line'
43 _inherit = 'stock.inventory.line'
44
45 _columns = {
46 'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type'),
47 'comment': fields.char(size=128, string='Comment'),
48 }
49
50stock_inventory_line()
51
52
53class stock_move(osv.osv):
54 _name = 'stock.move'
55 _inherit = 'stock.move'
56
57 _columns = {
58 'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type', readonly=True),
59 'comment': fields.char(size=128, string='Comment'),
60 }
61
62stock_move()
63
64
65class stock_inventory(osv.osv):
66 _name = 'stock.inventory'
67 _inherit = 'stock.inventory'
68
69 def action_confirm(self, cr, uid, ids, context={}):
70 """ Confirm the inventory and writes its finished date
71 @return True
72 """
73 # to perform the correct inventory corrections we need analyze stock location by
74 # location, never recursively, so we use a special context
75 product_context = dict(context, compute_child=False)
76
77 location_obj = self.pool.get('stock.location')
78 for inv in self.browse(cr, uid, ids, context=context):
79 move_ids = []
80 for line in inv.inventory_line_id:
81 pid = line.product_id.id
82 product_context.update(uom=line.product_uom.id,date=inv.date)
83 amount = location_obj._product_get(cr, uid, line.location_id.id, [pid], product_context)[pid]
84
85 change = line.product_qty - amount
86 lot_id = line.prod_lot_id.id
87 type_id = line.type_id.id
88 if change:
89 location_id = line.product_id.product_tmpl_id.property_stock_inventory.id
90 value = {
91 'name': 'INV:' + str(line.inventory_id.id) + ':' + line.inventory_id.name,
92 'product_id': line.product_id.id,
93 'product_uom': line.product_uom.id,
94 'prodlot_id': lot_id,
95 'date': inv.date,
96 # @@@override@ stock.stock_inventory.action_confirm()
97 'comment': line.comment,
98 # @@@end
99 }
100 if change > 0:
101 value.update( {
102 'product_qty': change,
103 'location_id': location_id,
104 'location_dest_id': line.location_id.id,
105 })
106 else:
107 value.update( {
108 'product_qty': -change,
109 'location_id': line.location_id.id,
110 'location_dest_id': location_id,
111 })
112 if lot_id:
113 value.update({
114 'prodlot_id': lot_id,
115 'product_qty': line.product_qty
116 })
117 # @@@override@ stock.stock_inventory.action_confirm()
118 if type_id:
119 value.update({
120 'type_id': type_id,
121 })
122 # @@@end
123 move_ids.append(self._inventory_line_hook(cr, uid, line, value))
124 message = _('Inventory') + " '" + inv.name + "' "+ _("is done.")
125 self.log(cr, uid, inv.id, message)
126 self.write(cr, uid, [inv.id], {'state': 'confirm', 'move_ids': [(6, 0, move_ids)]})
127
128 return True
129
130stock_inventory()
131
132# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
133
0134
=== added file 'stock_inventory_type/stock_data.xml'
--- stock_inventory_type/stock_data.xml 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/stock_data.xml 2011-03-15 15:12:37 +0000
@@ -0,0 +1,23 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<openerp>
3 <data>
4
5 <record id="adjustment_type_loss" model="stock.adjustment.type">
6 <field name="name">Loss</field>
7 </record>
8
9 <record id="adjustment_type_scrap" model="stock.adjustment.type">
10 <field name="name">Scrap</field>
11 </record>
12
13 <record id="adjustment_type_expired" model="stock.adjustment.type">
14 <field name="name">Expired</field>
15 </record>
16
17 <record id="adjustment_type_broken" model="stock.adjustment.type">
18 <field name="name">Broken</field>
19 </record>
20
21 </data>
22</openerp>
23
024
=== added file 'stock_inventory_type/stock_move_report.py'
--- stock_inventory_type/stock_move_report.py 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/stock_move_report.py 2011-03-15 15:12:37 +0000
@@ -0,0 +1,128 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from osv import osv
23from osv import fields
24
25from decimal_precision import decimal_precision as dp
26
27import tools
28
29
30class report_stock_move(osv.osv):
31 _name = 'report.stock.move'
32 _inherit = 'report.stock.move'
33
34 _columns = {
35 'type_id': fields.many2one('stock.adjustment.type', string='Adjustment type'),
36 }
37
38 def init(self, cr):
39 tools.drop_view_if_exists(cr, 'report_stock_move')
40 cr.execute("""
41 CREATE OR REPLACE view report_stock_move AS (
42 SELECT
43 min(sm_id) as id,
44 sm_type_id as type_id,
45 date_trunc('day',al.dp) as date,
46 al.curr_year as year,
47 al.curr_month as month,
48 al.curr_day as day,
49 al.curr_day_diff as day_diff,
50 al.curr_day_diff1 as day_diff1,
51 al.curr_day_diff2 as day_diff2,
52 al.location_id as location_id,
53 al.picking_id as picking_id,
54 al.company_id as company_id,
55 al.location_dest_id as location_dest_id,
56 al.product_qty,
57 al.out_qty as product_qty_out,
58 al.in_qty as product_qty_in,
59 al.address_id as partner_id,
60 al.product_id as product_id,
61 al.state as state ,
62 al.product_uom as product_uom,
63 al.categ_id as categ_id,
64 coalesce(al.type, 'other') as type,
65 al.stock_journal as stock_journal,
66 sum(al.in_value - al.out_value) as value
67 FROM (SELECT
68 CASE WHEN sp.type in ('out') THEN
69 sum(sm.product_qty * pu.factor)
70 ELSE 0.0
71 END AS out_qty,
72 CASE WHEN sp.type in ('in') THEN
73 sum(sm.product_qty * pu.factor)
74 ELSE 0.0
75 END AS in_qty,
76 CASE WHEN sp.type in ('out') THEN
77 sum(sm.product_qty * pu.factor) * pt.standard_price
78 ELSE 0.0
79 END AS out_value,
80 CASE WHEN sp.type in ('in') THEN
81 sum(sm.product_qty * pu.factor) * pt.standard_price
82 ELSE 0.0
83 END AS in_value,
84 min(sm.id) as sm_id,
85 sm.date as dp,
86 sm.type_id as sm_type_id,
87 to_char(date_trunc('day',sm.date), 'YYYY') as curr_year,
88 to_char(date_trunc('day',sm.date), 'MM') as curr_month,
89 to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as curr_day,
90 avg(date(sm.date)-date(sm.create_date)) as curr_day_diff,
91 avg(date(sm.date_expected)-date(sm.create_date)) as curr_day_diff1,
92 avg(date(sm.date)-date(sm.date_expected)) as curr_day_diff2,
93 sm.location_id as location_id,
94 sm.location_dest_id as location_dest_id,
95 sum(sm.product_qty) as product_qty,
96 pt.categ_id as categ_id ,
97 sm.address_id as address_id,
98 sm.product_id as product_id,
99 sm.picking_id as picking_id,
100 sm.company_id as company_id,
101 sm.state as state,
102 sm.product_uom as product_uom,
103 sp.type as type,
104 sp.stock_journal_id AS stock_journal
105 FROM
106 stock_move sm
107 LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id)
108 LEFT JOIN product_product pp ON (sm.product_id=pp.id)
109 LEFT JOIN product_uom pu ON (sm.product_uom=pu.id)
110 LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
111 LEFT JOIN stock_location sl ON (sm.location_id = sl.id)
112
113 GROUP BY
114 sm.id,sp.type, sm.date,sm.address_id, sm.type_id,
115 sm.product_id,sm.state,sm.product_uom,sm.date_expected,
116 sm.product_id,pt.standard_price, sm.picking_id, sm.product_qty,
117 sm.company_id,sm.product_qty, sm.location_id,sm.location_dest_id,pu.factor,pt.categ_id, sp.stock_journal_id)
118 AS al
119
120 GROUP BY
121 al.out_qty,al.in_qty,al.curr_year,al.curr_month, al.sm_type_id,
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,
123 al.address_id,al.product_id,al.state,al.product_uom,
124 al.picking_id,al.company_id,al.type,al.product_qty, al.categ_id, al.stock_journal
125 )
126 """)
127
128report_stock_move()
0\ No newline at end of file129\ No newline at end of file
1130
=== added file 'stock_inventory_type/stock_view.xml'
--- stock_inventory_type/stock_view.xml 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/stock_view.xml 2011-03-15 15:12:37 +0000
@@ -0,0 +1,193 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<openerp>
3 <data>
4
5 <!-- Stock Adjustment Types -->
6
7 <record id="stock_adjustment_type_form_view" model="ir.ui.view">
8 <field name="name">stock.adjustment.type.form.view</field>
9 <field name="model">stock.adjustment.type</field>
10 <field name="type">form</field>
11 <field name="arch" type="xml">
12 <form string="Adjustment Type">
13 <field name="name" colspan="4" select="1" />
14 </form>
15 </field>
16 </record>
17
18 <record id="stock_adjustment_type_tree_view" model="ir.ui.view">
19 <field name="name">stock.adjustment.type.tree.view</field>
20 <field name="model">stock.adjustment.type</field>
21 <field name="type">tree</field>
22 <field name="arch" type="xml">
23 <tree string="Adjustment Types">
24 <field name="name" />
25 </tree>
26 </field>
27 </record>
28
29 <record id="action_stock_adjustment_type" model="ir.actions.act_window">
30 <field name="name">Stock Adjustment Types</field>
31 <field name="res_model">stock.adjustment.type</field>
32 <field name="view_type">form</field>
33 <field name="view_mode">tree,form</field>
34 </record>
35
36 <menuitem
37 name="Inventory"
38 id="menu_configuration_inventory"
39 parent="stock.menu_stock_configuration" />
40
41 <menuitem
42 action="action_stock_adjustment_type"
43 id="menu_stock_adjustment_type"
44 parent="menu_configuration_inventory" />
45
46
47 <!-- Overrirde Stock Inventory Lines -->
48 <record id="stock_inventory_line_tree_type_id" model="ir.ui.view">
49 <field name="name">stock.inventory.line.tree.type.id</field>
50 <field name="model">stock.inventory.line</field>
51 <field name="type">tree</field>
52 <field name="inherit_id" ref="stock.stock_inventory_line_tree" />
53 <field name="arch" type="xml">
54 <xpath expr="/tree/field[@name='prodlot_id']" position="after">
55 <field name="type_id" widget="selection" />
56 <field name="comment" />
57 </xpath>
58 </field>
59 </record>
60
61 <record id="stock_inventory_line_form_type_id" model="ir.ui.view">
62 <field name="name">stock.inventory.line.form.type.id</field>
63 <field name="model">stock.inventory.line</field>
64 <field name="type">form</field>
65 <field name="inherit_id" ref="stock.stock_inventory_line_tree" />
66 <field name="arch" type="xml">
67 <xpath expr="/form/field[@name='prodlot_id']" position="after">
68 <field name="type_id" widget="selection" />
69 <field name="comment" />
70 </xpath>
71 </field>
72 </record>
73
74 <record id="stock_inventory_form_type_id" model="ir.ui.view">
75 <field name="name">stock.inventory.form.type.id</field>
76 <field name="model">stock.inventory</field>
77 <field name="type">form</field>
78 <field name="inherit_id" ref="stock.view_inventory_form" />
79 <field name="arch" type="xml">
80 <data>
81 <xpath expr="/form/notebook/page/field[@name='inventory_line_id']/tree/field[@name='product_id']" position="after">
82 <field name="type_id" widget="selection" />
83 <field name="comment" />
84 </xpath>
85 <xpath expr="/form/notebook/page/field[@name='inventory_line_id']/form/field[@name='product_id']" position="after">
86 <field name="type_id" widget="selection" />
87 <field name="comment" />
88 </xpath>
89 <xpath expr="/form/notebook/page[@string='Posted Inventory']/field[@name='move_ids']/tree/field[@name='prodlot_id']" position="after">
90 <field name="type_id" widget="selection" />
91 </xpath>
92 </data>
93 </field>
94 </record>
95
96 <!-- Override Stock Moves -->
97 <record id="stock_move_tree_type_id" model="ir.ui.view">
98 <field name="name">stock.move.tree.type.id</field>
99 <field name="model">stock.move</field>
100 <field name="type">tree</field>
101 <field name="inherit_id" ref="stock.stock_move_tree" />
102 <field name="arch" type="xml">
103 <xpath expr="/tree/field[@name='prodlot_id']" position="after">
104 <field name="type_id" widget="selection" />
105 <field name="comment" />
106 </xpath>
107 </field>
108 </record>
109
110 <record id="stock_move_tree2_type_id" model="ir.ui.view">
111 <field name="name">stock.move.tree2.type.id</field>
112 <field name="model">stock.move</field>
113 <field name="type">tree</field>
114 <field name="inherit_id" ref="stock.stock_move_tree2" />
115 <field name="arch" type="xml">
116 <xpath expr="/tree/field[@name='prodlot_id']" position="after">
117 <field name="type_id" widget="selection" />
118 <field name="comment" />
119 </xpath>
120 </field>
121 </record>
122
123 <record id="view_move_tree_type_id" model="ir.ui.view">
124 <field name="name">view.move.tree.type.id</field>
125 <field name="model">stock.move</field>
126 <field name="type">tree</field>
127 <field name="inherit_id" ref="stock.view_move_tree" />
128 <field name="arch" type="xml">
129 <xpath expr="/tree/field[@name='create_date']" position="after">
130 <field name="type_id" widget="selection" />
131 <field name="comment" />
132 </xpath>
133 </field>
134 </record>
135
136 <record id="view_move_form_type_id" model="ir.ui.view">
137 <field name="name">view.move.form.type.id</field>
138 <field name="model">stock.move</field>
139 <field name="type">form</field>
140 <field name="inherit_id" ref="stock.view_move_form" />
141 <field name="arch" type="xml">
142 <xpath expr="/form/group/button[@string='Scrap']" position="after">
143 <field name="type_id" widget="selection" />
144 <field name="comment" />
145 </xpath>
146 </field>
147 </record>
148
149 <record id="view_move_search_type_id" model="ir.ui.view">
150 <field name="name">view.move.search.type.id</field>
151 <field name="model">stock.move</field>
152 <field name="type">search</field>
153 <field name="inherit_id" ref="stock.view_move_search" />
154 <field name="arch" type="xml">
155 <xpath expr="/search/group/field[@name='product_id']" position="before">
156 <field name="type_id" widget="selection" />
157 <field name="comment" />
158 </xpath>
159 </field>
160 </record>
161
162 <record id="view_stock_tree_type_id" model="ir.ui.view">
163 <field name="name">view.stock.tree.type.id</field>
164 <field name="model">report.stock.move</field>
165 <field name="type">tree</field>
166 <field name="inherit_id" ref="stock.view_stock_tree" />
167 <field name="arch" type="xml">
168 <xpath expr="/tree/field[@name='type']" position="after">
169 <field name="type_id" />
170 </xpath>
171 </field>
172 </record>
173
174 <record id="view_stock_search_type_id" model="ir.ui.view">
175 <field name="name">view.stock.search.type.id</field>
176 <field name="model">report.stock.move</field>
177 <field name="type">search</field>
178 <field name="inherit_id" ref="stock.view_stock_search" />
179 <field name="arch" type="xml">
180 <data>
181 <xpath expr="/search/group/separator[3]" position="after">
182 <field name="type_id" widget="selection" />
183 </xpath>
184 <xpath expr="/search/group[@string='Group By...']/filter[@name='group_type']" position="after">
185 <filter string="Adjustment Type" name="group_type_id" icon="terp-stock_symbol-selection" context="{'group_by':'type_id'}" />
186 </xpath>
187 </data>
188 </field>
189 </record>
190
191 </data>
192</openerp>
193
0194
=== added directory 'stock_inventory_type/test'
=== added file 'stock_inventory_type/test/adjustment_type.yml'
--- stock_inventory_type/test/adjustment_type.yml 1970-01-01 00:00:00 +0000
+++ stock_inventory_type/test/adjustment_type.yml 2011-03-15 15:12:37 +0000
@@ -0,0 +1,117 @@
1-
2 In order to test the stock_inventory_type module, I will create product,
3 create a physical inventory, fill inventory lines from location
4-
5 I create a product category
6-
7 !record {model: product.category, id: product_category1}:
8 name: Categ1
9-
10 I create the first product (P1)
11-
12 !record {model: product.product, id: product_p1}:
13 valuation: manual_periodic
14 supply_method: produce
15 mes_type: fixed
16 uom_id: product.product_uom_unit
17 uom_po_id: product.product_uom_unit
18 type: product
19 procure_method: make_to_stock
20 cost_method: standard
21 categ_id: stock_inventory_type.product_category1
22 name: P1
23 standard_price: 10.0
24-
25 I create the second product (P2)
26-
27 !record {model: product.product, id: product_p2}:
28 valuation: manual_periodic
29 supply_method: produce
30 mes_type: fixed
31 uom_id: product.product_uom_unit
32 uom_po_id: product.product_uom_unit
33 type: product
34 procure_method: make_to_stock
35 cost_method: standard
36 categ_id: stock_inventory_type.product_category1
37 name: P2
38 standard_price: 20.0
39-
40 I create the third product (P3)
41-
42 !record {model: product.product, id: product_p3}:
43 valuation: manual_periodic
44 supply_method: produce
45 mes_type: fixed
46 uom_id: product.product_uom_unit
47 uom_po_id: product.product_uom_unit
48 type: product
49 procure_method: make_to_stock
50 cost_method: standard
51 categ_id: stock_inventory_type.product_category1
52 name: P3
53 standard_price: 30.0
54-
55 I create a physical inventory
56-
57 !record {model: stock.inventory, id: stock_inventory1}:
58 company_id: base.main_company
59 date: !eval time.strftime('%Y-%m-%d %H:%M:%S')
60 inventory_line_id:
61 - company_id: base.main_company
62 location_id: stock.stock_location_stock
63 product_id: stock_inventory_type.product_p1
64 product_qty: 70.0
65 product_uom: product.product_uom_unit
66 type_id: stock_inventory_type.adjustment_type_loss
67 comment: Loss items
68 - company_id: base.main_company
69 location_id: stock.stock_location_stock
70 product_id: stock_inventory_type.product_p2
71 product_qty: 50.0
72 product_uom: product.product_uom_unit
73 type_id: stock_inventory_type.adjustment_type_expired
74 comment: Expired product at 12/12/2012
75 - company_id: base.main_company
76 location_id: stock.stock_location_stock
77 product_id: stock_inventory_type.product_p3
78 product_qty: 10.0
79 product_uom: product.product_uom_unit
80 type_id: stock_inventory_type.adjustment_type_scrap
81 name: Test of UNI-SUP-1.15
82 state: draft
83-
84 I confirm the Inventory
85-
86 !python {model: stock.inventory}: |
87 self.action_confirm(cr, uid, [ref('stock_inventory1')])
88 self.action_done(cr, uid, [ref('stock_inventory1')])
89-
90 I check the 'Loss' stock moves
91-
92 !python {model: stock.move}: |
93 move_ids = self.search(cr, uid, [('type_id', '=', ref('stock_inventory_type.adjustment_type_loss'))])
94 assert move_ids, "No lines with 'Loss' type"
95 move = self.browse(cr, uid, move_ids[0])
96 assert move.product_id.id == ref('stock_inventory_type.product_p1'), "Move product (P1) is not correct"
97 assert move.product_qty == 70.0, "Move quatity (70.0) is not correct"
98 assert move.comment == 'Loss items', "Move comment (Loss items) is not correct"
99-
100 I check the 'Expired' stock moves
101-
102 !python {model: stock.move}: |
103 move_ids = self.search(cr, uid, [('type_id', '=', ref('stock_inventory_type.adjustment_type_expired'))])
104 assert move_ids, "No lines with 'Expired' type"
105 move = self.browse(cr, uid, move_ids[0])
106 assert move.product_id.id == ref('stock_inventory_type.product_p2'), "Move product (P2) is not correct"
107 assert move.product_qty == 50.0, "Move quatity (50.0) is not correct"
108 assert move.comment == 'Expired product at 12/12/2012', "Move comment (Expired product at 12/12/2012) is not correct"
109-
110 I check the 'Scrapped' stock moves
111-
112 !python {model: stock.move}: |
113 move_ids = self.search(cr, uid, [('type_id', '=', ref('stock_inventory_type.adjustment_type_scrap'))])
114 assert move_ids, "No lines with 'Scrap' type"
115 move = self.browse(cr, uid, move_ids[0])
116 assert move.product_id.id == ref('stock_inventory_type.product_p3'), "Move product (P3) is not correct"
117 assert move.product_qty == 10.0, "Move quatity (10.0) is not correct"

Subscribers

People subscribed via source and target branches

to all changes: