# Extra productions on multiple production outputs

We’ve a customer producing plastic pieces from mold injection (nice GIF) and I found a problem when creating multiple outputs of a BOM, but let me guide you from the real use case so I think it will be more understandable for all fellows that don’t know about the topic.

There are some molds that are capable of doing more than one piece in each injection. Like Part A / Part B are connected through a gate, but imagine we can produce much more parts in a single mold:

(img source)

In this image the A and B Part are equal (and go always together, A is the complement of B), so you can make a easy BOM with

``````bom: 1
mold used: CUSTOMPARTNET
input:
plastic material (10kg)

outputs:
part A (up face) (1u)
part B (down face) (1u)
``````

They can also produce only one of the parts, so they will block the gate that connects A with B so the runner will only go to the not blocked gate.
This become also possible with adding two more BOMs:

``````bom: 2
mold used: CUSTOMPARTNET
input:
plastic material (5kg)

outputs:
part A (up face) (1u)
``````
``````bom: 3
mold used: CUSTOMPARTNET
input:
plastic material (5kg)

outputs:
part B (down face) (1u)
``````

So If a costumer buys 10u of part A and 11u of part B, the human logic says that with a production using BOM 1 with quantity 10 will supply 20u of the 21 needed. And another production that can be:

• bom3. quantity = 1 → so we’ll produce the 21º part
• bom1. quantity = 1 → so we’ll produce the 21º part, and have a remaining part A for stock

But, the thing is what if we let the `sale_supply_production` supply the needs?
I will create 2 productions:

• bom1. quantity = 10, product = part A
• bom1. quantity = 11, product = part B

So if we follow the system we will be consuming nearly the double materials we need and producing the double we need. This is the problem I face.

FTR, I know I can change `lead_time` to set the “individual” BOM first, but it’s not the best option, as requires more extra time to fill the mold gates manually and the production will be twice as slow (as we will produce 1u/time instead of 2).

Have anyone faced the same or similar scenarios in other industries?

It’s not clear to me. Are you actually connected to production equipment that Tryton is managing in an automated fashion?

In the food and beverage industry, there needs to be many customizations with various outputs and a way to calculate waste and ingredients used. We have not explored the Tryton software yet. And have not set up a test environment yet either, but our business process dictates that we would have our own custom front end and business processes in the kitchen that manage that information so that the outputs are correct and meet the customer’s expectations and then obviously production is a combination of those things but not automated. Although in the future it would make sense that once an order is placed with all its various customizations then equipment could output specifically according to that, for example, small medium or large pizza sauce that pizza sauce can be light standard or heavy.

That’s a very specific one and I think the only way to solve this is to have a ‘man in the middle’ who merges the two productions into one. Also, what about a customer who wants 10 units of A and another customer wants 5 units of part B and another wants also 5 units of part B? So you are trying to optimize the production and use the injection molding machine as efficient as possible.

There will be a fair bit of logic involved when you want to automate it. Sometimes brainpower is far superior over computational power.

There is a kind of similar situation in PCB manufacturing. The manufacturers have general PCB boards with certain dimensions and they can handle a certain amount of them in one day. Customers can each day send in their PCB layouts which are then laid out on the boards. Each board contains different PCB layouts of different sizes and complexity. When the boards are full or the day is over, they go into production which contains several steps. This kind of production is ideal for PCB prototyping.

Tryton is that capable , all jokes aside, Tryton can create production orders for you when a sale order is confirmed. This is called `supply_on_sale`.

Completely different situation I’m currently looking at is cutting material. A customer buys box sections of 50 x 50 x 3 mm with different lengths: 4 units of 400 mm, 2 units of 1000 mm, 8 units of 100 cm etc. The ‘uncut’ box sections have a length of 6 meters and you want to cut as efficient as possible with minimal waste. There are some algorithms for to do the calculations and we end up with a list of needed material (input) and a list of cut material (output) and waste (sawdust and rest material).

Interesting times ahead …

1 Like

I guess this is easy doable by overriding the `generate_request` method of stock_supply_production and group the resulting productions when it is possible.

But it can be never achieved by using Supply on sale because it sale will generate a new production that can not be grouped.

We have a customer using that exact case but the optimization is done by external software. Once the optimization isdone, we have a production with a single input (main material to cut) and then all the cutted products are created as outputs products.

I am guessing this is the recommended workflow. As long as each order is separate then it should be traceable for reporting.

But then there should also be extra input which mold to be used, how many cavities etc for each mold, some do 10 units, others 2 or 3. To make things even more complex, there are companies who do molding in a multi step process but in the same mold. This to do multi color or inject a soft grip. See https://www.youtube.com/watch?v=AxX5ZPRNaKk. Designing molded products has been one of my tasks as mechanical engineer.

So it will be a big task to match the production with the sales.

The idea was to get a cut list from the customer, feed that into the optimizer together with the stock length. The optimizer then returns the stock needed and a cut list for each stock item. This means that we get how many stock items should be picked and what has to be cut and how many. This makes it a bit more complex then yours because of the added dimension. The optimizer is an external library trying to solve the ‘cutting-stock-problem’ Cutting stock problem - Wikipedia. The data from the optimizer is then used to build a cut list for the saw.

You do not want to match with sales. Sale order create the stock demand and the production modules fills the demand. There is no need to match direcly production with sale but just the customer shipment.

1 Like

Aaah, understood. I made it way more complicated then needed.

Thanks all for your suggestions, I’ve gone with @pokoli solution which seams to me the most easy and generic one.

I leave you here the modification, so you can review, I think it’s an optimization without too much complexity of the current `generate_request` that can be contributed to core modules, but I’m sure it can be improved, so any comment is welcome.

``````@classmethod
def generate_requests(cls, clean=True, warehouses=None):
requests = super().generate_requests(clean=clean, warehouses=warehouses)

# Do not waste extra materials when productions have multiple outputs
# https://discuss.tryton.org/t/extra-productions-on-multiple-production-outputs/6675
requests_by_product = defaultdict(list)
for request in requests:
key = ','.join([str(o.product.id) for o in request.outputs])
requests_by_product[key].append(request)

max_requests = []
for products, requests in requests_by_product.items():
max_requests.append(max(requests, key= lambda r: r.quantity))

if len(max_requests) < len(requests):
cls.delete(list(set(requests) - set(max_requests)))
max_requests.extend(
super().generate_requests(clean=False, warehouses=warehouses))
return max_requests
``````

When this is applied to my examples, if bom1 is the first on both products, the result is the following productions:

• bom1 production.quantity = 10, production.product = part A
• bom1 production.quantity = 1, production.product = part B

Which will only produce all the saled parts + 1unit of extra part A.