From 53778d4d998e9c5cbe004dd441fa1d9420673281 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 30 May 2013 16:43:21 +0200 Subject: [PATCH 1/7] [add] stock_optional_valuation - skeleton --- stock_optional_valuation/AUTHORS.txt | 1 + stock_optional_valuation/__init__.py | 21 +++++++++++++ stock_optional_valuation/__openerp__.py | 40 +++++++++++++++++++++++++ stock_optional_valuation/stock.py | 22 ++++++++++++++ stock_optional_valuation/stock_view.xml | 5 ++++ 5 files changed, 89 insertions(+) create mode 100644 stock_optional_valuation/AUTHORS.txt create mode 100644 stock_optional_valuation/__init__.py create mode 100644 stock_optional_valuation/__openerp__.py create mode 100644 stock_optional_valuation/stock.py create mode 100644 stock_optional_valuation/stock_view.xml diff --git a/stock_optional_valuation/AUTHORS.txt b/stock_optional_valuation/AUTHORS.txt new file mode 100644 index 000000000..7106ca0eb --- /dev/null +++ b/stock_optional_valuation/AUTHORS.txt @@ -0,0 +1 @@ +Lorenzo Battistini diff --git a/stock_optional_valuation/__init__.py b/stock_optional_valuation/__init__.py new file mode 100644 index 000000000..fcb730754 --- /dev/null +++ b/stock_optional_valuation/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import stock diff --git a/stock_optional_valuation/__openerp__.py b/stock_optional_valuation/__openerp__.py new file mode 100644 index 000000000..e12e7013b --- /dev/null +++ b/stock_optional_valuation/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': "Stock optional valuation", + 'version': '0.1', + 'category': 'Warehouse Management', + 'description': """ +You can choose which stock moves have to generate inventory valutanion accounting entries, by specifying it in the location form. +""", + 'author': 'Agile Business Group', + 'website': 'http://www.agilebg.com', + 'license': 'AGPL-3', + "depends" : ['stock'], + "data" : [ + "stock_view.xml", + ], + "demo" : [], + 'test': [ + ], + "active": False, + "installable": True +} diff --git a/stock_optional_valuation/stock.py b/stock_optional_valuation/stock.py new file mode 100644 index 000000000..5c6ab3230 --- /dev/null +++ b/stock_optional_valuation/stock.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013 Agile Business Group sagl () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import fields, orm +from openerp.tools.translate import _ diff --git a/stock_optional_valuation/stock_view.xml b/stock_optional_valuation/stock_view.xml new file mode 100644 index 000000000..d36ec6161 --- /dev/null +++ b/stock_optional_valuation/stock_view.xml @@ -0,0 +1,5 @@ + + + + + From 8f1a9ee6cdf4bf853af0c956978957bbf519b076 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 30 May 2013 17:22:27 +0200 Subject: [PATCH 2/7] [add] logic --- stock_optional_valuation/stock.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/stock_optional_valuation/stock.py b/stock_optional_valuation/stock.py index 5c6ab3230..9173df154 100644 --- a/stock_optional_valuation/stock.py +++ b/stock_optional_valuation/stock.py @@ -20,3 +20,24 @@ from openerp.osv import fields, orm from openerp.tools.translate import _ + +class stock_location(orm.Model): + _inherit = "stock.location" + + _columns = { + '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"), + } + +class stock_move(orm.Model): + _inherit = "stock.move" + + def _create_product_valuation_moves(self, cr, uid, move, context=None): + if move.location_id.company_id == move.location_dest_id.company_id: + if (move.location_id.usage == 'internal' or + move.location_id.consider_internal) and ( + move.location_dest_id.usage == 'internal' or + move.location_dest_id.consider_internal): + return + res=super(stock_move,self)._create_product_valuation_moves( + cr, uid, move, context=context) + return res From 9d6bd7b988b818ab054f915443c9246690c5a0a1 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 30 May 2013 17:39:00 +0200 Subject: [PATCH 3/7] [add] view --- stock_optional_valuation/stock_view.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stock_optional_valuation/stock_view.xml b/stock_optional_valuation/stock_view.xml index d36ec6161..a121b5629 100644 --- a/stock_optional_valuation/stock_view.xml +++ b/stock_optional_valuation/stock_view.xml @@ -1,5 +1,17 @@ + + stock.location.form + stock.location + + + + + + + + + From 68af6f60c40f63dfe15951c9bb844c0bd4b80c91 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Thu, 30 May 2013 19:26:30 +0200 Subject: [PATCH 4/7] [add] stock_optional_valuation: test --- stock_optional_valuation/__openerp__.py | 13 ++-- stock_optional_valuation/test/stock.yml | 95 +++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 stock_optional_valuation/test/stock.yml diff --git a/stock_optional_valuation/__openerp__.py b/stock_optional_valuation/__openerp__.py index e12e7013b..98fa63eee 100644 --- a/stock_optional_valuation/__openerp__.py +++ b/stock_optional_valuation/__openerp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # Copyright (C) 2013 Agile Business Group sagl () # # This program is free software: you can redistribute it and/or modify @@ -28,13 +28,14 @@ You can choose which stock moves have to generate inventory valutanion accountin 'author': 'Agile Business Group', 'website': 'http://www.agilebg.com', 'license': 'AGPL-3', - "depends" : ['stock'], - "data" : [ + "depends": ['stock'], + "data": [ "stock_view.xml", - ], - "demo" : [], + ], + "demo": [], 'test': [ - ], + 'test/stock.yml' + ], "active": False, "installable": True } diff --git a/stock_optional_valuation/test/stock.yml b/stock_optional_valuation/test/stock.yml new file mode 100644 index 000000000..f91ebee10 --- /dev/null +++ b/stock_optional_valuation/test/stock.yml @@ -0,0 +1,95 @@ +- + I need a product with real time valuation. +- + !record {model: product.product, id: product.product_product_24}: + valuation: real_time + property_stock_account_input: account.o_expense + property_stock_account_output: account.o_income +- + !record {model: stock.picking, id: outgoing_shipment}: + type: out +- + !record {model: stock.move, id: outgoing_shipment_card}: + picking_id: outgoing_shipment + product_id: product.product_product_24 + product_qty: 2.0 + location_id: stock.stock_location_stock + location_dest_id: stock.location_inventory +- + I confirm outgoing shipment of 2 Graphics Cards from Stock to Inventory Loss +- + !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment} +- + I process the picking +- + !python {model: stock.partial.picking}: | + context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment'), 'active_ids': [ref('outgoing_shipment')]}) +- + !record {model: stock.partial.picking, id: partial_outgoing}: + move_ids: + - quantity: 2.0 + product_id: product.product_product_24 + product_uom: product.product_uom_unit + move_id: outgoing_shipment_card + location_id: stock.stock_location_stock + location_dest_id: stock.location_inventory +- + !python {model: stock.partial.picking }: | + self.do_partial(cr, uid, [ref('partial_outgoing')], context=context) +- + My picking should have generated a Journal Entry with the same name +- + !python {model: stock.picking}: | + picking_name = self.browse(cr, uid, ref('outgoing_shipment'), context=context).name + a_move_obj = self.pool.get('account.move') + # count those + a_move_ids = a_move_obj.search(cr, uid, [('ref', '=', picking_name)]) + assert len(a_move_ids) == 1, "An outgoing picking should generate a Journal Entry" +- + Now I will consider the location to be Internal +- + !record {model: stock.location, id: stock.location_inventory}: + consider_internal: True +- + I repeate the process above. Now no Journal Entry should be generated. +- + !record {model: stock.picking, id: outgoing_shipment_as_internal}: + type: out +- + !record {model: stock.move, id: outgoing_shipment_as_internal_card}: + picking_id: outgoing_shipment_as_internal + product_id: product.product_product_24 + product_qty: 2.0 + location_id: stock.stock_location_stock + location_dest_id: stock.location_inventory + +- + I confirm outgoing shipment of 2 Graphics Cards from Stock to Inventory Loss +- + !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment_as_internal} +- + I process the picking +- + !python {model: stock.partial.picking}: | + context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment_as_internal'), 'active_ids': [ref('outgoing_shipment_as_internal')]}) +- + !record {model: stock.partial.picking, id: partial_outgoing}: + move_ids: + - quantity: 2.0 + product_id: product.product_product_24 + product_uom: product.product_uom_unit + move_id: outgoing_shipment_as_internal_card + location_id: stock.stock_location_stock + location_dest_id: stock.location_inventory +- + !python {model: stock.partial.picking }: | + self.do_partial(cr, uid, [ref('partial_outgoing')], context=context) +- + Now there should be no Journal Entries with the same name +- + !python {model: stock.picking }: | + picking_name = self.browse(cr, uid, ref('outgoing_shipment_as_internal'), context=context).name + a_move_obj = self.pool.get('account.move') + # count those + a_move_ids = a_move_obj.search(cr, uid, [('ref', '=', picking_name)]) + assert len(a_move_ids) == 0, "Locations treater as internal should generate no Journal Entries" From 8424be58715107fe1569efa31bcef80dae7c8b86 Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Thu, 30 May 2013 19:29:29 +0200 Subject: [PATCH 5/7] [imp] AUTHORS.txt --- stock_optional_valuation/AUTHORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/stock_optional_valuation/AUTHORS.txt b/stock_optional_valuation/AUTHORS.txt index 7106ca0eb..ce64f52de 100644 --- a/stock_optional_valuation/AUTHORS.txt +++ b/stock_optional_valuation/AUTHORS.txt @@ -1 +1,2 @@ Lorenzo Battistini +Leonardo Pistone From 9bff90f41bb6fea049361df524033e763f37e924 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Wed, 5 Jun 2013 10:18:53 +0200 Subject: [PATCH 6/7] [fix] when company_id is null --- stock_optional_valuation/stock.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/stock_optional_valuation/stock.py b/stock_optional_valuation/stock.py index 9173df154..e0f08a980 100644 --- a/stock_optional_valuation/stock.py +++ b/stock_optional_valuation/stock.py @@ -32,12 +32,14 @@ class stock_move(orm.Model): _inherit = "stock.move" def _create_product_valuation_moves(self, cr, uid, move, context=None): - if move.location_id.company_id == move.location_dest_id.company_id: - if (move.location_id.usage == 'internal' or - move.location_id.consider_internal) and ( - move.location_dest_id.usage == 'internal' or - move.location_dest_id.consider_internal): - return - res=super(stock_move,self)._create_product_valuation_moves( + if (move.location_id.company_id and move.location_dest_id.company_id + and move.location_id.company_id != move.location_dest_id.company_id): + return super(stock_move,self)._create_product_valuation_moves( + cr, uid, move, context=context) + if (move.location_id.usage == 'internal' or + move.location_id.consider_internal) and ( + move.location_dest_id.usage == 'internal' or + move.location_dest_id.consider_internal): + return + return super(stock_move,self)._create_product_valuation_moves( cr, uid, move, context=context) - return res From 57018aab26810871758ab1e1567a0ec10dc0f4c6 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Wed, 19 Jun 2013 18:41:03 +0200 Subject: [PATCH 7/7] [fix] description --- stock_optional_valuation/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_optional_valuation/__openerp__.py b/stock_optional_valuation/__openerp__.py index 98fa63eee..f15fef4c6 100644 --- a/stock_optional_valuation/__openerp__.py +++ b/stock_optional_valuation/__openerp__.py @@ -23,7 +23,7 @@ 'version': '0.1', 'category': 'Warehouse Management', 'description': """ -You can choose which stock moves have to generate inventory valutanion accounting entries, by specifying it in the location form. +You can choose which stock moves have to generate inventory valuation accounting entries, by specifying it in the location form. """, 'author': 'Agile Business Group', 'website': 'http://www.agilebg.com',