Skip to content

Commit

Permalink
[IMP] product_lot_sequence: add lot_sequence_padding configuration,vi…
Browse files Browse the repository at this point in the history
…ews adjustment

- Make number of digits to be set on products for sequence generation configurable.
- Fix a minor issue of _compute_display_lot_sequence_fields() not running before
  product is created.
- Make lot_sequence_prefix and lot_sequence_padding invisible when lot_sequence_id
  is assigned to the product (since these values are no longer relevant once the
  sequence is generated.
  • Loading branch information
AungKoKoLin1997 committed Nov 15, 2024
1 parent 6465bf9 commit 70524bc
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 21 deletions.
14 changes: 13 additions & 1 deletion product_lot_sequence/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Product Lot Sequence
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:043a59e32b82ffdcafdd494fdb97e28127e8489913d173aefed770e79efc18ce
!! source digest: sha256:b40154ba5f1de85d89cb1c8da85a999bd0cd850538e477e4eb0d9a7272af0bbd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -38,6 +38,9 @@ Adds ability to define a lot sequence from the product which will be proposed up
Configuration
=============

Lot Sequence policy
~~~~~~~~~~~~~~~~~~~

There are two ways you can configure this module through the use of System Parameter
`product_lot_sequence.policy`:

Expand All @@ -52,6 +55,12 @@ If any other value is used for this System Parameter, then you will get the defa
behaviour from odoo 15.0 which will look for the last lot number for each product and
will increment it.

Default Number of Digits for Product Sequence Generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The default is 7 digits. To change that to something else, go to the inventory
configuration, find "Sequence Number of Digits" and change the number.

Usage
=====

Expand Down Expand Up @@ -103,6 +112,9 @@ Contributors
* Adria Gil Sorribes <[email protected]>
* Domantas Girdžiūnas <[email protected]>
* Akim Juillerat <[email protected]>
* `Quartile <https://www.quartile.co>`__:

* Yoshi Tashiro

Maintainers
~~~~~~~~~~~
Expand Down
6 changes: 5 additions & 1 deletion product_lot_sequence/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"depends": ["stock"],
"data": ["data/ir_config_parameter.xml", "views/product_views.xml"],
"data": [
"data/ir_config_parameter.xml",
"views/product_views.xml",
"views/res_config_settings_views.xml",
],
}
2 changes: 2 additions & 0 deletions product_lot_sequence/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from . import res_company
from . import res_config_settings
from . import product
from . import stock_production_lot
from . import stock_move
3 changes: 2 additions & 1 deletion product_lot_sequence/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ProductTemplate(models.Model):
)
lot_sequence_padding = fields.Integer(
string="Sequence Number of Digits",
default=7,
default=lambda self: self.env.company.lot_sequence_padding,
help="The lots' sequence will be created using this number of digits.",
)
lot_sequence_number_next = fields.Integer(
Expand All @@ -32,6 +32,7 @@ class ProductTemplate(models.Model):
compute="_compute_display_lot_sequence_fields"
)

@api.depends("tracking") # For products being created (before saved).
def _compute_display_lot_sequence_fields(self):
self.display_lot_sequence_fields = (
self.env["stock.production.lot"]._get_sequence_policy() == "product"
Expand Down
10 changes: 10 additions & 0 deletions product_lot_sequence/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

lot_sequence_padding = fields.Integer("Sequence Number of Digits", default=7)
13 changes: 13 additions & 0 deletions product_lot_sequence/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Quartile Limited
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

lot_sequence_padding = fields.Integer(
related="company_id.lot_sequence_padding",
readonly=False,
)
9 changes: 9 additions & 0 deletions product_lot_sequence/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Lot Sequence policy
~~~~~~~~~~~~~~~~~~~

There are two ways you can configure this module through the use of System Parameter
`product_lot_sequence.policy`:

Expand All @@ -11,3 +14,9 @@ There are two ways you can configure this module through the use of System Param
If any other value is used for this System Parameter, then you will get the default
behaviour from odoo 15.0 which will look for the last lot number for each product and
will increment it.

Default Number of Digits for Product Sequence Generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The default is 7 digits. To change that to something else, go to the inventory
configuration, find "Sequence Number of Digits" and change the number.
3 changes: 3 additions & 0 deletions product_lot_sequence/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Adria Gil Sorribes <[email protected]>
* Domantas Girdžiūnas <[email protected]>
* Akim Juillerat <[email protected]>
* `Quartile <https://www.quartile.co>`__:

* Yoshi Tashiro
48 changes: 32 additions & 16 deletions product_lot_sequence/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,27 +367,33 @@ <h1 class="title">Product Lot Sequence</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:043a59e32b82ffdcafdd494fdb97e28127e8489913d173aefed770e79efc18ce
!! source digest: sha256:b40154ba5f1de85d89cb1c8da85a999bd0cd850538e477e4eb0d9a7272af0bbd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/product-attribute/tree/15.0/product_lot_sequence"><img alt="OCA/product-attribute" src="https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/product-attribute-15-0/product-attribute-15-0-product_lot_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds ability to define a lot sequence from the product which will be proposed upon creating new lots.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a><ul>
<li><a class="reference internal" href="#lot-sequence-policy" id="toc-entry-2">Lot Sequence policy</a></li>
<li><a class="reference internal" href="#default-number-of-digits-for-product-sequence-generation" id="toc-entry-3">Default Number of Digits for Product Sequence Generation</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage" id="toc-entry-4">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-5">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-6">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-7">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-8">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-9">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-10">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<div class="section" id="lot-sequence-policy">
<h2><a class="toc-backref" href="#toc-entry-2">Lot Sequence policy</a></h2>
<p>There are two ways you can configure this module through the use of System Parameter
<cite>product_lot_sequence.policy</cite>:</p>
<ul class="simple">
Expand All @@ -401,8 +407,14 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
behaviour from odoo 15.0 which will look for the last lot number for each product and
will increment it.</p>
</div>
<div class="section" id="default-number-of-digits-for-product-sequence-generation">
<h2><a class="toc-backref" href="#toc-entry-3">Default Number of Digits for Product Sequence Generation</a></h2>
<p>The default is 7 digits. To change that to something else, go to the inventory
configuration, find “Sequence Number of Digits” and change the number.</p>
</div>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Usage</a></h1>
<p>To use this module:</p>
<ul class="simple">
<li>Go to Inventory &gt; Products</li>
Expand All @@ -414,7 +426,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>There is an issue with the use of ir.sequence with the newer version of Odoo.</li>
</ul>
Expand All @@ -428,31 +440,35 @@ <h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<p>cf <a class="reference external" href="https://github.com/OCA/product-attribute/issues/1326">https://github.com/OCA/product-attribute/issues/1326</a></p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-6">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/product-attribute/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/product-attribute/issues/new?body=module:%20product_lot_sequence%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-7">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow S.L.</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<ul class="simple">
<li>Adria Gil Sorribes &lt;<a class="reference external" href="mailto:adria.gil&#64;forgeflow.com">adria.gil&#64;forgeflow.com</a>&gt;</li>
<li>Domantas Girdžiūnas &lt;<a class="reference external" href="mailto:domantas&#64;vialaurea.lt">domantas&#64;vialaurea.lt</a>&gt;</li>
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
<li>Yoshi Tashiro</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
4 changes: 2 additions & 2 deletions product_lot_sequence/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<field name="display_lot_sequence_fields" invisible="1" />
<field
name="lot_sequence_prefix"
attrs="{'readonly': [('lot_sequence_id', '!=', False)], 'invisible': ['|', ('tracking', 'not in', ['lot', 'serial']), ('display_lot_sequence_fields', '=', False)]}"
attrs="{'invisible': ['|', '|', ('tracking', 'not in', ['lot', 'serial']), ('display_lot_sequence_fields', '=', False), ('lot_sequence_id', '!=', False)]}"
/>
<field
name="lot_sequence_padding"
attrs="{'readonly': [('lot_sequence_id', '!=', False)], 'invisible': ['|', ('tracking', 'not in', ['lot', 'serial']), ('display_lot_sequence_fields', '=', False)]}"
attrs="{'invisible': ['|', '|', ('tracking', 'not in', ['lot', 'serial']), ('display_lot_sequence_fields', '=', False), ('lot_sequence_id', '!=', False)]}"
/>
<field
name="lot_sequence_number_next"
Expand Down
34 changes: 34 additions & 0 deletions product_lot_sequence/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.stock</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='production_lot_info']" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="lot_sequence_padding" />
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
Default number of digits to be set on products for product lot/serial sequence generation.
</div>
<div class="content-group">
<div class="mt16">
<span><field
name="lot_sequence_padding"
class="oe_inline"
/> digits</span>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 70524bc

Please sign in to comment.