Am 15.02.2017 um 15:52 schrieb Sergi Almacellas Abellana:
> El 15/02/17 a les 15:29, Ul ha escrit:
> 
> Thanks for sharing,
> 
> How do you define the stock_lot_relation table?

as a usual Table in the database:

class LotRelation(ModelSQL, ModelView):
    "Lot Relation"
    __name__ = 'stock.lot.relation'
    _rec_name = 'from_lot'
    from_lot = fields.Many2One('stock.lot', 'from Lot', required=True)
    quantity = fields.Float("Quantity", required=True,
        digits=(16, Eval('unit_digits', 2)), depends=['unit_digits'])
    uom = fields.Many2One("product.uom", "Uom", required=True)
    to_lot = fields.Many2One('stock.lot', 'to Lot', required=True)

> I think this is the table that we can add to the main stock_lot module
> and this table can be computed with a table query by joining the inputs
> and the outputs of a production.

If relations only originate from productons, this can be computed from
the production table. But i want to populate it from shipment in too,
because i want to create a new internal lot with every shipment and
relate it to the lot of the supplier.
This has two reasons:
- if we get several shipments from on supplier that have the same
lot-number because the supplier produced it at once, i want to be able
to track down our lot witch shipment it came with.
- some suppliers have incredibly long lot-numbers and it's annoying to
type them every time you use it.
> 
>>
>> so as Lot3 is used twice the lines with relation.id 11 and 12 show up
>> twice.
>>
> 
> The problem is that the same id is returned for multiple records. The id
> field of every model must be unique (as it's used to identify the
> records). Indeed, you developing a table_query you are supposed to take
> care about it. My advice is to compute the record id by using the ids of
> the composed lots.
The problem is, that it is literally the same rows in the joined table
that are returned twice by the query. using the lot id won't help
anything, Lot3 is used 2 times and all lines within it are exactly the
same.
The only way would be to have some kind of counter or sequence in the
with-clause. But i didn't find a function that could do that. Any other
way like adding the depth of recursion and the relation id could also
give duplicates.
And i don't see any value such an id would add except fulfilling the
rule that the ids of every returned line have to be unique. There is no
information added by giving different ids, its even information lost:
the information that it is the very same line in the originating table.

-- 
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/b56c7881-6e7e-4d51-c91b-2aa040a1a81c%40gmx.de.

Reply via email to