Odoo Help

0

0
2 Risposte
2
Avatar

Yenthe Van Ginneken Belgio

--Yenthe Van Ginneken--
24015
| 9 9 12
Turnhout, Belgio
--Yenthe Van Ginneken--

My Odoo training platform: https://www.oocademy.com
My Odoo blog: http://www.odoo.yenthevg.com/
My Twitter: https://twitter.com/Yenthe666

Yenthe Van Ginneken Belgio
03/12/18, 06:29

Hi Daniele,

You can do this by creating an XML file that contains the data. When you add this XML file to the __manifest__.py file it will be loaded when installing (or updating) the Odoo module. An example of a data record:

<?xml version="1.0" ?>
<odoo>
    <record id="some_record" model="your.model">
        <field name="name">Name of the record</field>
    </record>
</odoo>

You can just load the XML file in the __manifest__ in order to have the data available when installing the app:

# always loaded
    'data': [
        'data/your_data_file.xml',
    ]

You can also find examples of this in the official Odoo code, for example in the app "projects".
Example of data: https://github.com/odoo/odoo/blob/11.0/addons/project/data/project_data.xml  
Example of loading the data: https://github.com/odoo/odoo/blob/e0b1718e4a1ab641f56fef242ae1d6c13254b53c/addons/project/__manifest__.py#L35

Regards,
Yenthe

2 Commenti
Daniele Morelli Italia
03/12/18, 08:21

Thank you very much for your kind answer!

Yenthe Van Ginneken Belgio
03/12/18, 08:27

You're welcome, best of luck!

1
Avatar

subbarao India

--subbarao--

1367
| 5 3 8
Chennai, India
--subbarao--


subbarao India
03/12/18, 07:00

Hello Daniele,

By using XML we can do it, see the following example sale order import with two lines while install the module.

<record id="sale_order_1" model="sale.order">

            <field name="partner_id" ref="base.res_partner_2"/>

            <field name="partner_invoice_id" ref="base.res_partner_2"/>

            <field name="partner_shipping_id" ref="base.res_partner_2"/>

            <field name="user_id" ref="base.user_demo"/>

            <field name="pricelist_id" ref="product.list0"/>

            <field name="team_id" ref="sales_team.team_sales_department"/>

            <field name="date_order" eval="(DateTime.today() - relativedelta(months=1)).strftime('%Y-%m-%d %H:%M')"/>

        </record>


        <record id="sale_order_line_1" model="sale.order.line">

            <field name="order_id" ref="sale_order_1"/>

            <field name="name">Laptop E5023</field>

            <field name="product_id" ref="product.product_product_25"/>

            <field name="product_uom_qty">3</field>

            <field name="product_uom" ref="product.product_uom_unit"/>

            <field name="price_unit">2950.00</field>

        </record>


        <record id="sale_order_line_2" model="sale.order.line">

            <field name="order_id" ref="sale_order_1"/>

            <field name="name">Pen drive, 16GB</field>

            <field name="product_id" ref="product.product_product_30"/>

            <field name="product_uom_qty">5</field>

            <field name="product_uom" ref="product.product_uom_unit"/>

            <field name="price_unit">145.00</field>

        </record>

1 Commento
Daniele Morelli Italia
03/12/18, 08:21

Thanks!

Fai una domanda
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now