Skip to content

Commit

Permalink
[ADD] serial_last_location: New stock_production_lot_last_location mo…
Browse files Browse the repository at this point in the history
…dule to add last_location_id field in the stock.production.lot model to know the last location of the product related with the serial number
  • Loading branch information
Yanina Aular (Vauxoo) authored and nhomar committed Mar 21, 2017
1 parent 34557dc commit e4bf5a0
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ python:

env:
global:
- LINT_CHECK=0 TESTS="0" VERSION="8.0" ODOO_REPO="vauxoo/odoo"
- LINT_CHECK=0 TESTS="0" VERSION="10.0" ODOO_REPO="vauxoo/odoo"

matrix:
- LINT_CHECK=1
Expand Down
7 changes: 4 additions & 3 deletions product_unique_serial/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
'category': 'stock',
'version': '8.0.0.1.0',
'license': "AGPL-3",
'depends': ['stock_no_negative'],
'depends': ['stock_no_negative',
'serial_last_location',
],
'data': [
"views/product_view.xml",
"views/stock_view.xml",
"views/stock_serial_view.xml",
],
'demo': [
"demo/test_demo.xml",
],
'installable': True,
'installable': False,
'auto_install': False,
}
5 changes: 0 additions & 5 deletions product_unique_serial/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ msgstr "Línea inventario"
msgid "Is lot unique?"
msgstr "¿Es lote único?"

#. module: product_unique_serial
#: field:stock.production.lot,last_location_id:0
msgid "Last Location"
msgstr "Última ubicación"

#. module: product_unique_serial
#: field:stock.serial,__last_update:0
#: field:stock.serial.line,__last_update:0
Expand Down
5 changes: 0 additions & 5 deletions product_unique_serial/i18n/es_MX.po
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ msgstr "Línea inventario"
msgid "Is lot unique?"
msgstr "¿Es lote único?"

#. module: product_unique_serial
#: field:stock.production.lot,last_location_id:0
msgid "Last Location"
msgstr "Última ubicación"

#. module: product_unique_serial
#: field:stock.serial,__last_update:0
#: field:stock.serial.line,__last_update:0
Expand Down
5 changes: 0 additions & 5 deletions product_unique_serial/i18n/es_PA.po
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ msgstr "Línea inventario"
msgid "Is lot unique?"
msgstr "¿Es lote único?"

#. module: product_unique_serial
#: field:stock.production.lot,last_location_id:0
msgid "Last Location"
msgstr "Última ubicación"

#. module: product_unique_serial
#: field:stock.serial,__last_update:0
#: field:stock.serial.line,__last_update:0
Expand Down
29 changes: 0 additions & 29 deletions product_unique_serial/model/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,6 @@
from openerp.exceptions import ValidationError


class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'

@api.multi
@api.depends('quant_ids.location_id')
def _compute_get_last_location_id(self):
for record in self:
if record.quant_ids.ids:
last_quant_id = max(record.quant_ids.ids)
last_quant_data = self.env['stock.quant'].browse(last_quant_id)
record.last_location_id = last_quant_data.location_id.id
else:
record.last_location_id = False

last_location_id = fields.Many2one(
'stock.location',
string="Last Location",
compute='_compute_get_last_location_id',
store=True)

# Overwrite field to deny create serial number duplicated
ref = fields.Char('Internal Reference',
help="Internal reference number"
" in this case it"
" is same of manufacturer's"
" serial number",
related="name", store=True, readonly=True)


class StockQuant(models.Model):
_inherit = 'stock.quant'

Expand Down
8 changes: 8 additions & 0 deletions serial_last_location/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Stock Production Lot Last Location
==================================

Turns production lot tracking numbers into unique per product instance code (serial number).

Features
--------
- Add a field to lot to set domain to show only serial number that exists in last location
2 changes: 2 additions & 0 deletions serial_last_location/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
15 changes: 15 additions & 0 deletions serial_last_location/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# coding: utf-8
{
'name': "Stock Production Lot Last Location",
'author': "Vauxoo",
'website': "http://www.vauxoo.com",
'category': 'stock',
'version': '10.0.0.1.0',
'license': "AGPL-3",
'depends': ['stock'],
'data': [
"views/stock_production_lot.xml",
],
'installable': True,
'auto_install': False,
}
24 changes: 24 additions & 0 deletions serial_last_location/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_unique_serial
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-20 01:19+0000\n"
"PO-Revision-Date: 2016-07-20 02:05+0000\n"
"Last-Translator: Humberto Arocha <hbto@vauxoo.com>\n"
"Language-Team: Spanish <http://example.com/projects/stock-logistic-"
"workflow/product_unique_serial/es/>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 2.2-dev\n"

#. module: serial_last_location
#: field:stock.production.lot,last_location_id:0
msgid "Last Location"
msgstr "Última ubicación"
19 changes: 19 additions & 0 deletions serial_last_location/i18n/es_MX.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_unique_serial
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-20 01:19+0000\n"
"PO-Revision-Date: 2016-07-20 02:05+0000\n"
"Last-Translator: Humberto Arocha <hbto@vauxoo.com>\n"
"Language-Team: Spanish <http://example.com/projects/stock-logistic-"
"workflow/product_unique_serial/es/>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 2.2-dev\n"
19 changes: 19 additions & 0 deletions serial_last_location/i18n/es_PA.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_unique_serial
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-20 01:19+0000\n"
"PO-Revision-Date: 2016-07-20 02:05+0000\n"
"Last-Translator: Humberto Arocha <hbto@vauxoo.com>\n"
"Language-Team: Spanish <http://example.com/projects/stock-logistic-"
"workflow/product_unique_serial/es/>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 2.2-dev\n"
2 changes: 2 additions & 0 deletions serial_last_location/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import stock_production_lot
39 changes: 39 additions & 0 deletions serial_last_location/models/stock_production_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding: utf-8
############################################################################
# Module Writen For Odoo, Open Source Management Solution
#
# Copyright (c) 2017 Vauxoo - http://www.vauxoo.com
# All Rights Reserved.
# info Vauxoo (info@vauxoo.com)
# coded by: Vauxoo
############################################################################
from openerp import api, fields, models


class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'

@api.multi
@api.depends('quant_ids.location_id')
def _compute_get_last_location_id(self):
for record in self:
if record.quant_ids.ids:
last_quant_id = max(record.quant_ids.ids)
last_quant_data = self.env['stock.quant'].browse(last_quant_id)
record.last_location_id = last_quant_data.location_id.id
else:
record.last_location_id = False

last_location_id = fields.Many2one(
'stock.location',
string="Last Location",
compute='_compute_get_last_location_id',
store=True)

# Overwrite field to deny create serial number duplicated
ref = fields.Char('Internal Reference',
help="Internal reference number"
" in this case it"
" is same of manufacturer's"
" serial number",
related="name", store=True, readonly=True)
1 change: 1 addition & 0 deletions serial_last_location/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_last_location
73 changes: 73 additions & 0 deletions serial_last_location/tests/test_last_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# coding: utf-8
############################################################################
# Module Writen For Odoo, Open Source Management Solution
#
# Copyright (c) 2016 Vauxoo - http://www.vauxoo.com
# All Rights Reserved.
# info Vauxoo (info@vauxoo.com)
# coded by: Yanina Aular <yanina.aular@vauxoo.com>
# planned by: Yanina Aular <yanina.aular@vauxoo.com>
############################################################################

from openerp.tests.common import TransactionCase


class TestLastLocation(TransactionCase):

def test_last_location(self):
picking_obj = self.env['stock.picking']
move_obj = self.env["stock.move"]
stock_pack_obj = self.env['stock.pack.operation']
location_id = self.ref('stock.stock_location_suppliers')
location_dest_id = self.ref('stock.stock_location_stock')

picking_id = picking_obj.create(
{
'picking_type_id': self.ref('stock.picking_type_in'),
"location_id": location_id,
"location_dest_id": location_dest_id,
})

product_rec = self.env.ref('product.product_product_4')

move = move_obj.create({
"name": product_rec.name,
"product_id": product_rec.id,
"product_uom": product_rec.uom_id.id,
"product_uom_qty": 1.0,
"picking_id": picking_id.id,
"location_id": location_id,
"location_dest_id": location_dest_id,
})

serial_test = self.env['stock.production.lot'].create({
'product_id': product_rec.id,
'name': 'Product Serial Test Serial Las Location',
})

picking = move.picking_id

wizard_id = stock_pack_obj.create({
'picking_id': picking.id,
'product_qty': move.product_uom_qty,
'product_uom_id': self.env.ref('product.product_uom_unit').id,
'location_id': picking.location_id.id,
'location_dest_id': picking.location_dest_id.id,
'product_id': move.product_id.id,
'qty_done': move.product_uom_qty,
})

stock_pack_lot = self.env['stock.pack.operation.lot']
stock_pack_lot.create({
'operation_id': wizard_id.id,
'lot_id': serial_test.id,
})

stock_backorder_confirmation = \
self.env["stock.backorder.confirmation"]
backorder = stock_backorder_confirmation.create({
"pick_id": picking.id,
})
backorder.process()

self.assertEquals(serial_test.last_location_id.id, location_dest_id)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<odoo>
<data>

<record id="view_production_lot_form_inh_pus" model="ir.ui.view">
Expand All @@ -14,4 +14,4 @@
</record>

</data>
</openerp>
</odoo>
2 changes: 1 addition & 1 deletion stock_no_negative/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"js": [],
"css": [],
"qweb": [],
"installable": True,
"installable": False,
"auto_install": False
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2 changes: 1 addition & 1 deletion stock_picking_invoice_link/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
],
"demo": [],
'test': [],
'installable': True,
'installable': False,
}

0 comments on commit e4bf5a0

Please sign in to comment.