Merge pull request #82 from cyrilgdn/9.0-crm_rma_location

crm_rma_location: migration V9
This commit is contained in:
Yannick Vaucher
2016-05-09 13:41:11 +02:00
17 changed files with 885 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
.. 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
================
CRM RMA Location
================
This module adds a warehouse's stock location for RMA movements in the warehouse and 3 picking types for RMA operations, these picking types are one for Incoming Picking, another for Internal and the third for Outgoing picking. Creating it also document sequences for each of them.
Installation
============
To install this module, just select it from available modules
Configuration
=============
No extra configuration is added to this module
Usage
=====
* Go to Warehouses > Configuration > Warehouses and create a new one
* Then go to Warehouse > Configuration > Types of Operation, and confirm that it
have been created the three mentioned picking types.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/145/9.0
For further information, please visit:
* https://www.odoo.com/forum/help-1
Known issues / Roadmap
======================
* No issues are known yet
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/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
Credits
=======
Contributors
------------
* Osval Reyes <osval@vauxoo.com>
* Yanina Aular <yanina.aular@vauxoo.com>
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.

View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# © 2015 Yanina Aular, Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from openerp import SUPERUSER_ID
from openerp.api import Environment
def post_init_hook(cr, registry):
env = Environment(cr, SUPERUSER_ID, {})
warehouses = env['stock.warehouse'].search([])
warehouses.create_locations_rma()
warehouses.create_sequences_picking_types()

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © Guewen Yanina Aular, Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'RMA Location',
'version': '9.0.1.0.0',
'author': "Vauxoo, Odoo Community Association (OCA)",
'license': 'AGPL-3',
'website': 'http://www.camptocamp.com,http://www.vauxoo.com',
'category': 'Generic Modules/CRM & SRM',
'depends': [
'stock',
'procurement',
],
'data': [
'views/stock_warehouse.xml',
],
'post_init_hook': 'post_init_hook',
'installable': True,
'auto_install': False,
}

View File

@@ -0,0 +1,84 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:39+0000\n"
"PO-Revision-Date: 2015-07-17 19:39+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_location
#: code:addons/crm_rma_location/stock.py:60
#, python-format
msgid " Sequence in"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/stock.py:72
#, python-format
msgid " Sequence internal"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/stock.py:66
#, python-format
msgid " Sequence out"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/stock.py:166
#, python-format
msgid "RMA"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/stock.py:120
#, python-format
msgid "RMA Delivery Orders"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_in_type_id:0
msgid "RMA In Type"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/stock.py:134
#, python-format
msgid "RMA Internal Transfers"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_int_type_id:0
msgid "RMA Internal Type"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,lot_rma_id:0
msgid "RMA Location"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_out_type_id:0
msgid "RMA Out Type"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/stock.py:108
#, python-format
msgid "RMA Receipts"
msgstr ""
#. module: crm_rma_location
#: model:ir.model,name:crm_rma_location.model_stock_warehouse
msgid "Warehouse"
msgstr ""

View File

@@ -0,0 +1,86 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2016
msgid ""
msgstr ""
"Project-Id-Version: rma (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-19 12:26+0000\n"
"PO-Revision-Date: 2016-01-18 10:19+0000\n"
"Last-Translator: Rudolf Schnapka <rs@techno-flex.de>\n"
"Language-Team: German (http://www.transifex.com/oca/OCA-rma-8-0/language/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:73
#, python-format
msgid " Sequence in"
msgstr "Eingangsfolge"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:83
#, python-format
msgid " Sequence internal"
msgstr "Interne Folge"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:78
#, python-format
msgid " Sequence out"
msgstr "Ausgangsfolge"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:161
#, python-format
msgid "RMA"
msgstr "RMA"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:115
#, python-format
msgid "RMA Delivery Orders"
msgstr "RMA-Lieferscheine"
#. module: crm_rma_location
#: field:stock.warehouse,rma_in_type_id:0
msgid "RMA In Type"
msgstr "RMA aus Art"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:129
#, python-format
msgid "RMA Internal Transfers"
msgstr "RMA interne Umbuchungen"
#. module: crm_rma_location
#: field:stock.warehouse,rma_int_type_id:0
msgid "RMA Internal Type"
msgstr "Interne RMA-Art"
#. module: crm_rma_location
#: field:stock.warehouse,lot_rma_id:0
msgid "RMA Location"
msgstr "RMA-Anschrift"
#. module: crm_rma_location
#: field:stock.warehouse,rma_out_type_id:0
msgid "RMA Out Type"
msgstr "Art Ausgehender RMA"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:103
#, python-format
msgid "RMA Receipts"
msgstr "RMA-Eingänge"
#. module: crm_rma_location
#: model:ir.model,name:crm_rma_location.model_stock_warehouse
msgid "Warehouse"
msgstr "Warenlager"

View File

@@ -0,0 +1,85 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: rma (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-24 16:07+0000\n"
"PO-Revision-Date: 2015-11-03 17:06+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-rma-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:73
#, python-format
msgid " Sequence in"
msgstr "Secuencia de entrada"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:83
#, python-format
msgid " Sequence internal"
msgstr "Secuencia interna"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:78
#, python-format
msgid " Sequence out"
msgstr "Secuencia de salida"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:161
#, python-format
msgid "RMA"
msgstr "RMA"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:115
#, python-format
msgid "RMA Delivery Orders"
msgstr "Órdenes de envío de RMA"
#. module: crm_rma_location
#: field:stock.warehouse,rma_in_type_id:0
msgid "RMA In Type"
msgstr "Entradas en RMA"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:129
#, python-format
msgid "RMA Internal Transfers"
msgstr "Transferencias internas en RMA"
#. module: crm_rma_location
#: field:stock.warehouse,rma_int_type_id:0
msgid "RMA Internal Type"
msgstr "Internos en RMA"
#. module: crm_rma_location
#: field:stock.warehouse,lot_rma_id:0
msgid "RMA Location"
msgstr "Locación de RMA"
#. module: crm_rma_location
#: field:stock.warehouse,rma_out_type_id:0
msgid "RMA Out Type"
msgstr "Salidas en RMA"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:103
#, python-format
msgid "RMA Receipts"
msgstr "Recepciones de RMA"
#. module: crm_rma_location
#: model:ir.model,name:crm_rma_location.model_stock_warehouse
msgid "Warehouse"
msgstr "Almacén"

View File

@@ -0,0 +1,16 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:39+0000\n"
"PO-Revision-Date: 2015-07-17 19:39+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"

View File

@@ -0,0 +1,16 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:39+0000\n"
"PO-Revision-Date: 2015-07-17 19:39+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"

View File

@@ -0,0 +1,16 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:39+0000\n"
"PO-Revision-Date: 2015-07-17 19:39+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"

View File

@@ -0,0 +1,85 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: rma (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-24 16:07+0000\n"
"PO-Revision-Date: 2015-11-03 17:05+0000\n"
"Last-Translator: <>\n"
"Language-Team: French (http://www.transifex.com/oca/OCA-rma-8-0/language/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:73
#, python-format
msgid " Sequence in"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:83
#, python-format
msgid " Sequence internal"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:78
#, python-format
msgid " Sequence out"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:161
#, python-format
msgid "RMA"
msgstr "RMA"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:115
#, python-format
msgid "RMA Delivery Orders"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_in_type_id:0
msgid "RMA In Type"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:129
#, python-format
msgid "RMA Internal Transfers"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_int_type_id:0
msgid "RMA Internal Type"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,lot_rma_id:0
msgid "RMA Location"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_out_type_id:0
msgid "RMA Out Type"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:103
#, python-format
msgid "RMA Receipts"
msgstr ""
#. module: crm_rma_location
#: model:ir.model,name:crm_rma_location.model_stock_warehouse
msgid "Warehouse"
msgstr "Entrepôt"

View File

@@ -0,0 +1,86 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
# Translators:
# danimaribeiro <danimaribeiro@gmail.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: rma (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-19 12:26+0000\n"
"PO-Revision-Date: 2016-03-08 03:12+0000\n"
"Last-Translator: danimaribeiro <danimaribeiro@gmail.com>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-rma-8-0/language/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:73
#, python-format
msgid " Sequence in"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:83
#, python-format
msgid " Sequence internal"
msgstr "Sequência interna"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:78
#, python-format
msgid " Sequence out"
msgstr "Sequência de saida"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:161
#, python-format
msgid "RMA"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:115
#, python-format
msgid "RMA Delivery Orders"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_in_type_id:0
msgid "RMA In Type"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:129
#, python-format
msgid "RMA Internal Transfers"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_int_type_id:0
msgid "RMA Internal Type"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,lot_rma_id:0
msgid "RMA Location"
msgstr ""
#. module: crm_rma_location
#: field:stock.warehouse,rma_out_type_id:0
msgid "RMA Out Type"
msgstr ""
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:103
#, python-format
msgid "RMA Receipts"
msgstr ""
#. module: crm_rma_location
#: model:ir.model,name:crm_rma_location.model_stock_warehouse
msgid "Warehouse"
msgstr ""

View File

@@ -0,0 +1,86 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_location
#
# Translators:
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015
msgid ""
msgstr ""
"Project-Id-Version: rma (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-12 22:57+0000\n"
"PO-Revision-Date: 2015-12-13 06:20+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-rma-8-0/language/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:73
#, python-format
msgid " Sequence in"
msgstr "Vhodno zaporedje"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:83
#, python-format
msgid " Sequence internal"
msgstr "Interno zaporedje"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:78
#, python-format
msgid " Sequence out"
msgstr "Izhodno zaporedje"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:161
#, python-format
msgid "RMA"
msgstr "Pooblastilo vračila blaga - PVB"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:115
#, python-format
msgid "RMA Delivery Orders"
msgstr "PVB dobavni nalogi"
#. module: crm_rma_location
#: field:stock.warehouse,rma_in_type_id:0
msgid "RMA In Type"
msgstr "PVB vhodni tip"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:129
#, python-format
msgid "RMA Internal Transfers"
msgstr "PVB interni transferji"
#. module: crm_rma_location
#: field:stock.warehouse,rma_int_type_id:0
msgid "RMA Internal Type"
msgstr "PVB interni tip"
#. module: crm_rma_location
#: field:stock.warehouse,lot_rma_id:0
msgid "RMA Location"
msgstr "PVB lokacija"
#. module: crm_rma_location
#: field:stock.warehouse,rma_out_type_id:0
msgid "RMA Out Type"
msgstr "PVB izhodni tip"
#. module: crm_rma_location
#: code:addons/crm_rma_location/models/stock_warehouse.py:103
#, python-format
msgid "RMA Receipts"
msgstr "PVB prejemi"
#. module: crm_rma_location
#: model:ir.model,name:crm_rma_location.model_stock_warehouse
msgid "Warehouse"
msgstr "Skladišče"

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2013 Camptocamp
# © 2015 Yanina Aular, Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import stock_warehouse

View File

@@ -0,0 +1,160 @@
# -*- coding: utf-8 -*-
# © 2013 Camptocamp
# © 2015 Osval Reyes, Yanina Aular, Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import _, api, fields, models
class StockWarehouse(models.Model):
_inherit = "stock.warehouse"
lot_rma_id = fields.Many2one('stock.location', 'RMA Location')
rma_out_type_id = fields.Many2one('stock.picking.type', 'RMA Out Type')
rma_in_type_id = fields.Many2one('stock.picking.type', 'RMA In Type')
rma_int_type_id = fields.Many2one('stock.picking.type',
'RMA Internal Type')
def compute_next_color(self):
"""
Choose the next available color for
the picking types of this warehouse
"""
available_colors = [c % 9 for c in range(3, 12)]
all_used_colors = self.env['stock.picking.type'].\
search_read([('warehouse_id', '!=', False),
('color', '!=', False)],
['color'], order='color')
for col in all_used_colors:
if col['color'] in available_colors:
available_colors.remove(col['color'])
return available_colors[0] if available_colors else 0
def create_sequence(self, name, prefix, padding):
self.ensure_one()
return self.env['ir.sequence'].sudo().\
create(values={
'name': self.name + name,
'prefix': self.code + prefix,
'padding': padding,
'company_id': self.company_id.id
})
@api.multi
def create_sequences_picking_types(self):
"""
Takes care of create picking types for internal,
incoming and outgoing RMA
"""
picking_type_model = self.env['stock.picking.type']
for warehouse in self:
# create new sequences
if not warehouse.rma_in_type_id:
in_seq_id = warehouse.create_sequence(
_(' Sequence in'), '/RMA/IN/', 5
)
if not warehouse.rma_out_type_id:
out_seq_id = warehouse.create_sequence(
_(' Sequence out'), '/RMA/OUT/', 5
)
if not warehouse.rma_int_type_id:
int_seq_id = warehouse.create_sequence(
_(' Sequence internal'), '/RMA/INT/', 5
)
wh_stock_loc = warehouse.lot_rma_id
# fetch customer and supplier locations, for references
customer_loc, supplier_loc = self._get_partner_locations()
color = self.compute_next_color()
# order the picking types with a sequence
# allowing to have the following suit for
# each warehouse: reception, internal, pick, pack, ship.
max_sequence = picking_type_model.search_read(
[], ['sequence'], order='sequence desc'
)
max_sequence = max_sequence and max_sequence[0]['sequence'] or 0
in_type_id = warehouse.rma_in_type_id
if not in_type_id:
in_type_id = picking_type_model.create(vals={
'name': _('RMA Receipts'),
'warehouse_id': warehouse.id,
'code': 'incoming',
'sequence_id': in_seq_id.id,
'default_location_src_id': customer_loc.id,
'default_location_dest_id': wh_stock_loc.id,
'sequence': max_sequence + 4,
'color': color})
out_type_id = warehouse.rma_out_type_id
if not out_type_id:
out_type_id = picking_type_model.create(vals={
'name': _('RMA Delivery Orders'),
'warehouse_id': warehouse.id,
'code': 'outgoing',
'sequence_id': out_seq_id.id,
'return_picking_type_id': in_type_id.id,
'default_location_src_id': wh_stock_loc.id,
'default_location_dest_id': supplier_loc.id,
'sequence': max_sequence + 1,
'color': color})
in_type_id.write({'return_picking_type_id': out_type_id.id})
int_type_id = warehouse.rma_int_type_id
if not int_type_id:
int_type_id = picking_type_model.create(vals={
'name': _('RMA Internal Transfers'),
'warehouse_id': warehouse.id,
'code': 'internal',
'sequence_id': int_seq_id.id,
'default_location_src_id': wh_stock_loc.id,
'default_location_dest_id': wh_stock_loc.id,
'active': True,
'sequence': max_sequence + 2,
'color': color})
# write picking types on WH
warehouse.write({
'rma_in_type_id': in_type_id.id,
'rma_out_type_id': out_type_id.id,
'rma_int_type_id': int_type_id.id,
})
@api.multi
def create_locations_rma(self):
"""
Create a RMA location for RMA movements that takes place when internal,
outgoing or incoming pickings are made from/to this location
"""
location_obj = self.env['stock.location']
for warehouse in self:
if not warehouse.lot_rma_id:
location_id = location_obj.with_context(
active_test=False
).create({
'name': _('RMA'),
'usage': 'internal',
'location_id': warehouse.view_location_id.id,
'company_id': warehouse.company_id.id,
'active': True,
})
warehouse.lot_rma_id = location_id
@api.model
def create(self, vals):
"""
Create Locations and picking types for warehouse
"""
warehouse = super(StockWarehouse, self).create(vals=vals)
warehouse.create_locations_rma()
warehouse.create_sequences_picking_types()
return warehouse

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_location_rma

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# © 2015 Osval Reyes, Vauxoo
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase
class TestLocationRma(TransactionCase):
def setUp(self):
super(TestLocationRma, self).setUp()
self.warehouse = self.env['stock.warehouse']
def test_01_create_warehouse(self):
"""
Check if picking types were created
"""
warehouse_id = self.warehouse.create({
'name': 'BrandNew WH',
'code': 'NEWWH'
})
self.assertTrue(warehouse_id.rma_in_type_id and
warehouse_id.rma_out_type_id.code and
warehouse_id.rma_int_type_id.code)
self.assertEqual(warehouse_id.rma_in_type_id.code, 'incoming')
self.assertEqual(warehouse_id.rma_out_type_id.code, 'outgoing')
self.assertEqual(warehouse_id.rma_int_type_id.code, 'internal')

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_warehouse_form" model="ir.ui.view">
<field name="name">view_warehouse_form</field>
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='wh_output_stock_loc_id']" position="after">
<field name="lot_rma_id"/>
</xpath>
<xpath expr="//field[@name='out_type_id']" position="after">
<field name="rma_in_type_id"/>
<field name="rma_int_type_id"/>
<field name="rma_out_type_id"/>
</xpath>
</field>
</record>
</odoo>