forked from OCA/stock-logistics-workflow
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] serial_last_location: New stock_production_lot_last_location mo…
…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
Showing
19 changed files
with
211 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import stock_production_lot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_last_location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,5 @@ | |
], | ||
"demo": [], | ||
'test': [], | ||
'installable': True, | ||
'installable': False, | ||
} |