# Materials tracking

**URL:** https://discuss.tryton.org/t/materials-tracking/5935
**Category:** Ideas
**Tags:** stock
**Created:** [February 14, 2023, 10:59pm UTC](https://discuss.tryton.org/t/materials-tracking/5935 "2023-02-14T22:59:03Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 14, 2023, 10:59pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/1 "2023-02-14T22:59:03Z")

</div>

In order to clearly separate subjects on the [Excise duties on alcohol, tobacco and energy](https://discuss.tryton.org/t/excise-duties-on-alcohol-tobacco-and-energy/4265/7) topic (EN/FR):

## ⭐ A new _Materials_ module

_Materials_ are _Products_ that have physical _Measures_ (Length, Height, Width, Surface, Volume, Weight).

A lot of materials are tracked (ethanol, gold, carbon dioxide, asbestos, etc.), and so can serve as physical components into multiple products (spirits, jewelry, greenhouse gases, fibre cement products etc.).

For legal obligations, many _Materials_ MUST be tracked in separate _Inventory accounts_ (tobacco, alcohol, energy products, cannabis, narcotics, unhealthy products, products harmful to the environment, etc.).

[Economy-wide material flow accounts (EW-MFA)](https://ec.europa.eu/eurostat/documents/3859598/9117556/KS-GQ-18-006-EN-N.pdf), as an international standard, is a legal base statistical accounting framework recording material movement (flow) of physical measures over a given accounting period as they are crossing defined ‘crossing points’ or ‘points of measurement’. EW-MFA cover solid, gaseous, and liquid materials, except for bulk flows of water and air (the general purpose of EW-MFA is to describe the physical interaction of the national economy with the natural environment and the rest of the world economy in terms of flows of materials).

So the new _Materials_ module describe here Tryton’s fundamentals needs for basic double entry materials accounting, following the EW-MFA standard&nbsp;:

1. It MUST allow any product marked as `Material` to be associated with specific stock accounting, accounting properties such as taxes, charges, expense or income accounts.
2. It MUST make it easy to manage these properties using accounting categories, like _Account Product_ and _Customs_ modules help us to do.

The goal at this point should be to convert concepts into rough interface designs: for [Getting Real](https://basecamp.com/gettingreal/06.3-from-idea-to-implementation), we start with the interface, the real screens that people are going to use. It begins with what the customer actually experiences and builds Tryton backwards from there. I hope this lets us get the interface right before we get the software wrong. 🙂

1. «&nbsp;Materials&nbsp;» SHOULD be _Goods Products_ with a `Material` checkbox checked  
 ![](https://discuss-cdn.tryton.org/uploads/default/original/2X/e/ebcc262043961a176e048f88bdd9a17c213ced44.png)  
  
2. The _Materials_ module SHOULD add the following _Materials_ tab on the _Product_ model  
 ![](https://discuss-cdn.tryton.org/uploads/default/original/2X/4/4180fd6bdaf85e7bde27af998aadced930de4caa.png)  
  

  - On peut ajouter une Matière à la liste, en précisant&nbsp;:  
 ![](https://discuss-cdn.tryton.org/uploads/default/original/2X/7/75f76ba0dce1223d86fa635bf7d3d07314c9e00a.png)  
  

    - _**Matière (editable required)**_
      - Seuls les Produits qui ont la case à cocher `Matière` activée peuvent être liés
      - Une Matière ne peut pas se contenir elle-même

    - _Quantité (de Matière dans le Produit, editable)_&nbsp;: vide = quatité nulle
    - _Mesure (de référence du Produit, editable)_&nbsp;: seule une mesure Produit de même type que l’UDM par défaut de la Matière est sélectionnable parmis:
      - Aucune (équivaut à une quantité nulle, sans avoir à supprimer cette matière)
      - Quantité (de Produit)
      - Longueur (Mesure)
      - Largeur
      - Hauteur
      - Surface (pourqoi n’est-il pas par défaut dans le module _Product Measurements_&nbsp;?)
      - Volume
      - Poids

    - _UDM_ (par défaut de la Matière)&nbsp;: modifiable, avec une Unité de même type que l’UDM par défaut de la Matière

3. Les menus ~~`Lots containing Alcohol`~~ et ~~`Locations Alcohol Volume`~~ deviennent obsolètes
  - On passera par les liens du Produit (ces derniers sont éventuellement filtrés en standard, par exemple en ne sélectionnant que les produits de type `Matière`)  
 ![](https://discuss-cdn.tryton.org/uploads/default/original/2X/7/7ec0931997604c055a20de6eaad0a3c017a9d8e8.png)  
  

4. Tout mouvement d’une quantité d’un _Produit_ contenant des _Matières_, induit le même mouvement pour chaque Matière, selon la quantité listée sur ce Produit.

To be continued…

---

<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 15, 2023, 9:32am UTC](https://discuss.tryton.org/t/materials-tracking/5935/2 "2023-02-15T09:32:32Z")

</div>

> [@jmn](#):
>
> For legal obligations, many _Materials_ MUST be tracked in separate _Inventory accounts_ (tobacco, alcohol, energy products, cannabis, narcotics, unhealthy products, products harmful to the environment, etc.).

I do not understand this statement. For me stock accounting is per “product” not divided by its composition.

---

<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 15, 2023, 10:08am UTC](https://discuss.tryton.org/t/materials-tracking/5935/3 "2023-02-15T10:08:48Z")

</div>

I think I understood. Here “accounting” is not used to refer to the modules `account` but just as tracking.  
I think we should avoid to use the term “accounting” for anything else than the modules `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: [February 15, 2023, 10:21am UTC](https://discuss.tryton.org/t/materials-tracking/5935/4 "2023-02-15T10:21:20Z")

</div>

For me the main issue with this design compared to [Draft: Manage ethanol in stock (!40) · Merge requests · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/merge_requests/40) is that it does not support (small) variations of the materials quantity per product.  
The composition of each product is fixed so in some way it does not collecte any new data as they can be computed based on the product.  
Also the material tab is mainly the same as a bill of material from the production module.

Finally from a point of view of development I do not see any benefit to make a generic solution for any material than implement a module for each kind of material. This is mainly because with a specific module per material we can easily enforce constraint because we have a concret field on the stock move. While a generic solution will impose [EAV model](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model) or `Dict` fields for which the data integrity are much more difficult to enforce.

---

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 15, 2023, 11:27am UTC](https://discuss.tryton.org/t/materials-tracking/5935/5 "2023-02-15T11:27:25Z")

</div>

> [@ced](#):
>
> For me stock accounting is per “product” not divided by its composition.

Nope. In our conception a _Material_ is a _Product_ like the others, but with the `Material` flag checked. So stock accounting “per product” is steel OK with all _(Material) Products_.

> [@ced](#):
>
> Here “accounting” is not used to refer to the modules `account` but just as tracking.  
> I think we should avoid to use the term “accounting” for anything else than the modules `account`.

No. Accounting stand here like in the [“Account Product” module](https://docs.tryton.org/projects/modules-account-product/en/6.6/) name, witch “allows products to be associated with accounting properties such as taxes and expense or revenue accounts. It allows these properties to be easily managed using accounting categories.”

> [@ced](#):
>
> The composition of each product is fixed so in some way it does not collecte any new data as they can be computed based on the product.

No. “Composition” (ie only materials you want to track) for each products depends on laws and on your own productions focus.

So composition is not fixed: composition is not the same from an organisation to another: since a long time we track ethanol, yesterday we started track THC with cannabis legalisation, tomorrow CO² for environnement deals, and all for a same product (the same pint of beer 🍺 :-).

Come on man, have a kick look to [Economy-wide material flow accounts (EW-MFA)](https://ec.europa.eu/eurostat/documents/3859598/9117556/KS-GQ-18-006-EN-N.pdf) international standard, “a legal base statistical accounting framework recording material movement (flow) of physical measures over a given accounting period as they are crossing defined ‘crossing points’ or ‘points of measurement’”…

---

<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 15, 2023, 11:53am UTC](https://discuss.tryton.org/t/materials-tracking/5935/6 "2023-02-15T11:53:45Z")

</div>

> [@jmn](#):
>
> No. Accounting stand here like in the [“Account Product” module](https://docs.tryton.org/projects/modules-account-product/en/6.6/) name, witch “allows products to be associated with accounting properties such as taxes and expense or revenue accounts. It allows these properties to be easily managed using accounting categories.”

Then I do not understand the goal of this proposal.

> [@jmn](#):
>
> Come on man, have a kick look to [Economy-wide material flow accounts (EW-MFA)](https://ec.europa.eu/eurostat/documents/3859598/9117556/KS-GQ-18-006-EN-N.pdf) international standard

I did not read the 150 pages but as I do not understand the basic concept of the proposal, I do not think I should start reading.

---

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 15, 2023, 12:30pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/7 "2023-02-15T12:30:17Z")

</div>

> [@ced](#):
>
> Then I do not understand the goal of this proposal.

So sorry, niether do I: you’re right… I overlooked functionnal capacities of the [“Account Product” module](https://docs.tryton.org/projects/modules-account-product/en/6.6/)&nbsp;! 🙂

---

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 19, 2023, 12:24pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/8 "2023-02-19T12:24:42Z")

</div>

> [@ced](#):
>
> Finally from a point of view of development I do not see any benefit to make a generic solution for any material than implement a module for each kind of material. […] While a generic solution will impose [EAV model](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model) or `Dict` fields for which the data integrity are much more difficult to enforce.

OK, I understand that point, and I trust your core dev experience. 🙂

> [@ced](#):
>
> This is mainly because with a specific module per material we can easily enforce constraint because we have a concret field on the stock move.

You pushed me outo my entrenchments…

I think, finally, this was the main reason for my proposal: can we get more “user flexibility” by giving to him the possibility to point the product to track?

I mean, with alcohol actually tracked by `stock_ethanol` and `production_ethanol` modules:

- Can we give user the possibility to set the `Ethanol Product` (as we can set `Ethanol Product Adjustment`)?  
 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/8/8f5c0132542a75b313d7541fc42951cabf901d82.png)  
(\*) `Ethanol Product`, as `Ethanol Product Adjustment`, must be a Product that `Contain Alcohol` _with_ `Alcohol By Volume = 100`
- Where is the right place to set that configuration?  
 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/8/8cb40850f0c8227dfa5cb05463f6f817697685f0.png)  

## Refactored proposal

- The module [Stock Ethanol](https://foss.heptapod.net/tryton/tryton/-/merge_requests/40) should add **_Ethanol Product_** and **_Alcohol Volume UOM_** fields on Products/Configuration:  
 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/e/ea6ee5a7150c2474b506abd8b986ba72c5554bb8.png)
  - **_Ethanol Product_** must be a Product that `Contain Alcohol` _with_ `Alcohol By Volume = 100`
    - Since a product is selected as the _Ethanol Product_, his `Alcohol By Volume` cannot be modified

  - **_Alcohol Volume UOM_** is to “support (small) variations of the materials quantity per product”.

- Les menus ~~_Inventory & Stock / Locations / Locations Alcohol Volume_~~ et ~~_Inventory & Stock / Lots / Lots containing Alcohol_~~ ne sont plus utiles: on peut passer par les liens standards du produit _Ethanol Product_ (sinon, à terme, il devra y avoir deux fois autant d’entrées de plus dans le menu que de produits à suivre)  
 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/e/e51673d0158ec0b69eb1ee915148e705b1b6a0ce.png)

---

<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 19, 2023, 12:38pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/9 "2023-02-19T12:38:13Z")

</div>

> [@jmn](#):
>
> Can we give user the possibility to set the `Ethanol Product` (as we can set `Ethanol Product Adjustment`)?

I do not understand.

> [@jmn](#):
>
> The module [Stock Ethanol](https://foss.heptapod.net/tryton/tryton/-/merge_requests/40) should add _ **Ethanol Product** _

Why? We do not need such thing.

> [@jmn](#):
>
> _ **Alcohol Volume UOM** _ fields on Products/Configuration:

Why on product configuration, it is only needed for the stock (where it is already configured)?

---

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 19, 2023, 2:59pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/10 "2023-02-19T14:59:29Z")

</div>

[FR] (My english is poor…)

> [@ced](#):
>
> > [@jmn](#):
> >
> > Can we give user the possibility to set the `Ethanol Product` (as we can set `Ethanol Product Adjustment`)?
> 
> I do not understand.

Le draft des modules Stock et Production Ethanol fait le job a minima, et c’est bien.

Mon problème c’est qu’en l’état, je me sens trop contraint (voir limité) pour les cas d’usages clients: je ne peux pas utiliser les fonctionnalités Tryton disponibles par défaut sur les produits.

Par exemple:

1. Pour l’alcool: les distillateurs (et les Douanes surtout!) ont besoin de voir l’évolution du stock d’éthanol dans le temps, comme Tryton nous le permet déjà pour n’importe quel produit via le graphique _Product Quantities By Warehouse_.  
Or là, si on veut aussi afficher l’alcool (et les autres produits à venir) sur le graphique, il faut qu’on fasse un dév spécifique ☹  
  
 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/e/e687ffecb980c8a0e549b5f1b025645787e7acc7.png)
2. Pour appliquer des droits d’accises sur l’ensemble des produits qui y sont soumis (je rappelle que 190&nbsp;000 entreprises utilisent déjà le système EMCS en Europe et, c’est aussi ça le marché de Tryton), il faudra rajouter autant d’entrées dans les menus que de produits suivis.  
Or, il y a plus d’une dizaine de produits à suivre au même titre que l’alcool (le tabac, le sucre, le café, le chocolat, les produits agricoles, les produits pétroliers…).

Par contre, si on arrive à améliorer ces modules avec un meilleur compromis performance/généricité, de façon à ce que je ne sois pas bloqué face à ces cas d’usage, je pourrai vendre Tryton (quasiment) les yeux fermés (au développement spécifique près) comme solution sur de problématiques d’accise et de comptabilité matière…

C’est ça mon problème: ça marche, mais c’est trop spécifique et j’aimerais faire en sorte que les utilisateurs soient plus autonomes en termes de paramétrages (même si pour chaque nouveau produit à suivre il y aura des dév spécifiques).

Notre proposition du module _Excise_ va dans ce sens (en complément du module _Account Product_).

---

<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 19, 2023, 3:19pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/11 "2023-02-19T15:19:18Z")

</div>

> [@jmn](#):
>
> Pour l’alcool: les distillateurs (et les Douanes surtout!) ont besoin de voir l’évolution du stock d’éthanol dans le temps, comme Tryton nous le permet déjà pour n’importe quel produit via le graphique _Product Quantities By Warehouse_.  
> Or là, si on veut aussi afficher l’alcool (et les autres produits à venir) sur le graphique, il faut qu’on fasse un dév spécifique ☹

L’information est déjà là mais dans un autre champs (il faudrait juste que `compute_quantities_query` puisse fonctionner sur un autre champs que `internal_quantity`).  
Pour moi le manque d’une vue ne justifie pas la duplication de mouvement de stock pour just pouvoir réutiliser celle-ci.  
En fait je pense que plus on poussera vers plus de fonctionnalité pour la gestion d’ethanol plus on améliorera la base qui permettra d’inclure d’autre gestion similaire plus facilement.

> [@jmn](#):
>
> Pour appliquer des droits d’accises sur l’ensemble des produits qui y sont soumis (je rappelle que 190 000 entreprises utilisent déjà le système EMCS en Europe et, c’est aussi ça le marché de Tryton), il faudra rajouter autant d’entrées dans les menus que de produits suivis.

Je ne comprend pas.  
Évidement il faudra créer les produits qui sont géré par la société et les configurer par rapport aux accises s’il le faut. Je suppose que la plus part ont une contenance fixe et donc un montant d’accise fixe par quantité. Pour les autres qui serait plus artisanal, il faudra une gestion de stock comme le module ethanol.

---

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 19, 2023, 3:41pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/12 "2023-02-19T15:41:50Z")

</div>

> [@ced](#):
>
> Pour moi le manque d’une vue ne justifie pas la duplication de mouvement de stock pour just pouvoir réutiliser celle-ci.

Ah, je comprends mieux: je n’avais pas capté qu’il n’y avait pas de véritable mouvements de stock pour l’alcool (et qu’en fait ce sont uniquement les Produits, qui eux contiennent de l’alcool, qui sont déplacés, et pas l’alcool en tant que Produit)…

---

<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 19, 2023, 3:59pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/13 "2023-02-19T15:59:37Z")

</div>

> [@jmn](#):
>
> Ah, je comprends mieux: je n’avais pas capté qu’il n’y avait pas de véritable mouvements de stock pour l’alcool (et qu’en fait ce sont uniquement les Produits, qui eux contiennent de l’alcool, qui sont déplacés, et pas l’alcool en tant que Produit)…

C’est juste mais pas complète. En fait pour chaque mouvement de produit on stock aussi la quantité alcohol déplacé. Du coup on a 2 colonnes sur le mouvement `internal_quantity` et `internal_ethanol_volume`. Et rien n’empêche de faire les même calcule sur `internal_ethanol_volume` que ceux qu’on fait avec `internal_quantity`.

---

<div class="post-metadata">

### Author: ![jmn](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/jmn/32/2904_2.png) [@jmn](https://discuss.tryton.org/u/jmn)
#### Post date: [February 19, 2023, 7:58pm UTC](https://discuss.tryton.org/t/materials-tracking/5935/14 "2023-02-19T19:58:54Z")

</div>

> [@ced](#):
>
> Et rien n’empêche de faire les même calcule sur `internal_ethanol_volume` que ceux qu’on fait avec `internal_quantity`

Donc, si je comprends bien, le graphique _Product Quantities By Warehouse_ (`compute_quantities_query`) affiche l’historique du champ `internal_quantity` des produits sélectionnés, mais pas (encore) la colonne `internal_ethanol_volume` des produits sélectionnés, c’est ça?

Donc, pour l’alcool, il faudrait dire que

- "le graphique _Product Quantities By Warehouse_ compute aussi la colonne `internal_ethanol_volume` des produits sélectionnés,
- si il y a au moins un produit Contain Alcohol dans cette liste".

Si c’est ça, alors OK.

Moi, je sais donc que quand on rajoutera l’or par exemple, ce sera la même logique (même si c’est un dév supplémentaire):

- si j’ai sélectionné un produit contenant de l’alcool et un autre contenant de l’or,
- sur le graphique _Product Quantities By Warehouse_,
- j’aurai affiché par défaut l’historique du champ `internal_quantity` des produits sélectionnés,
- mais aussi les champs `internal_ethanol_volume` et `internal_gold_weight` (qui ne sont des produits, mais seulement des quantités déplacées).

Et ça, je peux le vendre… 🙂
