From 53ec041584dd911eba39cfce6398712d3a9f674d Mon Sep 17 00:00:00 2001 From: Osval Reyes Date: Thu, 26 Nov 2015 14:39:52 -0430 Subject: [PATCH 01/10] [IMP] crm_rma_stock_location: adapt to Odoo v8.0, include view section for product quantities on hand and forecasted, add unittest, add i18n terms --- crm_rma_stock_location/README.rst | 96 +++++++ crm_rma_stock_location/__init__.py | 17 +- crm_rma_stock_location/__openerp__.py | 69 ++--- .../demo/stock_inventory.xml | 28 ++ .../demo/stock_location.xml | 37 +++ .../i18n/crm_rma_stock_location.pot | 218 ++++++++++++++-- crm_rma_stock_location/i18n/es.po | 239 ++++++++++++++++++ crm_rma_stock_location/i18n/es_MX.po | 16 ++ crm_rma_stock_location/i18n/es_PA.po | 16 ++ crm_rma_stock_location/i18n/es_VE.po | 16 ++ crm_rma_stock_location/models/__init__.py | 29 +++ .../models/product_product.py | 131 ++++++++++ .../models/product_template.py | 49 ++++ .../models/stock_warehouse.py | 68 +++++ crm_rma_stock_location/product.py | 106 -------- crm_rma_stock_location/product_view.xml | 28 -- crm_rma_stock_location/stock_data.xml | 15 -- .../stock_warehouse_view.xml | 17 -- crm_rma_stock_location/test/quantity.yml | 72 ------ .../{stock_warehouse.py => tests/__init__.py} | 15 +- .../tests/test_crm_rma_stock_location.py | 78 ++++++ .../tests/test_make_picking_from_picking.py | 159 ++++++++++++ crm_rma_stock_location/views/crm_claim.xml | 19 ++ .../views/product_product.xml | 46 ++++ .../views/product_template.xml | 17 ++ .../views/stock_picking.xml | 30 +++ .../views/stock_warehouse.xml | 16 ++ crm_rma_stock_location/wizards/__init__.py | 24 ++ .../wizards/claim_make_picking.py | 63 +++++ .../claim_make_picking_from_picking.py | 178 +++++++++++++ .../claim_make_picking_from_picking_view.xml | 68 +++++ .../wizards/claim_make_picking_view.xml | 20 ++ 32 files changed, 1700 insertions(+), 300 deletions(-) create mode 100644 crm_rma_stock_location/README.rst create mode 100644 crm_rma_stock_location/demo/stock_inventory.xml create mode 100644 crm_rma_stock_location/demo/stock_location.xml create mode 100644 crm_rma_stock_location/i18n/es.po create mode 100644 crm_rma_stock_location/i18n/es_MX.po create mode 100644 crm_rma_stock_location/i18n/es_PA.po create mode 100644 crm_rma_stock_location/i18n/es_VE.po create mode 100644 crm_rma_stock_location/models/__init__.py create mode 100644 crm_rma_stock_location/models/product_product.py create mode 100644 crm_rma_stock_location/models/product_template.py create mode 100644 crm_rma_stock_location/models/stock_warehouse.py delete mode 100644 crm_rma_stock_location/product.py delete mode 100644 crm_rma_stock_location/product_view.xml delete mode 100644 crm_rma_stock_location/stock_data.xml delete mode 100644 crm_rma_stock_location/stock_warehouse_view.xml delete mode 100644 crm_rma_stock_location/test/quantity.yml rename crm_rma_stock_location/{stock_warehouse.py => tests/__init__.py} (76%) create mode 100644 crm_rma_stock_location/tests/test_crm_rma_stock_location.py create mode 100644 crm_rma_stock_location/tests/test_make_picking_from_picking.py create mode 100644 crm_rma_stock_location/views/crm_claim.xml create mode 100644 crm_rma_stock_location/views/product_product.xml create mode 100644 crm_rma_stock_location/views/product_template.xml create mode 100644 crm_rma_stock_location/views/stock_picking.xml create mode 100644 crm_rma_stock_location/views/stock_warehouse.xml create mode 100644 crm_rma_stock_location/wizards/__init__.py create mode 100644 crm_rma_stock_location/wizards/claim_make_picking.py create mode 100644 crm_rma_stock_location/wizards/claim_make_picking_from_picking.py create mode 100644 crm_rma_stock_location/wizards/claim_make_picking_from_picking_view.xml create mode 100644 crm_rma_stock_location/wizards/claim_make_picking_view.xml diff --git a/crm_rma_stock_location/README.rst b/crm_rma_stock_location/README.rst new file mode 100644 index 00000000..db575389 --- /dev/null +++ b/crm_rma_stock_location/README.rst @@ -0,0 +1,96 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +================== +RMA Stock Location +================== + +Allow the user to know how much for a product is available 'On Hand' and how much +is virtually (expected to be) available for RMA locations. Adding for the +different product views (Tree, Form and Kanban) information about it. + +Both quantities are computed and includes its children locations. + +It is useful use it as a quick snapshot for RMA from product perspective. + +It also adds the following location on warehouses : + + * Loss + * Refurbish + +Various wizards on incoming deliveries that allow you to move your +goods easily in those new locations from a done reception. + +Using this module make the logistic flow of return a bit more complex: + + * Returning product goes into RMA location with a incoming shipment + * From the incoming shipment, forward them to another places (stock, loss, refurbish) + +Installation +============ + +To install this module, just select it from availables modules. + +Configuration +============= + +No configuration is needed + +Usage +===== + +* Go to Sales > After-sale Services and note that 'RMA Quantity On Hand' and + 'RMA Forecasted Quantity' had been included and it'll be shown when at least + a product has either a on hand or forecasted quantities available. + +* In the other hand, it provides three wizards to make stock moves (transfers) + allowing to do product returns (incoming), send a product to loss or, to a refurbish + location. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/8.0/145 + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* Optimization is possible when searching virtual quantities in the search function + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Guewen Baconnier +* Yanina Aular +* Osval Reyes + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/crm_rma_stock_location/__init__.py b/crm_rma_stock_location/__init__.py index 997253d6..9f9433ff 100644 --- a/crm_rma_stock_location/__init__.py +++ b/crm_rma_stock_location/__init__.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Guewen Baconnier +# Copyright 2015 Vauxoo # Copyright 2014 Camptocamp SA +# Author: Guewen Baconnier, +# Osval Reyes # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,5 +21,14 @@ # ############################################################################## -from . import stock_warehouse -from . import product +from . import models +from . import wizards +from openerp import SUPERUSER_ID + + +def post_init_hook(cr, registry): + stock_wh = registry['stock.warehouse'] + for wh_id in stock_wh.browse(cr, SUPERUSER_ID, + stock_wh.search(cr, SUPERUSER_ID, [])): + vals = stock_wh.create_locations_rma(cr, SUPERUSER_ID, wh_id) + stock_wh.write(cr, SUPERUSER_ID, wh_id.id, vals) diff --git a/crm_rma_stock_location/__openerp__.py b/crm_rma_stock_location/__openerp__.py index 08318cbb..3f98a80b 100644 --- a/crm_rma_stock_location/__openerp__.py +++ b/crm_rma_stock_location/__openerp__.py @@ -1,8 +1,13 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Guewen Baconnier -# Copyright 2014 Camptocamp SA +# Copyright 2015 Vauxoo +# Copyright 2013-2014 Camptocamp SA +# Copyright 2009-2013 Akretion, +# Author: Guewen Baconnier, +# Emmanuel Samyn, Raphaël Valyi, Sébastien Beau, +# Joel Grand-Guillaume, +# Yanina Aular, Osval Reyes # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,31 +24,35 @@ # ############################################################################## -{'name': 'RMA Stock Location', - 'version': '1.0', - 'author': "Camptocamp,Odoo Community Association (OCA)", - 'maintainer': 'Camptocamp', - 'license': 'AGPL-3', - 'category': 'Generic Modules/CRM & SRM', - 'depends': ['stock', - 'procurement', - ], - 'description': """ -RMA Stock Location -================== - -A RMA location can be selected on the warehouses. -The product views displays the quantity available and virtual in this - RMA location (including the children locations). - - """, - 'website': 'http://www.camptocamp.com', - 'data': ['stock_data.xml', - 'stock_warehouse_view.xml', - 'product_view.xml', - ], - 'test': ['test/quantity.yml', - ], - 'installable': False, - 'auto_install': False, - } +{ + 'name': 'RMA Stock Location', + 'version': '8.0.1.0.0', + 'author': "Akretion,Vauxoo,Camptocamp,Odoo Community Association (OCA)", + 'maintainer': 'Camptocamp', + 'website': 'http://www.camptocamp.com,http://www.vauxoo.com', + 'license': 'AGPL-3', + 'category': 'Generic Modules/CRM & SRM', + 'depends': [ + 'crm_claim_rma', + 'crm_claim', + 'stock_account', + 'procurement', + 'crm_rma_location', + ], + 'data': [ + 'wizards/claim_make_picking_from_picking_view.xml', + 'wizards/claim_make_picking_view.xml', + 'views/product_product.xml', + 'views/product_template.xml', + 'views/crm_claim.xml', + 'views/stock_picking.xml', + 'views/stock_warehouse.xml', + ], + 'demo': [ + 'demo/stock_location.xml', + 'demo/stock_inventory.xml', + ], + 'post_init_hook': 'post_init_hook', + 'installable': True, + 'auto_install': False, +} diff --git a/crm_rma_stock_location/demo/stock_inventory.xml b/crm_rma_stock_location/demo/stock_inventory.xml new file mode 100644 index 00000000..729a9d35 --- /dev/null +++ b/crm_rma_stock_location/demo/stock_inventory.xml @@ -0,0 +1,28 @@ + + + + + Demo Stock Move: Customer > RMA + + 1 + 1000 + + 1 + + + + + + Demo Stock Move: RMA > Loss + + 1 + 1000 + + 1 + + + + + + + diff --git a/crm_rma_stock_location/demo/stock_location.xml b/crm_rma_stock_location/demo/stock_location.xml new file mode 100644 index 00000000..19d2ded1 --- /dev/null +++ b/crm_rma_stock_location/demo/stock_location.xml @@ -0,0 +1,37 @@ + + + + + + RMA Demo + internal + + + + + + + + RMA - Box A + + internal + + + RMA - Box B + + internal + + + + Socket + + 70.0 + 100.0 + product + + + + + + + diff --git a/crm_rma_stock_location/i18n/crm_rma_stock_location.pot b/crm_rma_stock_location/i18n/crm_rma_stock_location.pot index a9c52f83..444f0d7e 100644 --- a/crm_rma_stock_location/i18n/crm_rma_stock_location.pot +++ b/crm_rma_stock_location/i18n/crm_rma_stock_location.pot @@ -1,13 +1,13 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: -# * crm_rma_stock_location +# * crm_rma_stock_location # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-12 11:27+0000\n" -"PO-Revision-Date: 2014-09-12 11:27+0000\n" +"POT-Creation-Date: 2015-11-25 21:48+0000\n" +"PO-Revision-Date: 2015-11-25 21:48+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,39 +16,221 @@ msgstr "" "Plural-Forms: \n" #. module: crm_rma_stock_location -#: model:ir.model.fields,field_description:crm_rma_stock_location.field_stock_warehouse_lot_rma_id -#: field:stock.warehouse,lot_rma_id:0 -msgid "Location RMA" +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Cancel" msgstr "" #. module: crm_rma_stock_location -#: code:_description:0 -#: model:ir.model,name:crm_rma_stock_location.model_product_product +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_loss_picking_from_claim_picking +msgid "Create Incoming Shipment to Breakage Loss Location" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_used_picking_from_claim_picking +msgid "Create Incoming Shipment to Refurbish Location" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_stock_picking_from_claim_picking +msgid "Create Incoming Shipment to Stock" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_claim_picking_loss +msgid "Create a Product Loss" +msgstr "" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Create picking" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,create_date:0 +msgid "Created on" +msgstr "" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py:89 +#: field:claim.make.picking.from.picking.wizard,picking_line_dest_location:0 #, python-format +msgid "Dest. Location" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,id:0 +msgid "ID" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: crm_rma_stock_location +#: help:claim.make.picking.from.picking.wizard,picking_line_source_location:0 +msgid "Source location where the returned products are" +msgstr "" + +#. module: crm_rma_stock_location +#: help:claim.make.picking.from.picking.wizard,picking_line_dest_location:0 +msgid "Target location to send returned products" +msgstr "" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Locations" +msgstr "" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/stock_warehouse.py:62 +#, python-format +msgid "Loss" +msgstr "" + +#. module: crm_rma_stock_location +#: field:stock.warehouse,loss_loc_id:0 +msgid "Loss Location" +msgstr "" + +#. module: crm_rma_stock_location +#: view:crm.claim:crm_rma_stock_location.crm_claim_rma_form_view_loss +msgid "New Product Loss" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,picking_line_ids:0 +msgid "Picking lines" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_product_product msgid "Product" msgstr "" #. module: crm_rma_stock_location -#: model:stock.location,name:crm_rma_stock_location.stock_location_rma -msgid "RMA" +#: model:ir.model,name:crm_rma_stock_location.model_product_template +msgid "Product Template" msgstr "" #. module: crm_rma_stock_location -#: model:ir.model.fields,field_description:crm_rma_stock_location.field_product_product_rma_virtual_available -#: field:product.product,rma_virtual_available:0 +#: view:product.product:crm_rma_stock_location.rma_product_product_tree_view +msgid "Product Variants" +msgstr "" + +#. module: crm_rma_stock_location +#: view:stock.picking:crm_rma_stock_location.picking_in_form +msgid "Product to Loss" +msgstr "" + +#. module: crm_rma_stock_location +#: view:stock.picking:crm_rma_stock_location.picking_in_form +msgid "Product to refurbish stock" +msgstr "" + + +#. module: crm_rma_stock_location +#: view:stock.picking:crm_rma_stock_location.picking_in_form +msgid "Product to stock" +msgstr "" + +#. module: crm_rma_stock_location +#: model:stock.location,name:crm_rma_stock_location.location_rma_a +msgid "RMA - Box A" +msgstr "" + +#. module: crm_rma_stock_location +#: model:stock.location,name:crm_rma_stock_location.location_rma_b +msgid "RMA - Box B" +msgstr "" + +#. module: crm_rma_stock_location +#: view:product.product:crm_rma_stock_location.rma_product_search_view +msgid "RMA Available Products" +msgstr "" + +#. module: crm_rma_stock_location +#: model:stock.location,name:crm_rma_stock_location.location_rma +msgid "RMA Demo" +msgstr "" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/product_product.py:42 +#, python-format msgid "RMA Forecasted Quantity" msgstr "" #. module: crm_rma_stock_location -#: model:ir.model.fields,field_description:crm_rma_stock_location.field_product_product_rma_qty_available -#: field:product.product,rma_qty_available:0 +#: view:product.product:crm_rma_stock_location.rma_product_search_view +msgid "RMA Products" +msgstr "" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/product_product.py:36 +#, python-format msgid "RMA Quantity On Hand" msgstr "" #. module: crm_rma_stock_location -#: code:_description:0 -#: model:ir.model,name:crm_rma_stock_location.model_stock_warehouse +#: code:addons/crm_rma_stock_location/models/stock_warehouse.py:56 #, python-format +msgid "Refurbish" +msgstr "" + +#. module: crm_rma_stock_location +#: field:stock.warehouse,lot_refurbish_id:0 +msgid "Refurbish Location" +msgstr "" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Select lines for picking" +msgstr "" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Select lines to add in picking" +msgstr "" + +#. module: crm_rma_stock_location +#: model:product.template,name:crm_rma_stock_location.product_socket_product_template +msgid "Socket" +msgstr "" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py:85 +#: field:claim.make.picking.from.picking.wizard,picking_line_source_location:0 +#, python-format +msgid "Source Location" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.rma_product_variant_action +#: model:ir.ui.menu,name:crm_rma_stock_location.menu_stock_rma +msgid "RMA Stock" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_stock_warehouse msgid "Warehouse" msgstr "" +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_claim_make_picking_wizard +msgid "Wizard to create pickings from claim lines" +msgstr "" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_claim_make_picking_from_picking_wizard +msgid "Wizard to create pickings from picking lines" +msgstr "" diff --git a/crm_rma_stock_location/i18n/es.po b/crm_rma_stock_location/i18n/es.po new file mode 100644 index 00000000..e173f387 --- /dev/null +++ b/crm_rma_stock_location/i18n/es.po @@ -0,0 +1,239 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_rma_stock_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-25 21:48+0000\n" +"PO-Revision-Date: 2015-11-25 21:48+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Cancel" +msgstr "Cancelar" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_loss_picking_from_claim_picking +msgid "Create Incoming Shipment to Breakage Loss Location" +msgstr "Crear un envío de entrada hacia la ubicación de pérdida de productos dañados" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_used_picking_from_claim_picking +msgid "Create Incoming Shipment to Refurbish Location" +msgstr "Crear un envío de entrada hacia la ubicación de productos restaurados" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_stock_picking_from_claim_picking +msgid "Create Incoming Shipment to Stock" +msgstr "Crear un envío de entrada a Existencias" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.action_claim_picking_loss +msgid "Create a Product Loss" +msgstr "Registrar una pérdida de producto" + + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Create picking" +msgstr "Crear un albarán" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,create_uid:0 +msgid "Created by" +msgstr "Creado por" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,create_date:0 +msgid "Created on" +msgstr "Creado el" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py:89 +#: field:claim.make.picking.from.picking.wizard,picking_line_dest_location:0 +#, python-format +msgid "Dest. Location" +msgstr "Ubicación destino" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,id:0 +msgid "ID" +msgstr "" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,write_uid:0 +msgid "Last Updated by" +msgstr "Actualizado por" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,write_date:0 +msgid "Last Updated on" +msgstr "Actualizado el" + +#. module: crm_rma_stock_location +#: help:claim.make.picking.from.picking.wizard,picking_line_source_location:0 +msgid "Source location where the returned products are" +msgstr "Ubicación origen de los productos devueltos" + +#. module: crm_rma_stock_location +#: help:claim.make.picking.from.picking.wizard,picking_line_dest_location:0 +msgid "Target location to send returned products" +msgstr "Ubicación destino de los productos devueltos" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Locations" +msgstr "Ubicaciones" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/stock_warehouse.py:62 +#, python-format +msgid "Loss" +msgstr "Pérdida" + +#. module: crm_rma_stock_location +#: field:stock.warehouse,loss_loc_id:0 +msgid "Loss Location" +msgstr "Ubicación de Pérdida" + +#. module: crm_rma_stock_location +#: view:crm.claim:crm_rma_stock_location.crm_claim_rma_form_view_loss +msgid "New Product Loss" +msgstr "Nueva Pérdida de Producto" + +#. module: crm_rma_stock_location +#: field:claim.make.picking.from.picking.wizard,picking_line_ids:0 +msgid "Picking lines" +msgstr "Líneas de albarán" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_product_product +msgid "Product" +msgstr "Producto" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_product_template +msgid "Product Template" +msgstr "Producto Plantilla" + +#. module: crm_rma_stock_location +#: view:product.product:crm_rma_stock_location.rma_product_product_tree_view +msgid "Product Variants" +msgstr "Variantes del Producto" + +#. module: crm_rma_stock_location +#: view:stock.picking:crm_rma_stock_location.picking_in_form +msgid "Product to Loss" +msgstr "Producto a Pérdida" + +#. module: crm_rma_stock_location +#: view:stock.picking:crm_rma_stock_location.picking_in_form +msgid "Product to refurbish stock" +msgstr "Producto a Existencias de restaurados" + + +#. module: crm_rma_stock_location +#: view:stock.picking:crm_rma_stock_location.picking_in_form +msgid "Product to stock" +msgstr "Producto a Existencias" + +#. module: crm_rma_stock_location +#: model:stock.location,name:crm_rma_stock_location.location_rma_a +msgid "RMA - Box A" +msgstr "RMA - Caja A" + +#. module: crm_rma_stock_location +#: model:stock.location,name:crm_rma_stock_location.location_rma_b +msgid "RMA - Box B" +msgstr "RMA - Caja B" + +#. module: crm_rma_stock_location +#: view:product.product:crm_rma_stock_location.rma_product_search_view +msgid "RMA Available Products" +msgstr "Productos disponibles en RMA" + +#. module: crm_rma_stock_location +#: model:stock.location,name:crm_rma_stock_location.location_rma +msgid "RMA Demo" +msgstr "Demostración RMA" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/product_product.py:42 +#: code:addons/crm_rma_stock_location/models/product_template.py:42 +#, python-format +msgid "RMA Forecasted Quantity" +msgstr "Pronóstico de Cantidades en RMA" + +#. module: crm_rma_stock_location +#: view:product.product:crm_rma_stock_location.rma_product_search_view +msgid "RMA Products" +msgstr "Productos en RMA" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/product_product.py:36 +#: code:addons/crm_rma_stock_location/models/product_template.py:36 +#, python-format +msgid "RMA Quantity On Hand" +msgstr "Cantidades Disponibles en RMA" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/models/stock_warehouse.py:56 +#, python-format +msgid "Refurbish" +msgstr "Restaurar" + +#. module: crm_rma_stock_location +#: field:stock.warehouse,lot_refurbish_id:0 +msgid "Refurbish Location" +msgstr "Ubicación de Restaurados" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Select lines for picking" +msgstr "Seleccionar lineas para albarán" + +#. module: crm_rma_stock_location +#: view:claim.make.picking.from.picking.wizard:crm_rma_stock_location.view_claim_picking_from_picking +msgid "Select lines to add in picking" +msgstr "Seleccionar lineas a agregar en albarán" + +#. module: crm_rma_stock_location +#: model:product.template,name:crm_rma_stock_location.product_socket_product_template +msgid "Socket" +msgstr "Sócate" + +#. module: crm_rma_stock_location +#: code:addons/crm_rma_stock_location/wizards/claim_make_picking_from_picking.py:85 +#: field:claim.make.picking.from.picking.wizard,picking_line_source_location:0 +#, python-format +msgid "Source Location" +msgstr "Ubicación origen" + +#. module: crm_rma_stock_location +#: model:ir.actions.act_window,name:crm_rma_stock_location.rma_product_variant_action +#: model:ir.ui.menu,name:crm_rma_stock_location.menu_stock_rma +msgid "RMA Stock" +msgstr "Existencias en RMA" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_stock_warehouse +msgid "Warehouse" +msgstr "Almacén" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_claim_make_picking_wizard +msgid "Wizard to create pickings from claim lines" +msgstr "Asistente para create albaranes desde lineas de reclamo" + +#. module: crm_rma_stock_location +#: model:ir.model,name:crm_rma_stock_location.model_claim_make_picking_from_picking_wizard +msgid "Wizard to create pickings from picking lines" +msgstr "Asistente para create albaranes desde lineas de albaranes" diff --git a/crm_rma_stock_location/i18n/es_MX.po b/crm_rma_stock_location/i18n/es_MX.po new file mode 100644 index 00000000..c9158d37 --- /dev/null +++ b/crm_rma_stock_location/i18n/es_MX.po @@ -0,0 +1,16 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_rma_stock_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-18 00:48+0000\n" +"PO-Revision-Date: 2015-07-18 00:48+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" diff --git a/crm_rma_stock_location/i18n/es_PA.po b/crm_rma_stock_location/i18n/es_PA.po new file mode 100644 index 00000000..c9158d37 --- /dev/null +++ b/crm_rma_stock_location/i18n/es_PA.po @@ -0,0 +1,16 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_rma_stock_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-18 00:48+0000\n" +"PO-Revision-Date: 2015-07-18 00:48+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" diff --git a/crm_rma_stock_location/i18n/es_VE.po b/crm_rma_stock_location/i18n/es_VE.po new file mode 100644 index 00000000..c9158d37 --- /dev/null +++ b/crm_rma_stock_location/i18n/es_VE.po @@ -0,0 +1,16 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_rma_stock_location +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-18 00:48+0000\n" +"PO-Revision-Date: 2015-07-18 00:48+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" diff --git a/crm_rma_stock_location/models/__init__.py b/crm_rma_stock_location/models/__init__.py new file mode 100644 index 00000000..cbce7ada --- /dev/null +++ b/crm_rma_stock_location/models/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright 2015 Vauxoo +# Copyright 2013-2014 Camptocamp SA +# Copyright 2009-2013 Akretion, +# Author: Guewen Baconnier, +# Emmanuel Samyn, Raphaël Valyi, Sébastien Beau, +# Joel Grand-Guillaume, +# Osval Reyes +# +# 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 . import product_product +from . import product_template +from . import stock_warehouse diff --git a/crm_rma_stock_location/models/product_product.py b/crm_rma_stock_location/models/product_product.py new file mode 100644 index 00000000..8e950ddb --- /dev/null +++ b/crm_rma_stock_location/models/product_product.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2014 Camptocamp SA +# +# 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 import _, models, fields +import openerp.addons.decimal_precision as dp +from openerp.tools.float_utils import float_round +from openerp.tools.safe_eval import safe_eval as eval + + +class ProductProduct(models.Model): + + _inherit = 'product.product' + + rma_qty_available = fields.Float( + compute='_rma_product_available', + digits_compute=dp.get_precision('Product Unit of Measure'), + search='_search_rma_product_quantity', + string=_('RMA Quantity On Hand')) + + rma_virtual_available = fields.Float( + compute='_rma_product_available', + digits_compute=dp.get_precision('Product Unit of Measure'), + search='_search_rma_product_quantity', + string=_('RMA Forecasted Quantity')) + + def _search_rma_product_quantity(self, operator, value): + res = [] + # to prevent sql injections + assert operator in ('<', '>', '=', '!=', + '<=', '>='), 'Invalid domain operator' + assert isinstance(value, (float, int)), 'Invalid domain right operand' + + if operator == '=': + operator = '==' + + ids = [] + product_ids = self.search([]) + if product_ids: + for element in product_ids: + localdict = {'virtual': element.rma_virtual_available, + 'qty': element.rma_qty_available, + 'value': value} + if eval('qty %s value or virtual %s value' % + (operator, operator), localdict): + ids.append(element.id) + res.append(('id', 'in', ids)) + return res + + def _rma_product_available(self): + """ + Finds the incoming and outgoing quantity of product for the RMA + locations. + """ + context = self.env.context + warehouse_id = context.get('warehouse_id') + ctx = context.copy() + location_ids = set() + for product in self: + if warehouse_id and warehouse_id.lot_rma_id: + location_ids.add(warehouse_id.lot_rma_id.id) + else: + warehouse_ids = self.env['stock.warehouse'].search([]) + if not warehouse_ids: + return + for warehouse_id in warehouse_ids: + if warehouse_id.lot_rma_id: + location_ids.add(warehouse_id.lot_rma_id.id) + + if not location_ids: + return + ctx['location'] = list(location_ids) + + domain_products = [('product_id', 'in', [product.id])] + domain_quant, domain_move_in, domain_move_out = \ + product.with_context(ctx)._get_domain_locations() + domain_move_in += product.with_context(ctx)._get_domain_dates() + \ + [('state', 'not in', ('done', 'cancel', 'draft'))] + \ + domain_products + domain_move_out += product.with_context(ctx).\ + _get_domain_dates() + \ + [('state', 'not in', ('done', 'cancel', 'draft'))] + \ + domain_products + domain_quant += domain_products + moves_in = [] + moves_out = [] + lot_id = context.get('lot_id') + if lot_id: + domain_quant.append(('lot_id', '=', lot_id)) + else: + moves_in = self.env['stock.move'].\ + with_context(ctx).read_group(domain_move_in, + ['product_id', 'product_qty'], + ['product_id']) + moves_out = self.env['stock.move'].\ + with_context(ctx).read_group(domain_move_out, + ['product_id', 'product_qty'], + ['product_id']) + quants = self.env['stock.quant'].with_context(ctx).read_group( + domain_quant, ['product_id', 'qty'], ['product_id']) + quants = dict([(item.get('product_id')[0], + item.get('qty')) for item in quants]) + moves_in = dict([(item.get('product_id')[0], + item.get('product_qty')) for item in moves_in]) + moves_out = dict([(item.get('product_id')[0], + item.get('product_qty')) for item in moves_out]) + product.rma_qty_available = \ + float_round(quants.get(product.id, 0.0), + precision_rounding=product.uom_id.rounding) + product.rma_virtual_available = \ + float_round(quants.get(product.id, 0.0) + + moves_in.get(product.id, 0.0) - + moves_out.get(product.id, 0.0), + precision_rounding=product.uom_id.rounding) diff --git a/crm_rma_stock_location/models/product_template.py b/crm_rma_stock_location/models/product_template.py new file mode 100644 index 00000000..7bf733c4 --- /dev/null +++ b/crm_rma_stock_location/models/product_template.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright 2015 Vauxoo +# Copyright 2014 Camptocamp SA +# Author: Guewen Baconnier, +# Osval Reyes +# +# 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 import _, models, fields +import openerp.addons.decimal_precision as dp + + +class ProductTemplate(models.Model): + + _inherit = 'product.template' + + rma_qty_available = fields.Float(compute='_rma_product_available', + digits_compute=dp. + get_precision('Product Unit ' + 'of Measure'), + string=_('RMA Quantity On Hand')) + + rma_virtual_available = fields.Float(compute='_rma_product_available', + digits_compute=dp. + get_precision('Product Unit' + ' of Measure'), + string=_('RMA Forecasted Quantity')) + + def _rma_product_available(self): + for product in self: + product.rma_qty_available = sum( + [p.rma_qty_available for p in product.product_variant_ids]) + product.rma_virtual_available = sum( + [p.rma_virtual_available for p in product.product_variant_ids]) diff --git a/crm_rma_stock_location/models/stock_warehouse.py b/crm_rma_stock_location/models/stock_warehouse.py new file mode 100644 index 00000000..88a63625 --- /dev/null +++ b/crm_rma_stock_location/models/stock_warehouse.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright 2013 Camptocamp +# Copyright 2009-2013 Akretion, +# Author: Emmanuel Samyn, Raphaël Valyi, Sébastien Beau, +# Joel Grand-Guillaume +# +# 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 import _, api, fields, models + + +class StockWarehouse(models.Model): + + _inherit = "stock.warehouse" + + loss_loc_id = fields.Many2one('stock.location', 'Loss Location') + + lot_refurbish_id = fields.Many2one('stock.location', 'Refurbish Location') + + @api.model + def create_locations_rma(self, wh_id): + vals = {} + + location_obj = self.env['stock.location'] + context_with_inactive = self.env.context.copy() + context_with_inactive['active_test'] = False + wh_loc_id = wh_id.view_location_id.id + + vals_new = super(StockWarehouse, self).create_locations_rma(wh_id) + + loc_vals = { + 'usage': 'internal', + 'location_id': wh_loc_id, + 'active': True, + } + + if vals.get('company_id'): + loc_vals['company_id'] = vals.get('company_id') + + if not wh_id.lot_refurbish_id: + loc_vals.update({'name': _('Refurbish')}) + location_id = location_obj.with_context(context_with_inactive).\ + create(loc_vals) + vals['lot_refurbish_id'] = location_id.id + + if not wh_id.loss_loc_id: + loc_vals.update({'name': _('Loss')}) + location_id = location_obj.with_context(context_with_inactive).\ + create(loc_vals) + vals['loss_loc_id'] = location_id.id + + vals.update(vals_new) + return vals diff --git a/crm_rma_stock_location/product.py b/crm_rma_stock_location/product.py deleted file mode 100644 index 114bbaf4..00000000 --- a/crm_rma_stock_location/product.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Guewen Baconnier -# Copyright 2014 Camptocamp SA -# -# 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 orm, fields -import openerp.addons.decimal_precision as dp - - -class ProductProduct(orm.Model): - _inherit = 'product.product' - - def _rma_product_available(self, cr, uid, ids, field_names=None, arg=False, - context=None): - """ Finds the incoming and outgoing quantity of product for the RMA - locations. - """ - if field_names is None: - field_names = [] - if context is None: - context = {} - warehouse_obj = self.pool['stock.warehouse'] - res = {} - for id in ids: - res[id] = {}.fromkeys(field_names, 0.0) - - for field in field_names: - ctx = context.copy() - - warehouse_id = ctx.get('warehouse_id') - # no dependency on 'sale', the same oddness is done in - # 'stock' so I kept it here - if ctx.get('shop') and self.pool.get('sale.shop'): - shop_obj = self.pool['sale.shop'] - shop_id = ctx['shop'] - warehouse = shop_obj.read(cr, uid, shop_id, - ['warehouse_id'], - context=ctx) - warehouse_id = warehouse['warehouse_id'][0] - - if warehouse_id: - rma_id = warehouse_obj.read(cr, uid, - warehouse_id, - ['lot_rma_id'], - context=ctx)['lot_rma_id'][0] - if rma_id: - ctx['location'] = rma_id - else: - location_ids = set() - wids = warehouse_obj.search(cr, uid, [], context=context) - if not wids: - return res - for wh in warehouse_obj.browse(cr, uid, wids, context=context): - if wh.lot_rma_id: - location_ids.add(wh.lot_rma_id.id) - if not location_ids: - return res - ctx['location'] = list(location_ids) - - ctx['compute_child'] = True - compute = { - 'rma_qty_available': { - 'states': ('done', ), - 'what': ('in', 'out') - }, - 'rma_virtual_available': { - 'states': ('confirmed', 'waiting', 'assigned', 'done'), - 'what': ('in', 'out') - } - } - ctx.update(compute[field]) - stock = self.get_product_available(cr, uid, ids, context=ctx) - for id in ids: - res[id][field] = stock.get(id, 0.0) - return res - - _columns = { - 'rma_qty_available': fields.function( - _rma_product_available, - type='float', - multi='rma_qty', - digits_compute=dp.get_precision('Product Unit of Measure'), - string='RMA Quantity On Hand'), - 'rma_virtual_available': fields.function( - _rma_product_available, - type='float', - multi='rma_qty', - digits_compute=dp.get_precision('Product Unit of Measure'), - string='RMA Forecasted Quantity'), - } diff --git a/crm_rma_stock_location/product_view.xml b/crm_rma_stock_location/product_view.xml deleted file mode 100644 index c371eead..00000000 --- a/crm_rma_stock_location/product_view.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - product.product.tree - product.product - - - - - - - - - - - product.normal.procurement.locations.inherit - product.product - - - - - - - - - - diff --git a/crm_rma_stock_location/stock_data.xml b/crm_rma_stock_location/stock_data.xml deleted file mode 100644 index d50b3f38..00000000 --- a/crm_rma_stock_location/stock_data.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - RMA - internal - - - - - - - - diff --git a/crm_rma_stock_location/stock_warehouse_view.xml b/crm_rma_stock_location/stock_warehouse_view.xml deleted file mode 100644 index 82c72292..00000000 --- a/crm_rma_stock_location/stock_warehouse_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - view_warehouse_form - stock.warehouse - - - - - - - - - - diff --git a/crm_rma_stock_location/test/quantity.yml b/crm_rma_stock_location/test/quantity.yml deleted file mode 100644 index 96a77e7b..00000000 --- a/crm_rma_stock_location/test/quantity.yml +++ /dev/null @@ -1,72 +0,0 @@ -- - I create RMA locations -- - !record {model: stock.location, id: location_rma}: - name: RMA - usage: view -- - !record {model: stock.location, id: location_rma_a}: - name: RMA - Box A - usage: internal - location_id: location_rma -- - !record {model: stock.location, id: location_rma_b}: - name: RMA - Box B - usage: internal - location_id: location_rma -- - I set the RMA location on the warehouse -- - !record {model: stock.warehouse, id: stock.warehouse0}: - lot_rma_id: location_rma -- - I create a product -- - !record {model: product.product, id: product_socket}: - default_code: 002 - name: Sockets - type: product - categ_id: product.product_category_1 - list_price: 100.0 - standard_price: 70.0 - uom_id: product.product_uom_unit - uom_po_id: product.product_uom_unit -- - I create a physical inventory with 50 units in Box A and 30 in Box B -- - !record {model: stock.inventory, id: stock_inventory_socket}: - name: Inventory for Sockets -- - !record {model: stock.inventory.line, id: stock_inventory_line_socket_1}: - product_id: product_socket - product_uom: product.product_uom_unit - inventory_id: stock_inventory_socket - product_qty: 50.0 - location_id: location_rma_a -- - !record {model: stock.inventory.line, id: stock_inventory_line_socket_2}: - product_id: product_socket - product_uom: product.product_uom_unit - inventory_id: stock_inventory_socket - product_qty: 30.0 - location_id: location_rma_b -- - I confirm the physical inventory -- - !python {model: stock.inventory}: | - self.action_confirm(cr, uid, [ref('stock_inventory_socket')], context=context) -- - I confirm the move in Box A -- - !python {model: stock.inventory}: | - inventory = self.browse(cr, uid, ref('stock_inventory_socket'), context=context) - assert len(inventory.move_ids) == len(inventory.inventory_line_id), "moves are not correspond." - for move in inventory.move_ids: - if move.location_dest_id.id == ref('location_rma_a'): - move.action_done() -- - I check my RMA quantities, I should have 50 on hands and 80 forecasted -- - !assert {model: product.product, id: product_socket, string: RMA quantity is wrong}: - - rma_qty_available == 50 - - rma_virtual_available == 80 diff --git a/crm_rma_stock_location/stock_warehouse.py b/crm_rma_stock_location/tests/__init__.py similarity index 76% rename from crm_rma_stock_location/stock_warehouse.py rename to crm_rma_stock_location/tests/__init__.py index 13f32c31..38cc02d5 100644 --- a/crm_rma_stock_location/stock_warehouse.py +++ b/crm_rma_stock_location/tests/__init__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Guewen Baconnier -# Copyright 2014 Camptocamp SA +# Copyright 2015 Vauxoo +# Author: Yanina Aular, Osval Reyes # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,12 +19,5 @@ # ############################################################################## -from openerp.osv import orm, fields - - -class StockWarehouse(orm.Model): - _inherit = 'stock.warehouse' - - _columns = { - 'lot_rma_id': fields.many2one('stock.location', 'Location RMA'), - } +from . import test_crm_rma_stock_location +from . import test_make_picking_from_picking diff --git a/crm_rma_stock_location/tests/test_crm_rma_stock_location.py b/crm_rma_stock_location/tests/test_crm_rma_stock_location.py new file mode 100644 index 00000000..f743eff3 --- /dev/null +++ b/crm_rma_stock_location/tests/test_crm_rma_stock_location.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright 2015 Vauxoo +# Author: Osval Reyes +# +# 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.tests.common import TransactionCase + + +class TestCrmRmaStockLocation(TransactionCase): + + def setUp(self): + super(TestCrmRmaStockLocation, self).setUp() + self.inventory = self.env['stock.inventory'] + self.inventory_line = self.env['stock.inventory.line'] + self.location_id = self.env['stock.location'].search( + [('name', '=', 'RMA'), ('location_id.name', '=', 'WH')]) + self.warehouse_id = self.env['stock.warehouse'].browse( + self.ref('stock.warehouse0')) + self.lot_rma_id = self.warehouse_id.lot_rma_id + self.product_uom_id = self.ref('product.product_uom_unit') + self.product_socket_id = self.env['product.product'].browse( + self.ref('crm_rma_stock_location.product_socket')) + + def test_01_test(self): + inventory_id = self.inventory.create({ + 'name': 'Test Inventory 001', + 'location_id': self.location_id.id, + 'filter': 'product', + 'product_id': self.product_socket_id.id, + }) + + inventory_line_id_a = self.inventory_line.create({ + 'inventory_id': inventory_id.id, + 'product_id': self.product_socket_id.id, + 'product_uom_id': self.product_uom_id, + 'product_qty': 100, + 'location_id': self.lot_rma_id.id + }) + + inventory_line_id_b = self.inventory_line.create({ + 'inventory_id': inventory_id.id, + 'product_id': self.product_socket_id.id, + 'product_uom_id': self.product_uom_id, + 'product_qty': 10, + 'location_id': self.lot_rma_id.id + }) + + inventory_id.prepare_inventory() + inventory_id.action_done() + qty = inventory_line_id_a.product_qty + inventory_line_id_b.product_qty + self.assertEquals(self.product_socket_id.rma_qty_available, qty) + self.assertEquals(self.product_socket_id.rma_virtual_available, qty) + + self.assertEquals( + self.product_socket_id.product_tmpl_id.rma_qty_available, qty) + self.assertEquals( + self.product_socket_id.product_tmpl_id.rma_virtual_available, qty) + + res = self.product_socket_id._search_rma_product_quantity( + '=', + inventory_line_id_a.product_qty + inventory_line_id_b.product_qty) + self.assertEquals(self.product_socket_id.id, res[0][2][0]) diff --git a/crm_rma_stock_location/tests/test_make_picking_from_picking.py b/crm_rma_stock_location/tests/test_make_picking_from_picking.py new file mode 100644 index 00000000..c39ebbe4 --- /dev/null +++ b/crm_rma_stock_location/tests/test_make_picking_from_picking.py @@ -0,0 +1,159 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Yanina Aular +# Copyright 2015 Vauxoo +# +# 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.tests.common import TransactionCase + + +class TestPickingFromPicking(TransactionCase): + + def setUp(self): + super(TestPickingFromPicking, self).setUp() + self.stock_warehouse = self.env['stock.warehouse'] + self.claim_id = self.create_claim() + self.wizardmakepicking = self.env['claim_make_picking.wizard'] + self.claim_picking_wizard = \ + self.env['claim.make.picking.from.picking.wizard'] + self.get_default_locations() + + def create_claim(self): + claim_id = self.env['crm.claim'].browse( + self.ref("crm_claim.crm_claim_6")) + + claim_id.write({ + 'claim_line_ids': [(0, 0, { + 'name': str(claim_id.id) + 'test 1', + 'claim_origin': u'damaged', + 'product_id': self.ref('product.product_product_8') + }), (0, 0, { + 'name': str(claim_id.id) + 'test 2', + 'claim_origin': u'none', + 'product_id': self.ref('product.product_product_6') + })] + }) + + return claim_id + + def get_default_locations(self): + """ + Return locations for RMA, Loss and Refurbish + """ + self.main_warehouse_id = self.stock_warehouse.browse( + self.ref("stock.warehouse0")) + + self.loc_rma = self.main_warehouse_id.lot_rma_id + self.loss_loc = self.main_warehouse_id.loss_loc_id + self.loc_refurbish = self.main_warehouse_id.lot_refurbish_id + + def test_01_get_dest_loc(self): + + # Create Picking from Customers to RMA + # with button New Products Return + + wiz_context = { + 'active_id': self.claim_id.id, + 'warehouse_id': self.claim_id.warehouse_id.id, + 'partner_id': self.claim_id.partner_id.id, + 'picking_type': self.claim_id.warehouse_id.rma_in_type_id.id, + } + wizard_id = self.wizardmakepicking.with_context(wiz_context).create({}) + + res = wizard_id.action_create_picking() + + stock_picking_id = res.get('res_id') + + # Create Picking 'Product to stock' + context = { + 'active_id': stock_picking_id, + 'picking_type': 'picking_stock', + } + + claim_wizard = self.claim_picking_wizard.\ + with_context(context).create({}) + + self.assertEquals(claim_wizard.picking_line_source_location.id, + self.loc_rma.id) + + self.assertEquals(claim_wizard.picking_line_dest_location.id, + self.main_warehouse_id.lot_stock_id.id) + + self.assertEquals(len(claim_wizard.picking_line_ids), + len(self.claim_id.claim_line_ids)) + + # Review number of picking lines with claim lines + picking_lines = claim_wizard.picking_line_ids + claim_lines = self.claim_id.claim_line_ids + + for num in xrange(0, len(picking_lines)): + band = False + for num2 in xrange(0, len(claim_lines)): + if claim_lines[num].product_id.id == \ + picking_lines[num2].product_id.id: + band = True + self.assertEquals(True, band) + + claim_wizard.with_context(context).action_create_picking_from_picking() + + # Create Picking 'Product to Loss' + claim_wizard = self.claim_picking_wizard.\ + with_context({ + 'active_id': stock_picking_id, + 'picking_type': 'picking_loss', + }).create({}) + + self.assertEquals(claim_wizard.picking_line_source_location.id, + self.loc_rma.id) + + self.assertEquals(claim_wizard.picking_line_dest_location.id, + self.loss_loc.id) + + def assert_picking_type(self, picking_type_str=''): + new_context = { + 'active_id': self.claim_id.id, + 'warehouse_id': self.claim_id.warehouse_id.id, + 'partner_id': self.claim_id.partner_id.id, + 'picking_type': picking_type_str, + } + wizard_id = self.wizardmakepicking.with_context(new_context).create({}) + + default_location_dest_id = eval( + 'self.claim_id.warehouse_id.' + 'rma_%s_type_id.default_location_dest_id' % picking_type_str) + self.assertEquals( + wizard_id.claim_line_dest_location_id, default_location_dest_id) + + def test_02_picking_types_in_out_int(self): + self.assert_picking_type('in') + self.assert_picking_type('out') + self.assert_picking_type('int') + + def test_03_picking_type_loss(self): + new_context = { + 'active_id': self.claim_id.id, + 'warehouse_id': self.claim_id.warehouse_id.id, + 'partner_id': self.claim_id.partner_id.id, + 'picking_type': 'loss', + } + wizard_id = self.wizardmakepicking.with_context(new_context).create({}) + + default_location_dest_id = eval( + 'self.claim_id.warehouse_id.loss_loc_id') + self.assertEquals( + wizard_id.claim_line_dest_location_id, default_location_dest_id) diff --git a/crm_rma_stock_location/views/crm_claim.xml b/crm_rma_stock_location/views/crm_claim.xml new file mode 100644 index 00000000..f9a5f099 --- /dev/null +++ b/crm_rma_stock_location/views/crm_claim.xml @@ -0,0 +1,19 @@ + + + + + CRM - Claim product return Form + crm.claim + + + + + + + diff --git a/crm_rma_stock_location/views/product_product.xml b/crm_rma_stock_location/views/product_product.xml index 54fc3c26..47174164 100644 --- a/crm_rma_stock_location/views/product_product.xml +++ b/crm_rma_stock_location/views/product_product.xml @@ -1,46 +1,44 @@ - - - - product.stock.tree.inherit - product.product - - - - - - - - - - + + + product.stock.tree.inherit + product.product + + + + + + + + + + - - product.product.search - product.product - - - - - - - + + product.product.search + product.product + + + + + + + - - RMA Stock - ir.actions.act_window - product.product - tree - form - - - {'search_default_rma_available': 1} - + + RMA Stock + ir.actions.act_window + product.product + tree + form + + + {'search_default_rma_available': 1} + - - - + + diff --git a/crm_rma_stock_location/views/product_template.xml b/crm_rma_stock_location/views/product_template.xml index 44fe71cb..cc7ecc45 100644 --- a/crm_rma_stock_location/views/product_template.xml +++ b/crm_rma_stock_location/views/product_template.xml @@ -1,17 +1,29 @@ - - - - - product.normal.procurement.locations.inherit - product.template - - - - - - + + + product.template.tree + product.template + + + + + - - - + + + + + product.form.view.rma + product.template + + + + + + + + + + + + diff --git a/crm_rma_stock_location/views/stock_picking.xml b/crm_rma_stock_location/views/stock_picking.xml index 6da49f08..ea1cecb3 100644 --- a/crm_rma_stock_location/views/stock_picking.xml +++ b/crm_rma_stock_location/views/stock_picking.xml @@ -1,30 +1,28 @@ - - - - - crm_claim_rma.picking_in_form - stock.picking - - - -