.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

=============================
Stock Picking Auto Create Lot
=============================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:a76cf4f0c688d326d898c417e704342dcf91006e64c2d012e7d0e3f6ab4713d3
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/16.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-16-0/stock-logistics-workflow-16-0-stock_picking_auto_create_lot
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
    :alt: Try me on Runboat

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

This module extends the functionality of stock module to allow auto create
lots for selected picking types.

**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.

#. Go to a *Inventory > Configuration > Products > Product Categories*.
#. Set 'auto create lot' option for the categories you need.

It's possible to configure by code a way to force the setting of the auto lot when
printing the detailed operation labels. To do so, pass the context key `force_auto_lot`
to the report. This is a simple example with a server action, but it can be done with
overriding methods as well:

.. code-block:: xml

     <record id="action_print_detailed_operation" model="ir.actions.server">
          <field name="name">Print detailed operations</field>
          <field name="model_id" ref="stock.model_stock_move_line" />
          <field
                name="binding_model_id"
                ref="stock.model_stock_move_line"
          />
          <field name="binding_view_types">list</field>
          <field name="state">code</field>
          <field name="code">
     if records:
          report = env["ir.actions.report"].sudo()._get_report("my_custom_module.my_custom_report_xml_id")
          action = report.with_context(force_auto_lot=True).report_action(records.ids)
          </field>
     </record>

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 on the product or in the category.
#. 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 to smash 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:%2016.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>
* `Quartile <https://www.quartile.co>`__:

  * Aung Ko Ko Lin

* Eduardo de Miguel <info@moduon.team>

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/16.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.
