Help about fields displayed by a function field

73 views
Skip to first unread message

Maxime Richez

unread,
Feb 9, 2016, 6:05:07 AM2/9/16
to tryton

Hi everybody,

I'm working with Thierry Bruyere @ SALUC (Chemical industry located in Belgium)
We planned to migrate our internal erp tools to Tryton so i'm learning Tryton and his code.

Can someone give explanations about the display of a function field in the "stock.shipment.in" module. I'm wondering where are defined the displayed fields for the function field "incoming_moves" (in this case : product, quantity, uom,planned date, effective date, state

I'm analyzing the code, unsuccessfully ...

in the file shipment_in_form.xml

<notebook colspan="6">
       
<page string="Incoming Moves" id="incoming_moves">
           
<field name="incoming_moves" colspan="4"/>
       
</page>
       
<page string="Inventory Moves" id="inventory_moves">
           
<field name="inventory_moves" colspan="4"/>
       
</page>
   
</notebook>

in shipment.py

Class ShipmentIn

incoming_moves = fields.Function(fields.One2Many('stock.move', 'shipment',
           
'Incoming Moves',
            add_remove
=[
               
('shipment', '=', None),
               
('from_location', '=', Eval('supplier_location')),
               
('state', '=', 'draft'),
               
('to_location', '=', Eval('warehouse_input')),
               
],
            domain
=[
               
('from_location', '=', Eval('supplier_location')),
               
('to_location', '=', Eval('warehouse_input')),
               
('company', '=', Eval('company')),
               
],
            states
={
               
'readonly': (Eval('state').in_(['received', 'done', 'cancel'])
                   
| ~Eval('warehouse') | ~Eval('supplier')),
               
},
            depends
=['state', 'warehouse', 'supplier_location',
               
'warehouse_input', 'company']),
       
'get_incoming_moves', setter='set_incoming_moves')            


    def get_inventory_moves(self, name):
        moves
= []
       
for move in self.moves:
           
if (move.from_location.id ==
                   
self.warehouse.input_location.id):
                moves
.append(move.id)
       
return moves


Thank you !

Cédric Krier

unread,
Feb 9, 2016, 11:15:05 AM2/9/16
to tryton
On 2016-02-09 02:47, Maxime Richez wrote:
> Can someone give explanations about the display of a function field in the
> "stock.shipment.in" module. I'm wondering where are defined the displayed
> fields for the function field "incoming_moves" (in this case : product,
> quantity, uom,planned date, effective date, state

The client doesn't know about Function field but only about the type
which is in this case One2Many.
So when a One2Many is defined on a view but without any view_ids
attribute, it is the default view (lower sequence) of the target Model
that is used (in this case of stock.move).


--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Maxime Richez

unread,
Feb 10, 2016, 3:50:04 AM2/10/16
to tryton

The client doesn't know about Function field but only about the type
which is in this case One2Many.
So when a One2Many is defined on a view but without any view_ids
attribute, it is the default view (lower sequence) of the target Model
that is used (in this case of stock.move).


Thanks for your answer. So, in this case, default view  is move_tree.xml

<tree string="Moves">
   
<field name="product"/>
   
<field name="from_location"/>
   
<field name="to_location"/>
   
<field name="quantity"/>
   
<field name="uom"/>
   
<field name="planned_date"/>
   
<field name="effective_date"/>
   
<field name="state"/>
   
<field name="unit_digits" tree_invisible="1"/>
</tree>

But there is more fields in the model than displayed in the view of the function field.
In shipment_in : (from_location and to_location are invisible for the function field "incoming_moves" and "from_location" is invisible for function_field "inventory_moves"  and both are using stock.move...

"from_location" and "to_location" in the class Move have the same domain
So i'm still wondering how fields are hidden in the view ?


Cédric Krier

unread,
Feb 10, 2016, 4:45:04 AM2/10/16
to tryton
This is because the One2Many's have a domain written in such way that it
allows only one value for those fields. So the client automatically hide
such fields because they don't give any information (the information is
in the document header).

Maxime Richez

unread,
Feb 10, 2016, 10:52:02 AM2/10/16
to tryton

This is because the One2Many's have a domain written in such way that it
allows only one value for those fields. So the client automatically hide
such fields because they don't give any information (the information is
in the document header).

 
    Thanks ! Not easy to understand at first time all the complexity of the mechanisms :-)

Cédric Krier

unread,
Feb 10, 2016, 11:10:04 AM2/10/16
to tryton
Yes, they are all simple mechanisms but all put together create a
complex system.
Reply all
Reply to author
Forward
0 new messages