Skip to content

Commit

Permalink
[MIG] altinkaya_stock_lot
Browse files Browse the repository at this point in the history
  • Loading branch information
umithan-guldemir committed Feb 4, 2025
1 parent 793bc7a commit 089c8cd
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 154 deletions.
4 changes: 4 additions & 0 deletions altinkaya_stock_lot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
# from . import wizards
10 changes: 5 additions & 5 deletions altinkaya_stock_lot/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# Copyright 2025 Yiğit Budak, Ümithan Güldemir (https://github.com/yibudak) (https://github.com/umithan-guldemir)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Altinkaya Stock Lot Extensions",
"summary": "Adds custom fields to stock.production.lot",
"version": "13.0.1.0.0",
"version": "16.0.1.0.0",
"category": "stock",
"website": "https://github.com/yibudak",
"author": "Yiğit Budak",
"author": "Yiğit Budak, Ümithan Güldemir",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["stock", "mrp"],
"depends": ["stock", "mrp", "stock_inventory"],
"data": [
"wizards/mrp_product_produce_view.xml",
# "wizards/mrp_product_produce_view.xml",
],
}
48 changes: 48 additions & 0 deletions altinkaya_stock_lot/i18n/altinkaya_stock_lot.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * altinkaya_stock_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-28 08:07+0000\n"
"PO-Revision-Date: 2022-12-28 08:07+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: altinkaya_stock_lot
#: model:ir.model,name:altinkaya_stock_lot.model_stock_production_lot
msgid "Lot/Serial"
msgstr ""

#. module: altinkaya_stock_lot
#: model:ir.model.fields,field_description:altinkaya_stock_lot.field_stock_production_lot__name
msgid "Lot/Serial Number"
msgstr ""

#. module: altinkaya_stock_lot
#: model:ir.model,name:altinkaya_stock_lot.model_mrp_product_produce
msgid "Record Production"
msgstr ""

#. module: altinkaya_stock_lot
#: model:ir.model,name:altinkaya_stock_lot.model_stock_picking
msgid "Transfer"
msgstr ""

#. module: altinkaya_stock_lot
#: model:ir.model.fields,help:altinkaya_stock_lot.field_stock_production_lot__name
msgid "Unique Lot/Serial Number"
msgstr ""

#. module: altinkaya_stock_lot
#: code:addons/altinkaya_stock_lot/wizards/mrp_product_produce.py:16
#, python-format
msgid "You have to select a product."
msgstr ""

48 changes: 48 additions & 0 deletions altinkaya_stock_lot/i18n/tr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * altinkaya_stock_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-28 08:07+0000\n"
"PO-Revision-Date: 2022-12-28 08:07+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: altinkaya_stock_lot
#: model:ir.model,name:altinkaya_stock_lot.model_stock_production_lot
msgid "Lot/Serial"
msgstr "Lot/Seri"

#. module: altinkaya_stock_lot
#: model:ir.model.fields,field_description:altinkaya_stock_lot.field_stock_production_lot__name
msgid "Lot/Serial Number"
msgstr "Lot/Seri Numarası"

#. module: altinkaya_stock_lot
#: model:ir.model,name:altinkaya_stock_lot.model_mrp_product_produce
msgid "Record Production"
msgstr "Üretimi Kaydını İşle"

#. module: altinkaya_stock_lot
#: model:ir.model,name:altinkaya_stock_lot.model_stock_picking
msgid "Transfer"
msgstr "Transfer"

#. module: altinkaya_stock_lot
#: model:ir.model.fields,help:altinkaya_stock_lot.field_stock_production_lot__name
msgid "Unique Lot/Serial Number"
msgstr "Benzersiz Lot / Seri Numarası"

#. module: altinkaya_stock_lot
#: code:addons/altinkaya_stock_lot/wizards/mrp_product_produce.py:16
#, python-format
msgid "You have to select a product."
msgstr "Üretilecek bir ürün seçmelisiniz."

5 changes: 5 additions & 0 deletions altinkaya_stock_lot/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import stock_lot
from . import stock_move_line
# from . import stock_quant
11 changes: 0 additions & 11 deletions altinkaya_stock_lot/models/stock_inventory.py

This file was deleted.

44 changes: 0 additions & 44 deletions altinkaya_stock_lot/models/stock_inventory_line.py

This file was deleted.

28 changes: 28 additions & 0 deletions altinkaya_stock_lot/models/stock_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
import random

from odoo import fields, models


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

def _compute_lot_name(self):
"""Generates a random lot number. Overrides the default method.
We excluded some characters from the random string to avoid confusion."""
while True:
unique = "".join(
random.choice("ABCDEFGHJKLMNPRSTUVXYZ123456789") for i in range(5)
)
if not self.search([("name", "=", unique)], limit=1):
break
return unique

name = fields.Char(
"Lot/Serial Number",
default=_compute_lot_name,
required=True,
readonly=True,
help="Unique Lot/Serial Number",
)
15 changes: 7 additions & 8 deletions altinkaya_stock_lot/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models, api
from odoo import api, models


class StockMoveLine(models.Model):
_inherit = "stock.move.line"


def _create_missing_lot(self):
"""EXPERIMENTAL: Create a lot for the move line if it is missing."""
"""Create a lot for the move line if it is missing."""
for rec in self:
if rec.product_id.tracking != "none" and not rec.lot_id:
lot_id = self.env["stock.production.lot"].create(
{"product_id": rec.product_id.id, "ref": rec.move_id.name or ""}
lot_id = self.env["stock.lot"].create(
{"product_id": rec.product_id.id, "ref": rec.move_id.reference or ""}
)
rec.lot_id = lot_id.id
return True

@api.model
def create(self, vals):
res = super(StockMoveLine, self).create(vals)
def create(self, vals_list):
res = super().create(vals_list)
res._create_missing_lot()
return res

@api.model
def write(self, vals):
res = super(StockMoveLine, self).write(vals)
res = super().write(vals)
self._create_missing_lot()
return res
45 changes: 0 additions & 45 deletions altinkaya_stock_lot/models/stock_picking.py

This file was deleted.

28 changes: 28 additions & 0 deletions altinkaya_stock_lot/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from odoo import api, models


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

def _create_missing_lot(self, vals_list):
"""EXPERIMENTAL: Create a lot for the move line if it is missing."""
for vals in vals_list:
if not vals.get("lot_id") and vals.get("product_id") and (vals.get("quantity") or vals.get("inventory_quantity")):
product_id = self.env["product.product"].browse(vals["product_id"])
if product_id.tracking != "none":
lot_id = self.env["stock.lot"].create(
{
"product_id": product_id.id,
"ref": vals.get("stock_inventory_ids") or "", #todo: find a better ref
"product_qty": vals.get("quantity") or vals.get("inventory_quantity"),
}
)
vals["lot_id"] = lot_id.id


@api.model_create_multi
def create(self, vals_list):
self._create_missing_lot(vals_list)
res = super().create(vals_list)

return res
Binary file added altinkaya_stock_lot/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions altinkaya_stock_lot/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright 2022 Yiğit Budak (https://github.com/yibudak)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from . import mrp_product_produce
Loading

0 comments on commit 089c8cd

Please sign in to comment.