# Lot duplication

**URL:** <https://discuss.tryton.org/t/lot-duplication/618>\
**Category:** Feature\
**Tags:** stock\
**Created:** [July 20, 2018, 8:23am UTC](https://discuss.tryton.org/t/lot-duplication/618 "2018-07-20T08:23:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)\
**Post date:** [July 20, 2018, 8:23am UTC](https://discuss.tryton.org/t/lot-duplication/618/1 "2018-07-20T08:23:03Z")

</div>

## Rational

It is quite common users duplicate lot numbers. Despite adding custom constraints the duplications exists (as an example: for a product “P” the users create lot numbers “XY” and “L-XY”, that are the same).

## Proposal

Create a wizard similar to [party duplication wizard](https://discuss.tryton.org/t/party-duplication/168) that allows to join many lots in one.  
The wizard will be launch for two or more lots, and user will mark which is the valid lot.  
The wizard could have some comparison checks that will trigger a warning if lot fields does not match (in case lot model is extended).  
Lots duplicated will be removed (there isn’t active field).  
If lots are involved in period caches, the process will be canceled.  
The reference fields to relink:

- Move: lot
- Inventory: lot

## Implementation

---

<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:** [July 20, 2018, 8:56am UTC](https://discuss.tryton.org/t/lot-duplication/618/2 "2018-07-20T08:56:29Z")

</div>

> [@sergyo](#):
>
> Despite adding custom constraints the duplications exists

I guess the couple number, product may have a unique constraint.

> [@sergyo](#):
>
> for a product “P” the users create lot numbers “XY” and “L-XY”, that are the same

Why are they the same if the numbers are different?

> [@sergyo](#):
>
> Create a wizard similar to [party duplication wizard](https://discuss.tryton.org/t/party-duplication/168) that allows to join many lots in one.

Indeed lot are useful for traceability, so it is not really a matter of curating the past. But having a view that show the full traceability of a lot which should include a way to link two lots together (like it should be done for production). So for me, it is more about implementing traceability view.

> [@sergyo](#):
>
> If lots are involved in period caches, the process will be canceled.

For me, this makes the proposal not really useful.

---

<div class="post-metadata">

**Author:** ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)\
**Post date:** [July 20, 2018, 9:43am UTC](https://discuss.tryton.org/t/lot-duplication/618/3 "2018-07-20T09:43:18Z")

</div>

> [@ced](#):
>
> I guess the couple number, product may have a unique constraint.

We get it [1] but it is not enough …

[1] [https://bitbucket.org/datalife\_sco/trytond-stock\_lot\_unique](https://bitbucket.org/datalife_sco/trytond-stock_lot_unique)

> [@ced](#):
>
> Why are they the same if the numbers are different?

Are the same because second user decide to create a new lot with prefix “L-” instead of searching if lot exists.

---

<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:** [July 20, 2018, 10:36am UTC](https://discuss.tryton.org/t/lot-duplication/618/4 "2018-07-20T10:36:51Z")

</div>

> [@sergyo](#):
>
> Are the same because second user decide to create a new lot with prefix “L-” instead of searching if lot exists.

This sounds more like an educational issue than a technical issue.  
Any way, I do not think the solution is to have a replace wizard but more about having a place to link lot together like if it was a production.

---

<div class="post-metadata">

**Author:** ![sergyo](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/sergyo/32/181_2.png) [@sergyo](https://discuss.tryton.org/u/sergyo)\
**Post date:** [July 20, 2018, 10:56am UTC](https://discuss.tryton.org/t/lot-duplication/618/5 "2018-07-20T10:56:58Z")

</div>

> [@ced](#):
>
> This sounds more like an educational issue than a technical issue.

Yes it is, same way that party duplication.

> [@ced](#):
>
> Any way, I do not think the solution is to have a replace wizard but more about having a place to link lot together like if it was a production.

Are you thinking about relating lots and modify lot stock query to take it into account?

---

<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:** [July 20, 2018, 11:37am UTC](https://discuss.tryton.org/t/lot-duplication/618/6 "2018-07-20T11:37:02Z")

</div>

> [@sergyo](#):
>
> Are you thinking about relating lots and modify lot stock query to take it into account?

I’m thinking about relating lots but not changing the stock query. I do not see any need for that.  
The purpose of lot is the traceability, so it is that must be fixed (but we do not have it yet).
