I have a custom odoo module, which extends some existing modules like hr. I want to create an onboarding plan with several predefined tasks in it.
This is my plan acitivity type xml which works at it should. If I update the applikation with this file, I get the desired tasks in the planning types overview.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_plan_activity_type_create_work_contract" model="hr.plan.activity.type">
<field name="activity_type_id" ref="mail.mail_activity_data_todo"/>
<field name="responsible">manager</field>
<field name="summary">Create work contract</field>
<field name="note">Create the work contract for the employee.</field>
</record>
<record id="hr_plan_activity_type_employee_model_in_erp" model="hr.plan.activity.type">
<field name="activity_type_id" ref="mail.mail_activity_data_todo"/>
<field name="responsible">manager</field>
<field name="summary">Employee model in ERP</field>
<field name="note">Complete the employee model in ERP (AHV, Banking, etc.)</field>
</record>
</odoo>
This is my plan.xml which should create a plan with the activity types. The creation of the plan works, but if I reference the activity types, I'll get an error message.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Onboarding -->
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids"
eval="[(6,0,[ref('mycompany.hr_plan_activity_type_employee_model_in_erp')])]"/>
<field name="plan_activity_type_ids"
eval="[(4,0,[ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
</record>
</odoo>
In the manifest.py file I first load the plan.activity.type.xml and then the plan.xml so this shouldn't be a problem.
This is the error message I get when I try to upgrade my customized module mycompany:
File "C:\Program Files (x86)\Odoo 13.0e\server\odoo\addons\base\models\ir_model.py", line 1670, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
odoo.tools.convert.ParseError: "External ID not found in the system: hr.plan.activity.type.hr_plan_activity_type_create_work_contract" while parsing file:/c:/users/myuser/appdata/local/openerp%20s.a/odoo/addons/13.0/mycompany/data/hr/plan.xml:2, near
<odoo>
<!-- Onboarding -->
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" ref="hr.plan.activity.type.hr_plan_activity_type_create_work_contract"/>
</record>
Does anyone have any ideas?
String identifier stored in ir.model.data, can be used to refer to a record regardless of its database identifier during data imports or export/import roundtrips.
External identifiers are in the form module.id (e.g. account.invoice_graph). From within a module, the module. prefix can be left out.
Sometimes referred to as xml id or xml_id as XML-based Data Files make extensive use of them.
In your example you used model_name.id which probably does not exist in the database, to reference hr_plan_activity_type_create_work_contract record you just need to replace the model name with the module name.
I can see from the log message that the module name is mycompany, try to replace the model name with mycompany:
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" ref="mycompany.hr_plan_activity_type_create_work_contract"/>
</record>
Update:plan_activity_type_ids is an x2many field
Use the special commands format to set the x2many field values:
<record id="hr_plan_onboarding" model="hr.plan">
<field name="name">Onboarding</field>
<field name="plan_activity_type_ids" eval="[(6,0,[ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
</record>
Edit: Only the first one shows up in the GUI
To replaces all existing records in the set by the ids list (using '(6, 0, ids)') you can provide a list of ids inside the triplet. You can find an example in res_partner_demo.xml inside the base module.
Example:
<field name="plan_activity_type_ids" eval="[(6,0,[ref('mycompany.hr_plan_activity_type_employee_model_in_erp'), ref('mycompany.hr_plan_activity_type_create_work_contract')])]"/>
To add an existing record of id id to the set (using (4, id)) you need to provide one id for each triplet. You can find an example in base_groups.xml inside the base module.
Example:
<field name="plan_activity_type_ids" eval="[(4,ref('mycompany.hr_plan_activity_type_employee_model_in_erp')), (4,ref('mycompany.hr_plan_activity_type_create_work_contract'))]"/>
Your ref ids are wrong. hr.plan.activity.type.hr_plan_activity_type_create_work_contract is wrong. You get only one . in a reference. its [<module_name>.]ext_id_of_object.
If you reference the object from the same module you don't have to use module name.part
If you can see the database tables. then things you are referencing are in table ir_model_data
So if the thing you are referencing is in your own model then you cant use just hr_plan_activity_type_create_work_contract as a reference or your_model_name.hr_plan_activity_type_create_work_contract
I'm trying to set the default value for the type field on the product.product model to product. I thought this would be simple using a data file. This is the content of my file:
<odoo>
<function model="ir.values" name="set_default"
eval="('product.product', 'type', 'product')"/>
</odoo>
The module imports without errors, but the default value is not created. It's nowhere to be found. Am I doing something wrong here?
I tried it this way as well, but same result:
<odoo>
<function model="ir.values" name="set_default">
<value>product.product</value>
<value>type</value>
<value>product</value>
</function>
</odoo>
your syntax needs little correction
Try this and it will work :)
<function model="ir.values" name="set_default">
<value eval="str('product.product')"/>
<value eval="str('type')"/>
<value eval="str('product')"/>
</function>
Because each value should be passed individual as per signature sequence.
I am new to XLST, posting my question after searching for help in this portal.
I have a typical scenario where I need to transform XML into target XML as blocks per status at record node level below.
But the Header <eventName> and <eventdate> should present only once in first block of section in my target file.
Iām using nested for loop on Header in that another loop on record to scan each status code. Once I find status code is !=ā00ā then calling a template.
How do I check or set a condition with in template to execute only once for subsequent calls on template?
Tried with a param that var defined in top loop with value assigned position() but it did not work as record level it would remain same.
Please advise a solution.
An example input XML looks like below:
<?xml version="1.0" encoding="utf-8"?>
<n0:example>
<eventName>Managers Event</eventName>
<eventdate>09292016</eventdate>
<header>
<status>01</status>
<SubHead>
<Record>
<status>10</status>
<Service>Food</Service>
</Record>
<Record>
<status>00</status>
<Service>Music</Service>
</Record>
</SubHead>
</header>
<header>
<status>02</status>
<SubHead>
<Record>
<status>11</status>
<Service>Food</Service>
</Record>
<Record>
<status>00</status>
<Service>Music</Service>
</Record>
</SubHead>
</header>
</n0:example>
I'm trying to modify xml attribute in my table:
XML:
<root>
<object name="111">
<fields>
<field name="1">False</ofield>
<field name="VIN">123</field>
</fields>
</object>
</root>
UPDATE wftable
SET XML.modify('replace value of
(root/object[#name="111"]/fields/field/#name[.="VIN"])[1]
with "testNumber"')
WHERE id = 20889436
But I get as a result
<field name="testNumber">123</field>
Actually I just want to update xml node like this:
<field name="VIN">testNumber</field>
How can I modify my UPDATE query?
You need to specify the text() node of field as the node you want to update.
replace value of
(root/object[#name="111"]/fields/field[#name="VIN"]/text())[1]
with "testNumber"
I have a JDBC outbound endpoint that after performing Map To XML transformation, gives out XML in the following format:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<record>
<field name="DESTINATION" type="java.lang.String">SFO</field>
<field name="PRICE" type="java.lang.String">500</field>
<field name="ID" type="java.lang.Integer">2</field>
</record>
</table>
The problem is that when I try to generate the schema for this XML for use in the datamapper , the fields that are generated from this are not usable (it only shows field , In the mapping file I get this message when I try to hover over it :
'The attribute cannot be dragged since it does not belong to 'Current Element Mapping'
How do I use my XML so that I can map those fields to either another CSV, database or some other entity?
Why not trying to map (via DataMapper) Map object directly to CSV or anything you'd like ? If you need this intermediary XML format, you can also use DataMapper for the initial Map->XML mapping and configure the way you want it to look like (instead using MapsToXML).