Merge lp:~domsense/stock-logistic-warehouse/adding_stock_optional_valuation into lp:stock-logistic-warehouse

Proposed by Lorenzo Battistini
Status: Merged
Merged at revision: 30
Proposed branch: lp:~domsense/stock-logistic-warehouse/adding_stock_optional_valuation
Merge into: lp:stock-logistic-warehouse
Diff against target: 252 lines (+221/-0)
6 files modified
stock_optional_valuation/AUTHORS.txt (+2/-0)
stock_optional_valuation/__init__.py (+21/-0)
stock_optional_valuation/__openerp__.py (+41/-0)
stock_optional_valuation/stock.py (+45/-0)
stock_optional_valuation/stock_view.xml (+17/-0)
stock_optional_valuation/test/stock.yml (+95/-0)
To merge this branch: bzr merge lp:~domsense/stock-logistic-warehouse/adding_stock_optional_valuation
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) code review Approve
Guewen Baconnier @ Camptocamp code review, no test Approve
Review via email: mp+166798@code.launchpad.net

Description of the change

You can choose which stock moves have to generate inventory valutanion accounting entries, by specifying it in the location form

To post a comment you must log in.
35. By Lorenzo Battistini

[fix] when company_id is null

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

You may want to fix a typo in the __openerp__.py manifest:
s/valutanion/valuation

LGTM

review: Approve (code review, no test)
36. By Lorenzo Battistini

 [fix] description

Revision history for this message
Lorenzo Battistini (elbati) wrote :

> You may want to fix a typo in the __openerp__.py manifest:
> s/valutanion/valuation
>
>
Done

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'stock_optional_valuation'
2=== added file 'stock_optional_valuation/AUTHORS.txt'
3--- stock_optional_valuation/AUTHORS.txt 1970-01-01 00:00:00 +0000
4+++ stock_optional_valuation/AUTHORS.txt 2013-06-19 16:43:27 +0000
5@@ -0,0 +1,2 @@
6+Lorenzo Battistini <lorenzo.battistini@agilebg.com>
7+Leonardo Pistone <leonardo.pistone@agilebg.com>
8
9=== added file 'stock_optional_valuation/__init__.py'
10--- stock_optional_valuation/__init__.py 1970-01-01 00:00:00 +0000
11+++ stock_optional_valuation/__init__.py 2013-06-19 16:43:27 +0000
12@@ -0,0 +1,21 @@
13+# -*- coding: utf-8 -*-
14+##############################################################################
15+#
16+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU Affero General Public License as published
20+# by the Free Software Foundation, either version 3 of the License, or
21+# (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU Affero General Public License for more details.
27+#
28+# You should have received a copy of the GNU Affero General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31+##############################################################################
32+
33+import stock
34
35=== added file 'stock_optional_valuation/__openerp__.py'
36--- stock_optional_valuation/__openerp__.py 1970-01-01 00:00:00 +0000
37+++ stock_optional_valuation/__openerp__.py 2013-06-19 16:43:27 +0000
38@@ -0,0 +1,41 @@
39+# -*- coding: utf-8 -*-
40+##############################################################################
41+#
42+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
43+#
44+# This program is free software: you can redistribute it and/or modify
45+# it under the terms of the GNU Affero General Public License as published
46+# by the Free Software Foundation, either version 3 of the License, or
47+# (at your option) any later version.
48+#
49+# This program is distributed in the hope that it will be useful,
50+# but WITHOUT ANY WARRANTY; without even the implied warranty of
51+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+# GNU Affero General Public License for more details.
53+#
54+# You should have received a copy of the GNU Affero General Public License
55+# along with this program. If not, see <http://www.gnu.org/licenses/>.
56+#
57+##############################################################################
58+
59+{
60+ 'name': "Stock optional valuation",
61+ 'version': '0.1',
62+ 'category': 'Warehouse Management',
63+ 'description': """
64+You can choose which stock moves have to generate inventory valuation accounting entries, by specifying it in the location form.
65+""",
66+ 'author': 'Agile Business Group',
67+ 'website': 'http://www.agilebg.com',
68+ 'license': 'AGPL-3',
69+ "depends": ['stock'],
70+ "data": [
71+ "stock_view.xml",
72+ ],
73+ "demo": [],
74+ 'test': [
75+ 'test/stock.yml'
76+ ],
77+ "active": False,
78+ "installable": True
79+}
80
81=== added file 'stock_optional_valuation/stock.py'
82--- stock_optional_valuation/stock.py 1970-01-01 00:00:00 +0000
83+++ stock_optional_valuation/stock.py 2013-06-19 16:43:27 +0000
84@@ -0,0 +1,45 @@
85+# -*- coding: utf-8 -*-
86+##############################################################################
87+#
88+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
89+#
90+# This program is free software: you can redistribute it and/or modify
91+# it under the terms of the GNU Affero General Public License as published
92+# by the Free Software Foundation, either version 3 of the License, or
93+# (at your option) any later version.
94+#
95+# This program is distributed in the hope that it will be useful,
96+# but WITHOUT ANY WARRANTY; without even the implied warranty of
97+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98+# GNU Affero General Public License for more details.
99+#
100+# You should have received a copy of the GNU Affero General Public License
101+# along with this program. If not, see <http://www.gnu.org/licenses/>.
102+#
103+##############################################################################
104+
105+from openerp.osv import fields, orm
106+from openerp.tools.translate import _
107+
108+class stock_location(orm.Model):
109+ _inherit = "stock.location"
110+
111+ _columns = {
112+ 'consider_internal': fields.boolean('Consider internal', help="Consider as internal location for inventory valuation: stock moves from internal to internal will not generate accounting entries"),
113+ }
114+
115+class stock_move(orm.Model):
116+ _inherit = "stock.move"
117+
118+ def _create_product_valuation_moves(self, cr, uid, move, context=None):
119+ if (move.location_id.company_id and move.location_dest_id.company_id
120+ and move.location_id.company_id != move.location_dest_id.company_id):
121+ return super(stock_move,self)._create_product_valuation_moves(
122+ cr, uid, move, context=context)
123+ if (move.location_id.usage == 'internal' or
124+ move.location_id.consider_internal) and (
125+ move.location_dest_id.usage == 'internal' or
126+ move.location_dest_id.consider_internal):
127+ return
128+ return super(stock_move,self)._create_product_valuation_moves(
129+ cr, uid, move, context=context)
130
131=== added file 'stock_optional_valuation/stock_view.xml'
132--- stock_optional_valuation/stock_view.xml 1970-01-01 00:00:00 +0000
133+++ stock_optional_valuation/stock_view.xml 2013-06-19 16:43:27 +0000
134@@ -0,0 +1,17 @@
135+<?xml version="1.0" encoding="utf-8"?>
136+<openerp>
137+<data>
138+ <record id="view_location_form" model="ir.ui.view">
139+ <field name="name">stock.location.form</field>
140+ <field name="model">stock.location</field>
141+ <field name="inherit_id" ref="stock.view_location_form"></field>
142+ <field name="arch" type="xml">
143+ <xpath expr="/form/group" position="inside">
144+ <group string="Inventory valuation" groups="stock.group_inventory_valuation">
145+ <field name="consider_internal"/>
146+ </group>
147+ </xpath>
148+ </field>
149+ </record>
150+</data>
151+</openerp>
152
153=== added directory 'stock_optional_valuation/test'
154=== added file 'stock_optional_valuation/test/stock.yml'
155--- stock_optional_valuation/test/stock.yml 1970-01-01 00:00:00 +0000
156+++ stock_optional_valuation/test/stock.yml 2013-06-19 16:43:27 +0000
157@@ -0,0 +1,95 @@
158+-
159+ I need a product with real time valuation.
160+-
161+ !record {model: product.product, id: product.product_product_24}:
162+ valuation: real_time
163+ property_stock_account_input: account.o_expense
164+ property_stock_account_output: account.o_income
165+-
166+ !record {model: stock.picking, id: outgoing_shipment}:
167+ type: out
168+-
169+ !record {model: stock.move, id: outgoing_shipment_card}:
170+ picking_id: outgoing_shipment
171+ product_id: product.product_product_24
172+ product_qty: 2.0
173+ location_id: stock.stock_location_stock
174+ location_dest_id: stock.location_inventory
175+-
176+ I confirm outgoing shipment of 2 Graphics Cards from Stock to Inventory Loss
177+-
178+ !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment}
179+-
180+ I process the picking
181+-
182+ !python {model: stock.partial.picking}: |
183+ context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment'), 'active_ids': [ref('outgoing_shipment')]})
184+-
185+ !record {model: stock.partial.picking, id: partial_outgoing}:
186+ move_ids:
187+ - quantity: 2.0
188+ product_id: product.product_product_24
189+ product_uom: product.product_uom_unit
190+ move_id: outgoing_shipment_card
191+ location_id: stock.stock_location_stock
192+ location_dest_id: stock.location_inventory
193+-
194+ !python {model: stock.partial.picking }: |
195+ self.do_partial(cr, uid, [ref('partial_outgoing')], context=context)
196+-
197+ My picking should have generated a Journal Entry with the same name
198+-
199+ !python {model: stock.picking}: |
200+ picking_name = self.browse(cr, uid, ref('outgoing_shipment'), context=context).name
201+ a_move_obj = self.pool.get('account.move')
202+ # count those
203+ a_move_ids = a_move_obj.search(cr, uid, [('ref', '=', picking_name)])
204+ assert len(a_move_ids) == 1, "An outgoing picking should generate a Journal Entry"
205+-
206+ Now I will consider the location to be Internal
207+-
208+ !record {model: stock.location, id: stock.location_inventory}:
209+ consider_internal: True
210+-
211+ I repeate the process above. Now no Journal Entry should be generated.
212+-
213+ !record {model: stock.picking, id: outgoing_shipment_as_internal}:
214+ type: out
215+-
216+ !record {model: stock.move, id: outgoing_shipment_as_internal_card}:
217+ picking_id: outgoing_shipment_as_internal
218+ product_id: product.product_product_24
219+ product_qty: 2.0
220+ location_id: stock.stock_location_stock
221+ location_dest_id: stock.location_inventory
222+
223+-
224+ I confirm outgoing shipment of 2 Graphics Cards from Stock to Inventory Loss
225+-
226+ !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment_as_internal}
227+-
228+ I process the picking
229+-
230+ !python {model: stock.partial.picking}: |
231+ context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment_as_internal'), 'active_ids': [ref('outgoing_shipment_as_internal')]})
232+-
233+ !record {model: stock.partial.picking, id: partial_outgoing}:
234+ move_ids:
235+ - quantity: 2.0
236+ product_id: product.product_product_24
237+ product_uom: product.product_uom_unit
238+ move_id: outgoing_shipment_as_internal_card
239+ location_id: stock.stock_location_stock
240+ location_dest_id: stock.location_inventory
241+-
242+ !python {model: stock.partial.picking }: |
243+ self.do_partial(cr, uid, [ref('partial_outgoing')], context=context)
244+-
245+ Now there should be no Journal Entries with the same name
246+-
247+ !python {model: stock.picking }: |
248+ picking_name = self.browse(cr, uid, ref('outgoing_shipment_as_internal'), context=context).name
249+ a_move_obj = self.pool.get('account.move')
250+ # count those
251+ a_move_ids = a_move_obj.search(cr, uid, [('ref', '=', picking_name)])
252+ assert len(a_move_ids) == 0, "Locations treater as internal should generate no Journal Entries"

Subscribers

People subscribed via source and target branches