# Automatically numbering lots

**URL:** https://discuss.tryton.org/t/automatically-numbering-lots/2148
**Category:** Ideas
**Tags:** stock
**Created:** [January 3, 2020, 5:31pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148 "2020-01-03T17:31:31Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [January 3, 2020, 5:31pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/1 "2020-01-03T17:31:31Z")

</div>

Currently when producing products which require a lot the number must be explicitly set. But most of the time the lot number can be autogenerated using a sequence as the proupose of this field is to link the products with the production, so all the components and operations can be easly found.

This is specially usefull when working with [serial numbers](https://docs.tryton.org/projects/modules-stock-lot-unit/en/latest/index.html).

I think we should allow to set a lot sequence on production configuration and use this sequence to automatically create a lot for each output product that requires a lot if not set

As this may not be usefull for all tryton setups probably this should be part of a new module.

Thoughts?

---

<div class="post-metadata">

### Author: ![wifasoi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/w/ed655f/32.png) [@wifasoi](https://discuss.tryton.org/u/wifasoi)
#### Post date: [January 3, 2020, 6:07pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/2 "2020-01-03T18:07:10Z")

</div>

I think this should be implemented, because serialising/lot a product is a common task.

A little side note:  
Rign now stock move can have only a lot. When you want to serialise inbound product, you need to split the move. This is quite tedious. Maybe using a sequence can be a solution here.

Side-side note (almost off-topic):  
What about supporting sequences based on uuid?  
This can be useful for integrating a hybrid workflow, like pre-printing uuid sticker to affix to product/stock, or having a sticker printed on demand via tryton.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [January 3, 2020, 9:23pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/3 "2020-01-03T21:23:02Z")

</div>

> [@pokoli](#):
>
> allow to set a lot sequence on production configuration

I think the configuration should be set per producible product (and even maybe per product-bom) because it is quite common that the production number format depend on this.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [January 7, 2020, 2:21pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/4 "2020-01-07T14:21:55Z")

</div>

> [@ced](#):
>
> I think the configuration should be set per producible product (and even maybe per product-bom)

Ok but I think it will be good to also have a default value for it so simpler cases can be easly managed.

---

<div class="post-metadata">

### Author: ![uha4](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/u/ccd318/32.png) [@uha4](https://discuss.tryton.org/u/uha4)
#### Post date: [January 24, 2020, 6:15pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/5 "2020-01-24T18:15:22Z")

</div>

there is already a module doing this from NaN-tic:  
[https://bitbucket.org/nantic/trytond-stock\_lot\_sequence](https://bitbucket.org/nantic/trytond-stock_lot_sequence)

I’m using this since a few years. could be at least a place to start with…

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [January 27, 2020, 8:58am UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/6 "2020-01-27T08:58:09Z")

</div>

Indeed the proposal is to replace this module and inclue it as part of the trytond oficial modules.

For me the stock\_lot\_sequence module does to much things and the idea is to simplify. Do you think the current proposal also fits your current usage of the module or do you have some special case to be solved?

Your feedback will be much appreciated.

---

<div class="post-metadata">

### Author: ![uha4](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/u/ccd318/32.png) [@uha4](https://discuss.tryton.org/u/uha4)
#### Post date: [February 3, 2020, 10:38am UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/7 "2020-02-03T10:38:59Z")

</div>

I just had another look at the module.  
Except the company configuration, i think it is quite to the point. Your Proposal includes even more: stock\_lot\_sequence does only fill the lot number at creation, you proposed to generate the whole lot automaticly within production.

I have made several modules to deal with lots on my own. one of them adds a button at the production output move to automaticly create the lot, and if there is no required lot when the production is run, it also gets generated automaticly. So this point would fit me too.  
But as i’m using stock\_lot\_sled and i added additional Fields to the lot, some more information is requiered to fill in the lot data. my module takes them from the product input lots. But so these have to be checked to be filled first.

Another configuration i have made in the Product is, if you want to use the expiary date as a lot number, but this of cause onli works with stock\_lot\_sled, so it has to be in a extra module

If you build a official module i will use it, but i will anyway have to review my modules to fit with the changes.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 5, 2020, 5:56pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/8 "2020-11-05T17:56:19Z")

</div>

I started to work on this by adding a wizard on the stock move (similar to the split) to define quickly lot number and quantity.  
The idea is that if there is a lot sequence defined on the product, user can leave the lot number empty.  
When validated the wizard split the move according to the quantities and create a corresponding lot to set. If the `stock_lot_sled` is activated, the new field will be displayed and filled when default value (if possible).  
The wizard will be available on shipment and production because it aims to ease the filling of lot even if they are not generated.  
I’m thinking about adding a button on the wizard, from `stock_lot_unit` module, to fill automatically a lot per unit.

Finally I do not think the production should create lot automatically because it is difficult to make it match any kind of workflow (e.g. the result may require to be split and assign two different lot). But with such wizard it will be easier for the user.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [November 5, 2020, 6:13pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/9 "2020-11-05T18:13:55Z")

</div>

> [@ced](#):
>
> Finally I do not think the production should create lot automatically because it is difficult to make it match any kind of workflow (e.g. the result may require to be split and assign two different lot). But with such wizard it will be easier for the user.

I do not understand the rational. Why it may be required to split the production into diferent lots? The only case is when using serial numbers but in this case there is already a validation that prevents to set a move with more than serial quantity. SO the user will be forced to split the moves (and then we should set a sequence for each lot)

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 5, 2020, 7:34pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/10 "2020-11-05T19:34:13Z")

</div>

> [@pokoli](#):
>
> Why it may be required to split the production into diferent lots?

For example a part of the production has required some special treatment or was built a little bit differently etc.  
In all case I think it is always better to have clear action from the user than automatic fallback behavior. Especially if there is no going back possibility.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 6, 2020, 4:16pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/11 "2020-11-06T16:16:22Z")

</div>

Here is [Add wizard to fill lots on stock move (#9800) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9800)  
I tried to make the wizard smart so it will not create duplicate lots. So if a lot with the same values exist it will reuse it instead of creating a new one. Also `stock_slot_sled` fill automatically the expiration date using the product default value or the lot with the same number if exists. Idem for `stock_slot_unit` with the unit and unit quantity.  
So this prevents to add a unique constraint on the lot number (per product) which allow to use number from external source (which is never guarantee to be unique), but still limit duplication by default.  
I think it will be good to add a merge lot wizard: [Add wizard to merge duplicate lot (#9801) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9801)

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [November 7, 2020, 7:34pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/12 "2020-11-07T19:34:52Z")

</div>

Thanks for your work on this. I’ve tested the wizard and I think its a really good improvement but I’m still missing a way to create a bunch of lot numbers.

I propose to also add also a “Number of lots” field which will be only possible to edit when there are no lines. When the user sets this number the wizard automatically create the entered number of lines distributing the quantities evently (but we should allow customization). The user can set the numbers (if required) and adjust the quantities before creating new lots

Using this button will speed up the time required to create 50 new serial numbers using the sequence. For this operation we currently require 50 clicks to create a new line, while using the number it can be easly done with 2 clicks.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 7, 2020, 9:10pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/13 "2020-11-07T21:10:44Z")

</div>

I think this is specific to lot used as serial number and only for production result. So for me this should be managed by a dedicated button on production or even it may be done automatically by the `Production.explode_bom` for product with unit lot and a sequence.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 7, 2020, 9:29pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/14 "2020-11-07T21:29:54Z")

</div>

Indeed we can not know if the lot that will be set are “serial number” or not because it is defined on the the lot.  
Maybe a better way to deal with this need is by improving the `product` attribute of One2Many widget. We could have an option that ask for a number and fill as much of new record.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 8, 2020, 11:55am UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/15 "2020-11-08T11:55:29Z")

</div>

Well any of the above solution are really working because they do no manage correctly the setup of the lot like the expiration date, the quantity unit etc.  
So I think the best solution would be to have an instance button on the wizard that is visible only when a single lot is created. The button goes with an integer field and when clicked it duplicate the existing lot as much times as the integer field. This way the user can setup the lot with the quantity, the expiration date etc.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 23, 2020, 6:41pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/16 "2020-11-23T18:41:03Z")

</div>

> [@ced](#):
>
> the best solution would be to have an instance button on the wizard

This is implemented on the last version of the patch.

---

<div class="post-metadata">

### Author: ![uha4](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/u/ccd318/32.png) [@uha4](https://discuss.tryton.org/u/uha4)
#### Post date: [December 15, 2020, 12:45pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/17 "2020-12-15T12:45:10Z")

</div>

I don’t see the need for a wizard, having many small productions this would be a significant overhead.

I see three use-cases discussed so far:

1. one production output is going to be a single lot. In this case a simple Button ‘generate Lot’ in the Move would be enough and fastest to use. This is my use-case and how i set it up in a custom module.
2. you have to generate 2 or 3 lots because something in the production was different. This is basically a special case of No.1, otherwise i would consider it two productions. In this case I use stock\_split module to split the move, and than the simple Button on the move is also enough to generate the lots.
3. every Item should get it’s serial number, so every Item gets its own lot and therefore needs it’s own move. I would expect a setting at the product to indicate if it should have serial numbers. The function that is called on ‘generate lot’ could check this setting and than automatically split the moves and generate the lots. In this case there is no question in how many moves/lots to split, it’s just the quantity.

This way it would be the straight with a single click in the standard cases of production or shipment. Scenario 2 is more likely the exception than the rule, so i think this can be the one with a longer workflow. I agree to think ahead and prepare for possible and special cases, but this should not complicate the standard workflow of every day.

If you build all of this into stock\_lot or is this going to be a new module?  
I would prefer it to be a new module (like ‘stock\_lot\_auto’?), so it can be used with or without stock\_split or one could use the existing stock\_lot module without the new wizard.

PS:  
Sorry for answering relatively late, I havn’t been here for a while and the Mails about changes in this topic somehow didn’t reach me…

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [February 26, 2021, 5:00pm UTC](https://discuss.tryton.org/t/automatically-numbering-lots/2148/18 "2021-02-26T17:00:05Z")

</div>

This topic was automatically closed after 13 days. New replies are no longer allowed.
