No matching record found for external id Odoo 12 csv file - module

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

Related

Odoo: How to add custom category name to app module's search panel?

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.

openerp odoo v11.0 invalid model name error

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!

How can you create new user group in a custom module?

I want to assign permissions to a new model for a specific group. This new group will be called "Product Extended User" as it enables access to "Product Extended" model and custom module.
If I do this in ir.mode.access.csv I expect to be enabling access to this group for the specific model.
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_extended_user_group,product.extended.user,model_product_extended,base.group_product_extended_user,1,1,1,1
However, the group is not created and hence the XMLID base.group_product_extended_user does not exist, and I doubt it would have to be prefixed with base..
How can I create such group, not manually but importing it from custom module data file?
First of all create ir.model.access.csv file and add the following code.
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_extended_user,product.extended.user,model_product_extended,module_name.group_product_extended_user,1,1,1,1
In this case model name is product.extended and group name is group_product_extended_user.
After that you will need to add this code in an xml file.
<record model="res.groups" id="group_product_extended_user">
<field name="name">Group name</field>
<field name="category_id" ref="module.category_id"/>
</record>
Add this xml and ir.model.access.csv files into data attribute of manifest file. You will be able to create a group in this way.
How do you then refer to this specific group in the ir.model.access.csv file, provided that both xml and ir.model.access.csv are defined in the same module?
In your __openerp__.py (or __manifest__.py in newer Odoo versions) file, ensure the file that creates the group is loaded before the ir.model.access.csv file.
Call it as you would any other group: your_module_name.group_xml_id
ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_extended_user_group,product.extended.user,model_product_extended,your_module_name.group_xml_id,1,1,1,1

Altering base Odoo field via XML file

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?

KeyError every times upgrade Odoo module

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';