Skip to content

Commit

Permalink
[MIG] V9 -> V10
Browse files Browse the repository at this point in the history
  • Loading branch information
fmdl committed Mar 17, 2017
1 parent 2720867 commit 14c674c
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 163 deletions.
51 changes: 51 additions & 0 deletions stock_picking_show_return/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.. 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

=================================
Display returns on stock pickings
=================================

This module adds one tab in the pickings form view to display the returns
pickings related to the current one.

Usage
=====

#. Go to any picking that has a return
#. See the new tab "Returns" appears.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/154/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/stock-logistics-workflow/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
------------

* Pedro M. Baeza <pedro.baeza@tecnativa.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 https://odoo-community.org.
25 changes: 3 additions & 22 deletions stock_picking_show_return/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2013 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# $Id$
#
# 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_picking
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
52 changes: 14 additions & 38 deletions stock_picking_show_return/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2013 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# $Id$
#
# 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/>.
#
##############################################################################
# Copyright 2014-2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Show returns on stock pickings",
"version": "1.0",
"author": "Serv. Tecnol. Avanzados - Pedro M. Baeza,"
"Odoo Community Association (OCA)",
"category": "Warehouse Management",
"description": """
Show in pickings one tab that contains returns made for that picking.
""",
"website": "www.serviciosbaeza.com",
"license": "AGPL-3",
"depends": [
"stock",
'name': 'Show returns on stock pickings',
'version': '10.0.1.0.0',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'category': 'Warehouse Management',
'website': 'https://www.tecnativa.com',
'license': 'AGPL-3',
'depends': [
'stock',
],
"demo": [],
"data": [
'stock_picking_view.xml',
'data': [
'views/stock_picking_view.xml',
],
"installable": False,
"active": False,
'installable': True,
}
34 changes: 34 additions & 0 deletions stock_picking_show_return/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_show_return
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-22 02:46+0000\n"
"PO-Revision-Date: 2016-07-22 02:46+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2016\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/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: stock_picking_show_return
#: model:ir.model,name:stock_picking_show_return.model_stock_picking
msgid "Picking List"
msgstr "Bon de livraison"

#. module: stock_picking_show_return
#: field:stock.picking,returned_ids:0
msgid "Returned pickings"
msgstr ""

#. module: stock_picking_show_return
#: view:stock.picking:stock_picking_show_return.view_picking_form
msgid "Returns"
msgstr ""
34 changes: 34 additions & 0 deletions stock_picking_show_return/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_show_return
#
# Translators:
# Paolo Valier <paolo.valier@hotmail.it>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-22 02:46+0000\n"
"PO-Revision-Date: 2016-07-22 02:46+0000\n"
"Last-Translator: Paolo Valier <paolo.valier@hotmail.it>, 2016\n"
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: stock_picking_show_return
#: model:ir.model,name:stock_picking_show_return.model_stock_picking
msgid "Picking List"
msgstr "Lista Picking"

#. module: stock_picking_show_return
#: field:stock.picking,returned_ids:0
msgid "Returned pickings"
msgstr ""

#. module: stock_picking_show_return
#: view:stock.picking:stock_picking_show_return.view_picking_form
msgid "Returns"
msgstr ""
34 changes: 34 additions & 0 deletions stock_picking_show_return/i18n/sl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_show_return
#
# Translators:
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-22 02:46+0000\n"
"PO-Revision-Date: 2016-07-22 02:46+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>, 2016\n"
"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/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: stock_picking_show_return
#: model:ir.model,name:stock_picking_show_return.model_stock_picking
msgid "Picking List"
msgstr "Zbirnik"

#. module: stock_picking_show_return
#: field:stock.picking,returned_ids:0
msgid "Returned pickings"
msgstr "Povrnjeni zbirniki"

#. module: stock_picking_show_return
#: view:stock.picking:stock_picking_show_return.view_picking_form
msgid "Returns"
msgstr "Vračila"
4 changes: 4 additions & 0 deletions stock_picking_show_return/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_picking
87 changes: 13 additions & 74 deletions stock_picking_show_return/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,19 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2013 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
#
# 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.osv import fields, orm
# Copyright 2014-2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models

class stock_picking(orm.Model):
_inherit = 'stock.picking'

def _get_return_ids(self, cr, uid, ids, name, arg, context=None):
result = {}
for picking in self.browse(cr, uid, ids, context=context):
for line in picking.move_lines:
return_ids = []
if line.state == 'done':
for rec in line.move_history_ids2:
if (
rec.location_dest_id.id == line.location_id.id and
rec.location_id.id == line.location_dest_id.id
):
return_ids.append(rec.picking_id.id)
result[picking.id] = return_ids
return result

_columns = {
'return_ids': fields.function(_get_return_ids,
relation='stock.picking',
string="Return pickings",
type='many2many'),
}


class stock_picking_out(orm.Model):
_inherit = 'stock.picking.out'

def _get_return_ids(self, cr, uid, ids, name, arg, context=None):
return super(stock_picking_out, self)._get_return_ids(cr, uid, ids,
name, arg,
context=context)

_columns = {
'return_ids': fields.function(_get_return_ids,
relation='stock.picking',
string="Return pickings",
type='many2many'),
}


class stock_picking_in(orm.Model):
_inherit = 'stock.picking.in'
class StockPicking(models.Model):
_inherit = 'stock.picking'

def _get_return_ids(self, cr, uid, ids, name, arg, context=None):
return super(stock_picking_out, self)._get_return_ids(cr, uid, ids,
name, arg,
context=context)
returned_ids = fields.Many2many(
comodel_name="stock.picking", compute="_compute_returned_ids",
string="Returned pickings")

_columns = {
'return_ids': fields.function(_get_return_ids,
relation='stock.picking',
string="Return pickings",
type='many2many'),
}
@api.multi
def _compute_returned_ids(self):
for picking in self:
picking.returned_ids = picking.mapped(
'move_lines.returned_move_ids.picking_id')
4 changes: 4 additions & 0 deletions stock_picking_show_return/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_stock_picking_show_return
32 changes: 32 additions & 0 deletions stock_picking_show_return/tests/test_stock_picking_show_return.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright 2014-2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests import common


class TestStockPickingShowReturn(common.TransactionCase):
def setUp(self):
super(TestStockPickingShowReturn, self).setUp()
self.product = self.env['product.product'].create({
'name': 'Test product',
})
picking_type = self.env.ref('stock.picking_type_internal')
self.picking = self.env['stock.picking'].create({
'picking_type_id': picking_type.id,
'location_id': picking_type.default_location_src_id.id,
'location_dest_id': picking_type.default_location_dest_id.id,
'move_lines': [(0, 0, {
'name': self.product.name,
'product_id': self.product.id,
'product_uom': self.product.uom_id.id,
})],
})

def test_returned_ids_field(self):
self.picking.force_assign()
self.picking.do_transfer()
wizard = self.env['stock.return.picking'].with_context(
active_ids=self.picking.ids, active_id=self.picking.id).create({})
wizard.create_returns()
self.assertTrue(self.picking.returned_ids)
Loading

0 comments on commit 14c674c

Please sign in to comment.