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
=== added directory 'stock_optional_valuation'
=== added file 'stock_optional_valuation/AUTHORS.txt'
--- stock_optional_valuation/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ stock_optional_valuation/AUTHORS.txt 2013-06-19 16:43:27 +0000
@@ -0,0 +1,2 @@
1Lorenzo Battistini <lorenzo.battistini@agilebg.com>
2Leonardo Pistone <leonardo.pistone@agilebg.com>
03
=== added file 'stock_optional_valuation/__init__.py'
--- stock_optional_valuation/__init__.py 1970-01-01 00:00:00 +0000
+++ stock_optional_valuation/__init__.py 2013-06-19 16:43:27 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published
8# by the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21import stock
022
=== added file 'stock_optional_valuation/__openerp__.py'
--- stock_optional_valuation/__openerp__.py 1970-01-01 00:00:00 +0000
+++ stock_optional_valuation/__openerp__.py 2013-06-19 16:43:27 +0000
@@ -0,0 +1,41 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published
8# by the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21{
22 'name': "Stock optional valuation",
23 'version': '0.1',
24 'category': 'Warehouse Management',
25 'description': """
26You can choose which stock moves have to generate inventory valuation accounting entries, by specifying it in the location form.
27""",
28 'author': 'Agile Business Group',
29 'website': 'http://www.agilebg.com',
30 'license': 'AGPL-3',
31 "depends": ['stock'],
32 "data": [
33 "stock_view.xml",
34 ],
35 "demo": [],
36 'test': [
37 'test/stock.yml'
38 ],
39 "active": False,
40 "installable": True
41}
042
=== added file 'stock_optional_valuation/stock.py'
--- stock_optional_valuation/stock.py 1970-01-01 00:00:00 +0000
+++ stock_optional_valuation/stock.py 2013-06-19 16:43:27 +0000
@@ -0,0 +1,45 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published
8# by the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from openerp.osv import fields, orm
22from openerp.tools.translate import _
23
24class stock_location(orm.Model):
25 _inherit = "stock.location"
26
27 _columns = {
28 '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"),
29 }
30
31class stock_move(orm.Model):
32 _inherit = "stock.move"
33
34 def _create_product_valuation_moves(self, cr, uid, move, context=None):
35 if (move.location_id.company_id and move.location_dest_id.company_id
36 and move.location_id.company_id != move.location_dest_id.company_id):
37 return super(stock_move,self)._create_product_valuation_moves(
38 cr, uid, move, context=context)
39 if (move.location_id.usage == 'internal' or
40 move.location_id.consider_internal) and (
41 move.location_dest_id.usage == 'internal' or
42 move.location_dest_id.consider_internal):
43 return
44 return super(stock_move,self)._create_product_valuation_moves(
45 cr, uid, move, context=context)
046
=== added file 'stock_optional_valuation/stock_view.xml'
--- stock_optional_valuation/stock_view.xml 1970-01-01 00:00:00 +0000
+++ stock_optional_valuation/stock_view.xml 2013-06-19 16:43:27 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data>
4 <record id="view_location_form" model="ir.ui.view">
5 <field name="name">stock.location.form</field>
6 <field name="model">stock.location</field>
7 <field name="inherit_id" ref="stock.view_location_form"></field>
8 <field name="arch" type="xml">
9 <xpath expr="/form/group" position="inside">
10 <group string="Inventory valuation" groups="stock.group_inventory_valuation">
11 <field name="consider_internal"/>
12 </group>
13 </xpath>
14 </field>
15 </record>
16</data>
17</openerp>
018
=== added directory 'stock_optional_valuation/test'
=== added file 'stock_optional_valuation/test/stock.yml'
--- stock_optional_valuation/test/stock.yml 1970-01-01 00:00:00 +0000
+++ stock_optional_valuation/test/stock.yml 2013-06-19 16:43:27 +0000
@@ -0,0 +1,95 @@
1-
2 I need a product with real time valuation.
3-
4 !record {model: product.product, id: product.product_product_24}:
5 valuation: real_time
6 property_stock_account_input: account.o_expense
7 property_stock_account_output: account.o_income
8-
9 !record {model: stock.picking, id: outgoing_shipment}:
10 type: out
11-
12 !record {model: stock.move, id: outgoing_shipment_card}:
13 picking_id: outgoing_shipment
14 product_id: product.product_product_24
15 product_qty: 2.0
16 location_id: stock.stock_location_stock
17 location_dest_id: stock.location_inventory
18-
19 I confirm outgoing shipment of 2 Graphics Cards from Stock to Inventory Loss
20-
21 !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment}
22-
23 I process the picking
24-
25 !python {model: stock.partial.picking}: |
26 context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment'), 'active_ids': [ref('outgoing_shipment')]})
27-
28 !record {model: stock.partial.picking, id: partial_outgoing}:
29 move_ids:
30 - quantity: 2.0
31 product_id: product.product_product_24
32 product_uom: product.product_uom_unit
33 move_id: outgoing_shipment_card
34 location_id: stock.stock_location_stock
35 location_dest_id: stock.location_inventory
36-
37 !python {model: stock.partial.picking }: |
38 self.do_partial(cr, uid, [ref('partial_outgoing')], context=context)
39-
40 My picking should have generated a Journal Entry with the same name
41-
42 !python {model: stock.picking}: |
43 picking_name = self.browse(cr, uid, ref('outgoing_shipment'), context=context).name
44 a_move_obj = self.pool.get('account.move')
45 # count those
46 a_move_ids = a_move_obj.search(cr, uid, [('ref', '=', picking_name)])
47 assert len(a_move_ids) == 1, "An outgoing picking should generate a Journal Entry"
48-
49 Now I will consider the location to be Internal
50-
51 !record {model: stock.location, id: stock.location_inventory}:
52 consider_internal: True
53-
54 I repeate the process above. Now no Journal Entry should be generated.
55-
56 !record {model: stock.picking, id: outgoing_shipment_as_internal}:
57 type: out
58-
59 !record {model: stock.move, id: outgoing_shipment_as_internal_card}:
60 picking_id: outgoing_shipment_as_internal
61 product_id: product.product_product_24
62 product_qty: 2.0
63 location_id: stock.stock_location_stock
64 location_dest_id: stock.location_inventory
65
66-
67 I confirm outgoing shipment of 2 Graphics Cards from Stock to Inventory Loss
68-
69 !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment_as_internal}
70-
71 I process the picking
72-
73 !python {model: stock.partial.picking}: |
74 context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment_as_internal'), 'active_ids': [ref('outgoing_shipment_as_internal')]})
75-
76 !record {model: stock.partial.picking, id: partial_outgoing}:
77 move_ids:
78 - quantity: 2.0
79 product_id: product.product_product_24
80 product_uom: product.product_uom_unit
81 move_id: outgoing_shipment_as_internal_card
82 location_id: stock.stock_location_stock
83 location_dest_id: stock.location_inventory
84-
85 !python {model: stock.partial.picking }: |
86 self.do_partial(cr, uid, [ref('partial_outgoing')], context=context)
87-
88 Now there should be no Journal Entries with the same name
89-
90 !python {model: stock.picking }: |
91 picking_name = self.browse(cr, uid, ref('outgoing_shipment_as_internal'), context=context).name
92 a_move_obj = self.pool.get('account.move')
93 # count those
94 a_move_ids = a_move_obj.search(cr, uid, [('ref', '=', picking_name)])
95 assert len(a_move_ids) == 0, "Locations treater as internal should generate no Journal Entries"

Subscribers

People subscribed via source and target branches