Hi,
I’m having trouble trying to find the best way to work on productions, the problem is, with some productions, I need to know which exact inputs are on each output, so, for example, if I have Product A and Product B, and I want to produce Product C from them (more than 1 unit), I need to know which lot of Product A and B has been used on each output, so in those cases I split productions into productions of 1 unit, but the problem comes when there is several productions, and some works that last a few minuts, which are all done at the same time, meaning the user has to be opening & closing works constantly in the production of each output.
Is there a simpler way to manage this situations without adding much complication to the user workflow?
If you need a direct relation between inputs and outputs and you want to have a single work for each production the easiest is to create a relation between inputs and outputs lots using an intermediate table and force the user to enter the inputs lots for each output lot in a single production.
Probably you will need to override the traceability model in order to use your relation for custom lots when available.
With the previous feature you can just have a single work for all of the lots which will be used to correctly compute the costs.
For me the link must not be between lots but between the input and output move of the production.
This link can than be used in LotTrace._get_upward_traces and LotTrace._get_downward_traces methods to filter the inputs/outputs to only the move with the proper link.
So, if I understood correctly, following your proposal, the way to proceed is to create an intermediate table to relate production inputs and outputs, then stock moves could have 2 new Many2Many fields: “input_of” and “output_of”, and use them to filter traces doing something like:
def _get_upward_traces(self):
pool = Pool()
move = pool.get('stock.move')
traces = super()._get_upward_traces()
move, = Move.browse([self.id])
traces = {t for t in traces if t in move.input_of}
return traces
(I didn’t test it, just how I imagine it would be)
Does everything look good?
I don’t mind proposing this as a standard module if it looks good for you, I will have to develop it either way.
That’s the idea. But I think there should be some constraint to ensure to link only input/output moves from the same production.
Also the traces must still work if those internal links are not done by the user and fallback to the full original trace.