Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] stock_picking_auto_create_lot #1106

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
90e0691
[11.0][ADD] stock_picking_auto_create_lot: Create lot for incoming pi…
sergio-teruel Oct 22, 2018
09069d7
[11.0][FIX] stock_picking_auto_create_lot: Not create lot if lot_name…
sergio-teruel Feb 25, 2019
e2f6120
[MIG] stock_picking_auto_create_lot: Migration to 12.0
meigallodixital Feb 25, 2019
1dc2eb8
README generated with OCA README generator
meigallodixital Feb 27, 2019
99d5f72
FIX - Incorrect branch on README.rst and index.html
meigallodixital Feb 27, 2019
77ea6ff
[IMP] stock_picking_auto_create_lot: Change latest comments:
pedrobaeza Nov 28, 2019
54170a3
[UPD] Update stock_picking_auto_create_lot.pot
oca-travis Nov 28, 2019
cbe48b3
Update translation files
oca-transbot Nov 28, 2019
a496053
[IMP] stock_picking_auto_create_lot: black, isort
ps-tubtim Dec 25, 2019
3469a19
[MIG] stock_picking_auto_create_lot: Migration to 13.0
ps-tubtim Dec 25, 2019
990f605
[UPD] Update stock_picking_auto_create_lot.pot
oca-travis Jan 7, 2020
2bbad8b
pre-commit update
OCA-git-bot Mar 14, 2020
f64adab
Added translation using Weblate (Chinese (Simplified))
dong-z Mar 21, 2020
89d9eaf
Translated using Weblate (Chinese (Simplified))
dong-z Mar 21, 2020
266b66e
[13.0][IMP] stock_picking_auto_create_lot: Improve performances and UX
rousseldenis Nov 5, 2020
7a83f48
[13.0][IMP] stock_picking_auto_create_lot: Improve tests
rousseldenis Nov 5, 2020
275a72d
[13.0][IMP] stock_picking_auto_create_lot: Allows to set lot on actio…
rousseldenis Jan 25, 2021
f5676ee
[13.0][IMP] stock_picking_auto_create_lot: Allow multi recordset
rousseldenis Jan 25, 2021
c7fa49e
[13.0][IMP] stock_picking_auto_create_lot: Fix serial generation, add…
rousseldenis Jan 26, 2021
603a84e
[UPD] Update stock_picking_auto_create_lot.pot
oca-travis Jul 28, 2021
717ee56
[UPD] README.rst
OCA-git-bot Jul 28, 2021
da1b855
stock_picking_auto_create_lot 13.0.1.1.0
OCA-git-bot Jul 28, 2021
357d402
Update translation files
oca-transbot Jul 28, 2021
6844a94
[MIG]stock_picking_auto_create_lot: Migration to 14.0
ValentinVinagre Oct 29, 2021
15b5a43
[UPD] Update stock_picking_auto_create_lot.pot
oca-travis Jun 13, 2022
59145f3
[UPD] README.rst
OCA-git-bot Jun 13, 2022
f25335e
[IMP] stock_picking_auto_create_lot: pre-commit execution
vib-adhoc Aug 17, 2022
402d01c
[MIG] stock_picking_auto_create_lot: Migration to 15.0
vib-adhoc Aug 17, 2022
3a53b5e
[UPD] Update stock_picking_auto_create_lot.pot
Aug 23, 2022
3faaf10
[UPD] README.rst
OCA-git-bot Aug 23, 2022
7d75610
[IMP] stock_auto_create_lot: pre-commit stuff
ps-tubtim Oct 10, 2022
3527945
[MIG] stock_picking_auto_create_lot: Migration to 16.0
ps-tubtim Oct 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/stock_picking_auto_create_lot/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
109 changes: 109 additions & 0 deletions stock_picking_auto_create_lot/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
=============================
Stock Picking Auto Create Lot
=============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_picking_auto_create_lot
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-15-0/stock-logistics-workflow-15-0-stock_picking_auto_create_lot
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/154/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of stock module to allow auto create
lots for incoming pickings.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

#. Go to a *Inventory > Configuration > Operation Types*.
#. Set 'auto create lot' option for this operation type.

#. Go to a *Inventory > Master Data > Products*.
#. Set 'auto create lot' option for the products you need.

Usage
=====

To use this module you need to:

#. Go to a *Product > Inventory tab*.
#. Set a tracking option for this product.
#. Set auto create lot.
#. Go to *Inventory > Incoming* and create one.
#. Validate picking without lot.

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 <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_picking_auto_create_lot%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ACSONE SA/NV
* Tecnativa

Contributors
~~~~~~~~~~~~

* Carlos Dauden <carlos.dauden@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
* Denis Roussel <denis.roussel@acsone.eu>
* Valentin Vinagre <valentin.vinagre@sygel.es>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-sergio-teruel| image:: https://github.com/sergio-teruel.png?size=40px
:target: https://github.com/sergio-teruel
:alt: sergio-teruel

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sergio-teruel|

This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_picking_auto_create_lot>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions stock_picking_auto_create_lot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
17 changes: 17 additions & 0 deletions stock_picking_auto_create_lot/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2018 Tecnativa - Sergio Teruel
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Stock Picking Auto Create Lot",
"summary": "Auto create lots for incoming pickings",
"version": "16.0.1.0.0",
"development_status": "Production/Stable",
"category": "stock",
"website": "https://github.com/OCA/stock-logistics-workflow",
"author": "ACSONE SA/NV, Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["stock"],
"data": ["views/product_views.xml", "views/stock_picking_type_views.xml"],
"maintainers": ["sergio-teruel"],
}
49 changes: 49 additions & 0 deletions stock_picking_auto_create_lot/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_auto_create_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-25 13:29+0000\n"
"PO-Revision-Date: 2019-02-25 13:29+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_picking_auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_product_product__auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_product_template__auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_stock_picking_type__auto_create_lot
msgid "Auto Create Lot"
msgstr "Auto crear lote"

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_picking_type
msgid "Picking Type"
msgstr "Tipo de albarán"

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_picking
msgid "Transfer"
msgstr "Transferir"
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_auto_create_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \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: stock_picking_auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_product_product__auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_product_template__auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_stock_picking_type__auto_create_lot
msgid "Auto Create Lot"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_picking_type
msgid "Picking Type"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_product_template
msgid "Product Template"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_picking
msgid "Transfer"
msgstr ""
49 changes: 49 additions & 0 deletions stock_picking_auto_create_lot/i18n/zh_CN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_picking_auto_create_lot
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-03-21 15:13+0000\n"
"Last-Translator: Dong <dong@freshoo.cn>\n"
"Language-Team: none\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 3.10\n"

#. module: stock_picking_auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_product_product__auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_product_template__auto_create_lot
#: model:ir.model.fields,field_description:stock_picking_auto_create_lot.field_stock_picking_type__auto_create_lot
msgid "Auto Create Lot"
msgstr "自动创建批次"

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_picking_type
msgid "Picking Type"
msgstr "作业类型"

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_move_line
msgid "Product Moves (Stock Move Line)"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_product_template
msgid "Product Template"
msgstr "产品模版"

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: stock_picking_auto_create_lot
#: model:ir.model,name:stock_picking_auto_create_lot.model_stock_picking
msgid "Transfer"
msgstr "调拨"
6 changes: 6 additions & 0 deletions stock_picking_auto_create_lot/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import product
from . import stock_picking
from . import stock_picking_type
from . import stock_move_line
from . import stock_move
9 changes: 9 additions & 0 deletions stock_picking_auto_create_lot/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2018 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

auto_create_lot = fields.Boolean()
24 changes: 24 additions & 0 deletions stock_picking_auto_create_lot/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models


class StockMove(models.Model):

_inherit = "stock.move"

@api.depends(
"has_tracking",
"picking_type_id.auto_create_lot",
"product_id.auto_create_lot",
"picking_type_id.use_existing_lots",
"state",
)
def _compute_display_assign_serial(self):
super()._compute_display_assign_serial()
moves_not_display = self.filtered(
lambda m: m.picking_type_id.auto_create_lot and m.product_id.auto_create_lot
)
for move in moves_not_display:
move.display_assign_serial = False
return
39 changes: 39 additions & 0 deletions stock_picking_auto_create_lot/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
from odoo.fields import first


class StockMoveLine(models.Model):

_inherit = "stock.move.line"

def _prepare_auto_lot_values(self):
"""
Prepare multi valued lots per line to use multi creation.
"""
self.ensure_one()
return {"product_id": self.product_id.id, "company_id": self.company_id.id}

def set_lot_auto(self):
"""
Create lots using create_multi to avoid too much queries
As move lines were created by product or by tracked 'serial'
products, we apply the lot with both different approaches.
"""
values = []
stock_lot_obj = self.env["stock.lot"]
lots_by_product = dict()
for line in self:
values.append(line._prepare_auto_lot_values())
lots = stock_lot_obj.create(values)
for lot in lots:
if lot.product_id.id not in lots_by_product:
lots_by_product[lot.product_id.id] = lot
else:
lots_by_product[lot.product_id.id] += lot
for line in self:
lot = first(lots_by_product[line.product_id.id])
line.lot_id = lot
if lot.product_id.tracking == "serial":
lots_by_product[line.product_id.id] -= lot
Loading