I am trying to edit the default_code field on the product.product model. I am attempting to make it so the field is no longer copied when duplicating a record. This is the XML record in my module:
<record id="product.field_product_product_default_code" model="ir.model.fields">
<field name="copy" eval="False"/>
</record>
When I import the module, I get an import error. If I comment out this record, the rest of my module imports without an issue, so I believe this is causing the problem. Is it not possible to alter a base field in this manner?
Related
I'm installing my custom module that I copy from Odoo 14 to Odoo 12 and I'm getting this error:
No matching record found for external id 'hr_daily_task.group_daily_task_employee' in field 'Group'
Missing required value for the field 'Object' (model_id)
No matching record found for external id 'model_daily_task' in field 'Object'
This is my model:
class DailyTask(models.Model):
_name = "daily.task"
_description: "Daily Task"`enter code here`
This is my csv:
access_daily_task_employee,access.daily.task.employee,model_daily_task,hr_daily_task.group_daily_task_employee,1,1,1,0
My Security:
<record model="ir.module.category" id="module_category_hr_daily_task">
<field name="name">HR Daily Employee Task</field>
<field name="description" >Daily Records of employee tasks</field>
<field name="sequence">45</field>
</record>
<record id="group_daily_task_employee" model="res.groups">
<field name="name">Employee
<field name="category_id" ref="module_category_hr_daily_task"/>
</record>
I've already tried several solution with the following:
Add module_name.model_name (hr_daily_task.model_daily_task) in both csv file and security
Reboot server
Update Apps List in Odoo
Import in init.py file for both models folder and main init.py file
I've tried all of them but still not working for me.
But if I install it in Odoo 14, it's working. Also, I've tried to install Planning CE by Vertel AB (Odoo 14) in Odoo 12, I've also got the same error but it also works in Odoo 14.
Please help me to solve this, I can't really find any solution for this. You may try to install Planning CE by Vertel Ab in Odoo 12 so that you can try and fix the problem and please share the solution if you find one.
Thanks in advance.
No matching record found for external id 'hr_daily_task.group_daily_task_employee' in field 'Group'
This can be one of the following:
This is not the right external ID
The CSV file is imported before the security file (The file where you defined the groups)
The security file is not imported
No matching record found for external id 'model_daily_task' in field 'Object'
Check module imports, probably you forgot to import the file where you defined the daily.task model
For example i have app with
category = "custom_category"
How can i add this category to my search panel in app module ?
When I created a category, I thought it would come here automatically, but it didn't.
I found the file, where these categories are defined:
15.0/odoo/odoo/addons/base/data/ir_module_category_data.xml
But something is not right here! When I delete a record from here, for example:
<!-- <record model="ir.module.category" id="module_category_human_resources">-->
<!-- <field name="name">Human Resources</field>-->
<!-- <field name="sequence">45</field>-->
<!-- </record>-->
And update the base module, this (Human Resources) field is still in this menu !?
Why it is not deleted? Any advice?
Model 'ir.module.category' doesn't have delete access rights (ref https://github.com/odoo/odoo/blob/a7f7233e0eae8ee101d745a9813cba930fd03dcb/odoo/addons/base/security/ir.model.access.csv#L20). So once a record is created from the xml file, it will not delete if you comment that code line.
You can directly delete it from the database using delete query.
Odoo will only show categories that do not have a parent and that one of the subcategories is linked to a module.
If the category_id field is defined in the search panel, Odoo will use a custom domain:
domain = [('parent_id', '=', False), ('child_ids.module_ids', '!=', False)]
To show the custom category in the search panel:
First, define the module category as follows:
<record model="ir.module.category" id="module_custom_category">
<field name="name">custom_category</field>
<field name="sequence">99</field>
</record>
<record model="ir.module.category" id="module_child_category">
<field name="name">child_category</field>
<field name="parent_id" ref="module_custom_category"/>
</record>
Then set it in a module __manifest__.py file:
'category': 'custom_category/child_category',
Why Odoo did not remove the category after commenting the XML definition?
Odoo will create two categories with the same name (custom_category) with the following XML IDS:
base.module_category_custom_category
stack15.module_custom_category
And use the first one to show it in the search panel.
When you comment record XML definition and upgrade the module, Odoo will remove the category using the module name as a prefix in its XML id (stack15.module_custom_category) and keep the base category (base.module_category_custom_category), so the custom category will be visible even if you uninstall the module.
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 am trying to build an odoo module named kroshu for stock managment
i have wrote the needed models and the views
after i try to install my module odoo server shows this message
File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir \ir_actions.py", line 128, in _check_model
raise ValidationError(_('Invalid model name %r in action definition.') % action.res_model)
odoo.tools.convert.ParseError: "Invalid model name 'kroshu.product' in action definition.
None" while parsing file:/c:/program%20files%20(x86)/odoo%2011.0/server/odoo/addons/kroshu_khalil_kasmi/data/actions.xml:5, near
<record model="ir.actions.act_window" id="action_kroshu_product">
<field name="name">Product</field>
<field name="res_model">kroshu.product</field>
<field name="view_mode">tree,form</field>
</record>
my module is named Product.py :
from odoo import models,fields
class Product(models.Model):
_name = 'kroshu.product'
product_id = fields.Char("product id",required =True)
product_name = fields.Char("product name",required = True)
product_description = fields.text("product description")
product_type = fields.One2many("product.type","product_type_id",string="type")
product_category = fields.One2many("product.category","product_category_id",string="category")
quantity_on_hand = fields.Integer("quantity on hand",required =True)
forcasted_quantity = fields.Integer("forcasted quantity")
location_in_stock = fields.Char("product location in stock")
barcode = fields.text("barcode")
vendor = fields.One2many("product.vendor","vendor_id",string="vendor/manufacturer")
cost = fields.Float("cost")
stock = fields.One2many("kroshu.stock","stock_id",string="in stock")
my action_views.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<menuitem name="Kroshu" id="kroshu_root_menu"/>
<record model="ir.actions.act_window" id="action_kroshu_product">
<field name="name">Product</field>
<field name="res_model">kroshu.product</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.actions.act_window" id="action_kroshu_product_category">
<field name="name">Product Category</field>
<field name="res_model">product.category</field>
<field name="view_mode">tree,form</field>
</record>
........ still more lines
my __ init __ .py file :
from . import category
from . import product
From what you have stated above. The issue is likely that in your __init__.py file you are importing product however the file is called Product.py. I also am not sure of the indentation within Product.py however this may just be formatting of what was copied and pasted into stack overflow.
When writing a new module, for debugging the general setup, it may help to simplify first and then add step by step, keeping things working.
In your case, first create one model with one field (like name) and get that to work. Then, add more simple fields, a view and an action. Make sure you can create records for your new model.
Then, adding relational fields, make sure to include the dependencies in the manifest file where the target models are (in your case, product for product. product etc.)
Finally, make sure your second model kroshu.stock needs to exist, too, following the same methodology.
You have an error inside your model definition:
barcode = fields.text("barcode")
instead of :
barcode = fields.Text("barcode")
change text to Text and your code 'll become nice.
Second Solution:
try to rename your model name, change
_name = 'kroshu.product'
for example like:
_name = 'kroshuproduct'
Odoo commonly uses this expression to specify that the model product is inside de module name kroshup for example.
This error mostly occur when you have and error inside your Model
definition. to detect your Error, comment all fields and test every
fields alone.
Hope this help you! Great!
I am new to Odoo, I developing a simple module that will add some fields to an existed view. First, I install it to Odoo, it works fine. Then I edit some code, likes add new more field to my module. Now when I upgrade my module with some new code, Odoo display error: KeyError "bla bla".
But if I install my new module to another machine, it works fine.
Did I miss something? How can I fix it.
And, sorry for my bad English, I'm Vietnamese.
Update my code:
my_model.py file:
from openerp.osv import fields, osv
class ij_project_form(osv.osv):
_name = 'project.project'
_inherit = "project.project"
_columns = {
'ij_project_form_id': fields.integer('An integer field', size=11),
'ij_project_form_des': fields.text('A text field')
}
_defaults ={
'ij_project_form_id': 0
}
ij_project_form()
my_view.xml file:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="ij_project_form">
<field name="name">project.project.form</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project" />
<field name="arch" type="xml">
<xpath expr="//field[#name='partner_id']" position="after">
<newline/>
<field name="ij_project_form_id" />
</xpath>
<xpath expr='//page[#string="Project Stages"]' position="after">
<group string="Injection tab" name="sample">
<field name="ij_project_form_des" />
</group>
</xpath>
</field>
</record>
</data>
</openerp>
Here you are inherit the project.project model and this model is in project module so you are first set dependencies in v7,v8 openerp.py and if you work on v9 or v10 than manifest.py
'depends':['project']
1) In odoo the '_name' attribute creates a new table in the backend (i.e., in database). So, when you want to add fields to the existing model (like here 'project.project'), no need to use _name. "_inherit" like above is sufficient.
With the above code it will try to create another table, project_project (which is a base table of odoo, which is already created in database). so, remove the _name in your code and run.
We can use _name along with _inherit, but try to give different name to '_name' attribute. So this conflict wont be raised.
You should update your __openerp__.py file and make sure you place the depends section correctly.
Here, you inherit the project.project module, so you should add this in the __openerp__.py:
'depends': ['project']
This is possibly because here you are inheriting the project module. So in your module's manifest file you have to make depend on the project module
eg:
In your openerp.py file add the following code
'depends': [
'project',
],
Cheers!
This happens with every newcomer in odoo , I also suffered with this "KeyError". Well I changed database by creating new one and Installed all needed modules again. It worked for me .
And about your English ,In Communication words doesn't matter , only understanding is require.
Hi I'm also new too odoo
I encountered same problem KeyError: 'some old model'
The reason is like other answers, due to stale data in the database
I fixed it by removing the records from db with this command
DELETE FROM ir_model WHERE model = 'yourmodule.oldmodelname';