mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[ADD] new module crm_rma_location
This commit is contained in:
72
crm_rma_location/README.rst
Normal file
72
crm_rma_location/README.rst
Normal file
@@ -0,0 +1,72 @@
|
||||
.. 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/8.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
|
||||
`here <https://github.com/OCA/rma/issues/new?body=module:%20crm_rma_location%0Aversion:%208.0.1.0.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
|
||||
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.
|
||||
33
crm_rma_location/__init__.py
Normal file
33
crm_rma_location/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright 2015 Vauxoo
|
||||
# Author: Yanina Aular
|
||||
#
|
||||
# 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 . import models
|
||||
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)
|
||||
vals = stock_wh.create_sequences_picking_types(cr, SUPERUSER_ID, wh_id)
|
||||
stock_wh.write(cr, SUPERUSER_ID, wh_id.id, vals)
|
||||
39
crm_rma_location/__openerp__.py
Normal file
39
crm_rma_location/__openerp__.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright 2015 Vauxoo
|
||||
# Author: Yanina Aular
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'RMA Location',
|
||||
'version': '8.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,
|
||||
}
|
||||
84
crm_rma_location/i18n/crm_rma_location_rma.pot
Normal file
84
crm_rma_location/i18n/crm_rma_location_rma.pot
Normal 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 ""
|
||||
|
||||
84
crm_rma_location/i18n/es.po
Normal file
84
crm_rma_location/i18n/es.po
Normal 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 "Secuencia de entrada"
|
||||
|
||||
#. module: crm_rma_location
|
||||
#: code:addons/crm_rma_location/stock.py:72
|
||||
#, python-format
|
||||
msgid " Sequence internal"
|
||||
msgstr "Secuencia interna"
|
||||
|
||||
#. module: crm_rma_location
|
||||
#: code:addons/crm_rma_location/stock.py:66
|
||||
#, python-format
|
||||
msgid " Sequence out"
|
||||
msgstr "Secuencia de salida"
|
||||
|
||||
#. module: crm_rma_location
|
||||
#: code:addons/crm_rma_location/stock.py:166
|
||||
#, python-format
|
||||
msgid "RMA"
|
||||
msgstr "RMA"
|
||||
|
||||
#. module: crm_rma_location
|
||||
#: code:addons/crm_rma_location/stock.py:120
|
||||
#, 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/stock.py:134
|
||||
#, 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/stock.py:108
|
||||
#, 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"
|
||||
|
||||
16
crm_rma_location/i18n/es_MX.po
Normal file
16
crm_rma_location/i18n/es_MX.po
Normal 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"
|
||||
16
crm_rma_location/i18n/es_PA.po
Normal file
16
crm_rma_location/i18n/es_PA.po
Normal 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"
|
||||
16
crm_rma_location/i18n/es_VE.po
Normal file
16
crm_rma_location/i18n/es_VE.po
Normal 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"
|
||||
23
crm_rma_location/models/__init__.py
Normal file
23
crm_rma_location/models/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright 2013 Camptocamp
|
||||
# Copyright 2015 Vauxoo
|
||||
# Author: Yanina Aular
|
||||
#
|
||||
# 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 . import stock_warehouse
|
||||
183
crm_rma_location/models/stock_warehouse.py
Normal file
183
crm_rma_location/models/stock_warehouse.py
Normal file
@@ -0,0 +1,183 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright 2013 Camptocamp
|
||||
# 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
|
||||
# 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 _, 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, warehouse_id, name, prefix, padding):
|
||||
return self.env['ir.sequence'].sudo().\
|
||||
create(values={
|
||||
'name': warehouse_id.name + name,
|
||||
'prefix': warehouse_id.code + prefix,
|
||||
'padding': padding,
|
||||
'company_id': warehouse_id.company_id.id
|
||||
})
|
||||
|
||||
@api.model
|
||||
def create_sequences_picking_types(self, warehouse):
|
||||
"""
|
||||
Takes care of create picking types for internal,
|
||||
incoming and outgoing RMA
|
||||
"""
|
||||
picking_type = self.env['stock.picking.type']
|
||||
|
||||
# create new sequences
|
||||
if not warehouse.rma_in_type_id:
|
||||
in_seq_id = self.create_sequence(
|
||||
warehouse, _(' Sequence in'), '/RMA/IN/', 5
|
||||
)
|
||||
|
||||
if not warehouse.rma_out_type_id:
|
||||
out_seq_id = self.create_sequence(
|
||||
warehouse, _(' Sequence out'), '/RMA/OUT/', 5
|
||||
)
|
||||
|
||||
if not warehouse.rma_int_type_id:
|
||||
int_seq_id = self.create_sequence(
|
||||
warehouse, _(' 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 = self.env['stock.picking.type'].\
|
||||
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.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.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.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
|
||||
vals = {
|
||||
'rma_in_type_id': in_type_id.id,
|
||||
'rma_out_type_id': out_type_id.id,
|
||||
'rma_int_type_id': int_type_id.id,
|
||||
}
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def create_locations_rma(self, warehouse_id):
|
||||
"""
|
||||
Create a RMA location for RMA movements that takes place when internal,
|
||||
outgoing or incoming pickings are made from/to this location
|
||||
"""
|
||||
vals = {}
|
||||
|
||||
location_obj = self.env['stock.location']
|
||||
context_with_inactive = self.env.context.copy()
|
||||
context_with_inactive['active_test'] = False
|
||||
|
||||
if not warehouse_id.lot_rma_id:
|
||||
loc_vals = {
|
||||
'name': _('RMA'),
|
||||
'usage': 'internal',
|
||||
'location_id': warehouse_id.view_location_id.id,
|
||||
'company_id': warehouse_id.company_id.id,
|
||||
'active': True,
|
||||
}
|
||||
location_id = location_obj.with_context(context_with_inactive).\
|
||||
create(loc_vals)
|
||||
vals['lot_rma_id'] = location_id.id
|
||||
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
"""
|
||||
Create Locations and picking types for warehouse
|
||||
"""
|
||||
warehouse_id = super(StockWarehouse, self).create(vals=vals)
|
||||
new_vals = self.create_locations_rma(warehouse_id)
|
||||
warehouse_id.write(vals=new_vals)
|
||||
new_vals = self.create_sequences_picking_types(warehouse_id)
|
||||
warehouse_id.write(vals=new_vals)
|
||||
return warehouse_id
|
||||
22
crm_rma_location/tests/__init__.py
Normal file
22
crm_rma_location/tests/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import test_location_rma
|
||||
46
crm_rma_location/tests/test_location_rma.py
Normal file
46
crm_rma_location/tests/test_location_rma.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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')
|
||||
21
crm_rma_location/views/stock_warehouse.xml
Normal file
21
crm_rma_location/views/stock_warehouse.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<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>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user