# Copy resources to created documents

**URL:** https://discuss.tryton.org/t/copy-resources-to-created-documents/2444
**Category:** Feature
**Created:** [March 12, 2020, 3:53pm UTC](https://discuss.tryton.org/t/copy-resources-to-created-documents/2444 "2020-03-12T15:53:20Z")
**Posts on this page:** 5
**Page:** 1

<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: [March 12, 2020, 3:53pm UTC](https://discuss.tryton.org/t/copy-resources-to-created-documents/2444/1 "2020-03-12T15:53:20Z")

</div>

## Rational

Attachments and notes are flexible tools that user can use to share informal information.  
But on document like sale or purchase orders, the information may need to be passed to created documents like shipments or invoices. This is mainly because the user has an information to share for a document (e.g. shipment that is not yet created). The natural place at that time is to put the information on the order that will create the document (e.g. the sale).

## Proposal

We add on the `ResourceMixin` a `MultiSelection` field that contains the list of resources the record must be copied to. The selection is dynamic and depend on the main resource (E.g. for `sale.sale`, it will contain `stock.shipment.out`, `account.invoice`, `stock.shipment.out.return`).  
Each module will be responsible to extend the mixin to fill the selection for its models.  
The models that create other records will be copy all the resources that are selected to the new records. A mixin is created to contain those common operations.

## Implementation

- [Copy resources to created documents (#9154) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9154)

---

<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: [March 12, 2020, 3:56pm UTC](https://discuss.tryton.org/t/copy-resources-to-created-documents/2444/2 "2020-03-12T15:56:16Z")

</div>

We may argument that this mechanism is limit to one level of creation. For example, it will not be possible to copy resources from sale → shipment → moves.  
I do not think it is really needed and if such case appear, it is still possible to customize the copy of the resource of the 1st level to select automatically the second level.

---

<div class="post-metadata">

### Author: ![timitos](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/timitos/32/323_2.png) [@timitos](https://discuss.tryton.org/u/timitos)
#### Post date: [March 13, 2020, 8:36am UTC](https://discuss.tryton.org/t/copy-resources-to-created-documents/2444/3 "2020-03-13T08:36:58Z")

</div>

Wouldn’t it be better to allow to relate an attachment to more than one record? If I understand your proposal correctly it will create unnecessary duplication of binary data if the binary data is stored in the database.

---

<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: [March 13, 2020, 9:11am UTC](https://discuss.tryton.org/t/copy-resources-to-created-documents/2444/4 "2020-03-13T09:11:38Z")

</div>

I do not think because:

- It will add an indirection to find attachments/notes. So the client queries will be more expensive (and they are executed a lot)
- Users may have difficulties to understand that such records are shared because nothing will indicate it.
- The _read_ state of note will be propagated to other documents which is probably not desired.
- Edition should only affect the current record version.

> [@timitos](#):
>
> it will create unnecessary duplication of binary data if the binary data is stored in the database

In this case but this is not the default configuration and it is already the case if you attach twice the same date. By the way, I filled [Do not copy Binary with file\_id filled (#9153) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue9153)

---

<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: [August 8, 2020, 10:22am UTC](https://discuss.tryton.org/t/copy-resources-to-created-documents/2444/5 "2020-08-08T10:22:43Z")

</div>


