[REF] crm_rma_stock_location: add init_hooks file for post_init_hook, correct typos in readme, change usage for created locations loss and refurbished, rename compute method _rma_product_available -> _rma_template_available and get defined with @api.multi decorator

This commit is contained in:
Osval Reyes
2015-11-27 18:58:54 -04:30
committed by Yanina Aular (Vauxoo)
parent 72ec97c461
commit bdc11ae77a
6 changed files with 54 additions and 24 deletions

View File

@@ -10,16 +10,16 @@ Allow the user to know how much for a product is available 'On Hand' and how muc
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.
Both quantities are computed and include its children locations.
It is useful use it as a quick snapshot for RMA from product perspective.
It is useful to use it as a quick snapshot for RMA from product perspective.
It also adds the following location on warehouses :
* Loss
* Refurbish
* Refurbished
Various wizards on incoming deliveries that allow you to move your
Several 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:
@@ -41,11 +41,11 @@ 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.
'RMA Forecasted Quantity' has been included and they'll be shown when at least
when a product has either 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
allowing to do product returns (incoming), send a product to loss or, to a refurbished
location.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas

View File

@@ -23,12 +23,4 @@
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)
from .init_hooks import post_init_hook

View File

@@ -0,0 +1,31 @@
# -*- 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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)

View File

@@ -19,7 +19,7 @@
#
##############################################################################
from openerp import _, models, fields
from openerp import _, api, fields, models
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
@@ -64,6 +64,7 @@ class ProductProduct(models.Model):
res.append(('id', 'in', ids))
return res
@api.multi
def _rma_product_available(self):
"""
Finds the incoming and outgoing quantity of product for the RMA

View File

@@ -21,7 +21,7 @@
#
##############################################################################
from openerp import _, models, fields
from openerp import _, api, fields, models
import openerp.addons.decimal_precision as dp
@@ -29,19 +29,20 @@ class ProductTemplate(models.Model):
_inherit = 'product.template'
rma_qty_available = fields.Float(compute='_rma_product_available',
rma_qty_available = fields.Float(compute='_rma_template_available',
digits_compute=dp.
get_precision('Product Unit '
'of Measure'),
string=_('RMA Quantity On Hand'))
rma_virtual_available = fields.Float(compute='_rma_product_available',
rma_virtual_available = fields.Float(compute='_rma_template_available',
digits_compute=dp.
get_precision('Product Unit'
' of Measure'),
string=_('RMA Forecasted Quantity'))
def _rma_product_available(self):
@api.multi
def _rma_template_available(self):
for product in self:
product.rma_qty_available = sum(
[p.rma_qty_available for p in product.product_variant_ids])

View File

@@ -44,7 +44,6 @@ class StockWarehouse(models.Model):
vals_new = super(StockWarehouse, self).create_locations_rma(wh_id)
loc_vals = {
'usage': 'internal',
'location_id': wh_loc_id,
'active': True,
}
@@ -53,13 +52,19 @@ class StockWarehouse(models.Model):
loc_vals['company_id'] = vals.get('company_id')
if not wh_id.lot_refurbish_id:
loc_vals.update({'name': _('Refurbish')})
loc_vals.update({
'name': _('Refurbish'),
'usage': 'production'
})
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')})
loc_vals.update({
'name': _('Loss'),
'usage': 'inventory'
})
location_id = location_obj.with_context(context_with_inactive).\
create(loc_vals)
vals['loss_loc_id'] = location_id.id