Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
12462 Widoki

Hi, i confused when i try to replace data in demo data. I wanna change the data in odoo/addons/product/product_data.xml for demo data Precision like this :


<record forcecreate="True" id="decimal_price" model="decimal.precision">

<field name="name">Product Price</field>

<field name="digits">2</field>

</record>

<record forcecreate="True" id="decimal_discount" model="decimal.precision">

<field name="name">Discount</field>

<field name="digits">2</field>

</record>

<record forcecreate="True" id="decimal_account" model="decimal.precision">

<field name="name">Account</field>

<field name="digits">2</field>

</record>

<record forcecreate="True" id="decimal_stock_weight" model="decimal.precision">

<field name="name">Stock Weight</field>

<field name="digits">2</field>

</record>

<record forcecreate="True" id="decimal_product_uom" model="decimal.precision">

<field name="name">Product Unit of Measure</field>

<field name="digits" eval="3"/>

</record>

<record forcecreate="True" id="decimal_product_uos" model="decimal.precision">

<field name="name">Product UoS</field>

<field name="digits" eval="3"/>

</record>



and i want to replace with create new demo data for Precision. I can't find how to change replace demo data with inherit or any else except delete and create new.


Thanks,

Awatar
Odrzuć
Najlepsza odpowiedź

Hello,

if you want to do it using a XML file inside a module, you can try to do the following (change the model and ID based on your needs):

<function name="write" model="ir.model.data">

            <!-- First we need to find the record...-->

            <function name="search" model="ir.model.data">

                <value

                  eval="[('module', '=', 'sale'), ('name', '=', 'email_template_edi_sale')]"

                  />

            </function>

           <!-- ...and temporarily set the noupdate field to False-->

            <value eval="{'noupdate': False}" />

        </function>

       <!-- Get our main job done, i.e. modify the email Template of a record -->

     <record id="sale.email_template_edi_sale" model="mail.template">

        <field name="email_cc">${object.company_id.email|safe}</field>

    </record>

       <!-- (Optional) Time to clean our dirty hand, set the previously noupdate False to True again -->

        <function name="write" model="ir.model.data">

            <function name="search" model="ir.model.data">

                <value

                  eval="[('module', '=', 'sale'), ('name', '=', 'email_template_edi_sale')]"

                  />

            </function>

            <value eval="{'noupdate': True}" />

        </function>

I tested this code and it is work in my case.

Hope it helps in your case also!

Awatar
Odrzuć
Najlepsza odpowiedź

First you need to know a few things.. 

  1. . product/product_data.xml has <data noupdate="1"> tag.. wich means it will be loaded only first time the module is installed.. -> any modifications made to that file will be applied on NEXT instalations, not on current database.

  2. demo data is loaded only if you check "demo data" while creating database, othervise it is not loaded at all

  3. ou should NEVER change original module data, instead do a custom odule containig all the modification you need (in csv or xml files) .


Now, for modifying your current database you could try to use csv import and customize current data, or manualy change it...

Hope it helps a bit

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
cze 25
841
2
sty 18
8548
2
kwi 15
12507
1
mar 15
9119
1
mar 15
6102