Community mailing list archives

community@mail.odoo.com

V8 - Fields defaults not getting loaded in Create method

by
Alien Group Lda, Aires Silvestre
- 01/29/2016 07:20:14
Hello Community, I need help, please

In Odoo V8 if you create a Puchase Order using the Odoo interface you'll realize that there are some required (not null) fields that get their default values computed automatically (location_id, date_order, picking_type_id, etc) and the only field you have to enter is the vendor.

But if I try to create a Purchase Order using the ORM (by Create method) and passing only the partner_id as data all those field are not computed and therefore I get Integrity Error (
[object with reference: location_id - location.id] ).

My code (using new API):
self.env['purchase.order'].create({'partner_id': XXX})

I now I can overcome this by passing all required fields but if they have defaults computed in the model, should not the create in ORM behave the same way?
How can I use the create and have the same required fields computed and loaded for me?

Thanks in advance and kind regards 
--
<img src="cid:part1.00060100.01010305@alien-group.com" alt="ALIEN GROUP LDA">

Aires Silvestre

COO

em.aires.silvestre@alien-group.com

tm.+244 925 999 331

<img src="cid:part9.06020200.06030003@alien-group.com" alt="Código QR">

Rua Doutor Agostinho Neto, 156, Bairro Azul, Luanda - Angola, Tel: +244 913 728 600 | +244 913 728 650,
Website: www.alien-group.com, Email: geral@alien-group.com

<img src="cid:part12.08040704.01080807@alien-group.com" style="vertical-align:top;" alt=""> Não imprima este email caso não seja estritamente necessário. A Terra agradece-lhe!