Odoo 10, Importing res partner with tags with an XML when installing a module - import

I need to import customers data with tags into res.partner with an XML when installing a custom module.
"Customers" data is stored in res.partner and "Tags" data is stored in res.partner.category, they have a relationship Many2many through res_partner_res_partner_category_rel.
I'm calling two XML files in the __manifest__.py:
The first one populates successfully res.partner.category:
<?xml version="1.0"?>
<odoo>
<record model="res.partner.category" id="res_partner_category_1">
<field name="name">Heavy metal</field>
<field name="active">1</field>
</record>
</odoo>
The second one inserts the partner data:
<?xml version="1.0"?>
<odoo>
<record model="res.partner" id="res_partner_predata_1">
<field name="name">Iron Maiden</field>
</record>
</odoo>
All I need is to insert this res.partner registry with the "Heavy metal" Tag with the installation of a custom module like this:
This is how it would look:
I will deeply appreciate any help.

I found the answer in the Odoo demo data:
When I created the category Heavy metal I assigned the id res_partner_predata_1, then I only have to add the next line (the one after the comment) to the res_partner registry like this:
<?xml version="1.0"?>
<odoo>
<record model="res.partner" id="res_partner_predata_1">
<field name="name">Iron Maiden</field>
<--! This line will add the category-->
<field eval="[(6, 0, [ref('module_name.res_partner_category_1')])]" name="category_id"/>
</record>
</odoo>

I faced the same question with odoo 14. In my case your solution did not work completely. Instead of:
<field eval="[(6, 0, [ref('module_name.res_partner_category_1')])]" name="category_id"/>
I had to set:
<field name="category_id" eval="[(6,0,[ref('res_partner_category_1')])]"/>

Related

Solr Mongo/DocDB Delta Import Query is not working

I am trying to import data from Document DB to solr-5.4.1.
Full import is executing properly but delta import is not working. When I execute delta import nothing happens
Here is the current delta configuration
deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: Date('${dih.last_index_time}')}}"
deltaImportQuery="{'_id':'${dih.delta._id}'}">
whole db-data-config.xml
<dataConfig>
<propertyWriter dateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX" type="SimplePropertiesWriter" filename="dataimport.properties"/>
<document name="tvTitleSearch">
<entity name="tvTitleSearch"
processor="MongoEntityProcessor"
query=""
collection="tvTitleSearch"
datasource="MyMongo"
transformer="MongoMapperTransformer"
deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: Date('${dih.last_index_time}')}}"
deltaImportQuery="{'_id':'${dih.delta._id}'}">
<field name="id" column="_id" indexed="true" type="uuid" stored="true" mongoField="_id"/>
<field column="lastUpdatedDate" sourceColName="lastUpdatedDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX" locale="en"/>
</entity>
</document>
</dataConfig>
sample from managed-schema file
<field type="date" name="modifiedDate" indexed="true" stored="true"/>
<field type="date" name="lastUpdatedDate" indexed="true" stored="true"/>
the value stored in DocumentDB:
lastUpdatedDate:2019-11-24T11:43:46.045+00:00
I tried to follow the date-time format as stored in DocumentDB, but still, it did not work, also, I tried suggestions from other similar question asked here but no luck. I tried below snippet in delta query
{lastUpdatedDate : {$gt: ISODate('${dih.last_index_time}')}} , but I got JSON Prasing Excpetion
but got below Exception
java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: com.mongodb.util.JSONParseException:
{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: ISODate('2019-11-20T13:14:30.576-08:00')}}
I tried following configuration too
deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt:
{$date:'${dih.last_index_time}'}}}"
could someone please help me or provide any suggestions to trigger delta query
The correct way to use the deltaQuery is
deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: {$date:'2020-03-13T08:44:06.959Z'}}}"
as you can see here
However, the SOLR will use ${dih.last_index_time} that is by default formated as 2020-03-13 08:44:06. You'll need to change the format by adding something like the following setting inside your <dateConfig> element.
<propertyWriter dateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX" type="SimplePropertiesWriter" filename="my_dih.properties" locale="en-US" />

Wrong values in Interim Accounts when returning stock

I am using anglo saxon accounting ​method in my accounting and I use average pricing as my costing method in inventory. But I am struggling with the vendor stock returning process because after validating the return, stock interim account values are not as I expected. I want to return the stock to the vendor to the price of what bought but it returned to the current price.
https://www.odoo.com/documentation/user/12.0/accounting/others/inventory/avg_price_valuation.html
As the above link says, Odoo can cater stock returns to their purchase price (see section: “Further thoughts on anglo saxon mode”). But I run the same test case on my server (Odoo 12) as well as the Odoo demo server, but it returns to the current price.
Is there any specific configuration for enabling this process or am I doing something wrong?
all you need to do is inherit view_company_form view and add anglo_saxon_accounting field
<record id="view_company_form_inherit" model="ir.ui.view">
<field name="name">res.company.form.inherit</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='rml_header1']" position="after">
<separator string=""/>
<group >
<field name="anglo_saxon_accounting" />
</group>
</xpath>
</field>
</record>

odoo 8: Import ir.translation with External ID

I have successfully imported several product templates into Odoo (version 8) and used External IDs for this. Now I want to import product description translations into ir.translation and want to use these External IDs. I guess, I have to put in field "Record ID" a reference to the product template - but this field unfortunately doesn't support External IDs in import screen.
How can I import translations for product templates with external IDs in an elegant way?
If I understood you well (you want to translate the field description of a product.template record which was introduced by XML code in a module you did before), you can try this and tell me if it works:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="whatever_you_want" model="ir.translation">
<field name="name">product.template,description</field>
<field name="type">model</field>
<field name="res_id" ref="the_module_which_introduced_xml_records.the_xml_id_of_the_record_you_want_to_translate"/>
<field name="lang">de_DE</field> <!-- The code of the language you want to translate to -->
<field name="src">Your product template description</field>
<field name="value">Your translation (in this case to German)</field>
</record>
</data>
</openerp>

Set test parameter in test instance using HP QC REST API

Is there any way to create test instance with parameter using the REST API on QC 11 ?
I have a test in my test plan with some parameters, or just one for the exercise :
I want to create using the rest API :
A test set in my test lab
A test instance in this test set
A test run of my test (the one in the plan) in this test instance
And be able to set the value of my parameters
I have manage to do the first 3 points. But I can not find how to set the parameter value for my instance. If I create the tests manually it is asked during the add of the test in the instance. And I can find the parameters in the Execution Settings in the Test Instance detail :
I have search in the documentation, but didn't find anything about how to set/use theses parameters. I have made GET on every objects, but didn't find them. I also try some urls like :
/test-instances/25378/test-parameters
/test-instances/25378/execution-settings
/test-instances/25378/exec-settings
But they always return 404.
Is there any way to set these parameters values ?
I had same troubles and here is my solution.
You can query your test parameters as:
/tests/{id}/test-parameters
And your test instance parameters, which are effectively actual values for those in your test instance, with:
/test-instances/{id}/step-parameters
For parameter values created via UI it returns like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Entities TotalResults="1">
<Entity Type="step-parameter">
<ChildrenCount>
<Value>0</Value>
</ChildrenCount>
<Fields>
<Field Name="origin-test">
<Value>-1</Value>
</Field>
<Field Name="vc-user-name">
<Value></Value>
</Field>
<Field Name="id">
<Value>21</Value>
</Field>
<Field Name="parent-id">
<Value>46</Value>
</Field>
<Field Name="used-by-owner-type">
<Value>test-instance</Value>
</Field>
<Field Name="actual-value">
<Value><html><body>
<div align="left">
<font face="Arial"><span style="font-size:8pt">AAA</span></font>
</div>
</body></html></Value>
</Field>
<Field Name="key">
<Value></Value>
</Field>
<Field Name="used-by-owner-id">
<Value>34</Value>
</Field>
</Fields>
<RelatedEntities/>
</Entity>
</Entities>
Where used-by-owner-id is id of the test-instance and parent-id is id of test parameter of the test.
Actual value for this case is AAA wrapped up with html tags.
You can create step parameters like this using normal POST to url:
/step-parameters
Note: Don't use same nested url for creation as you use for retrieval. You'll not be able to create parameters with such a combination of parameters you need.
API documentation really sucks, but you can get ideas how to retrieve or create things you need by requesting entity schema with
/customization/entities

Change the content of a record field from an XML file

In OpenERP XML fields are used to load module data.
The <record> tag is used for this.
When reinstalling the module, the records are rewritten with the current data in the XML file.
But is there a way to change just one of the record fields without rewriting all the others?
For instance, in addons/project_issue/project_issue_view.xml we have this action definition:
<record id="project_issue_categ_action" model="ir.actions.act_window">
<field name="name">Issue Categories</field>
<field name="res_model">crm.case.categ</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm.crm_case_categ_tree-view"/>
<field name="domain">[('object_id.model', '=', 'project.issue')]</field>
<field name="context" eval="{'object_id': ref('model_project_issue')}"/>
</record>
Is it possible to change just the name field in an XML file of a custom module?
I already tried :
<record id="project_issue.project_issue_categ_action" model="ir.actions.act_window">
<field name="name">Issue Categorization</field>
</record>
and
<update id="project_issue.project_issue_categ_action" model="ir.actions.act_window">
<field name="name">Issue Categorization</field>
</update>
<record id="project_issue.project_issue_categ_action" model="ir.actions.act_window">
<field name="name">Issue Categorization</field>
</record>
Your given code will change the name but won't affect menu name. You can see your given action name in form and tree view.
To change menu name, you have to override menu only not action.
For example:
<record id="project_issue.menu_project_issue_category_act" model="ir.ui.menu">
<field name="name">Issue Categorization</field>
</record>
You can even refer Apply groups on already created menus