Python Debugger out of sync with code - odoo

I am in the process of debugging something in OpenERP using Python 2.7.3. The debugger seems to get out of sync with the code when stepping through with the Next (n) command. See Code and output below. I have the same problem with Python 2.6.5. I have never experienced this before using Python pdb.
I believe the problem may be related to the way OpenERP calls my method through a Python exec() statement by reading the code field in the OpenERP XML below. Is possible that calling Python code constructed dynamically and called via exec() is confusing the pdb debugger?
If this is the case is there a work around?
CODE called via this OpenERP action below:
<record id="action_wash_st_method1" model="ir.actions.server">
<field name="type">ir.actions.server</field>
<field name="condition">True</field>
<field name="state">code</field>
<field name="model_id" ref="model_view_tree_display_address_list"/>
<field eval="5" name="sequence"/>
<field name="code">
action = self.view_calc_sales_tax(cr, uid, context)
</field>
<field name="name">wash state action request</field>
</record>
<record model="ir.values" id="action_wash_st_tax_trigger_method1" >
<field name="key2" eval="'tree_but_open'" />
<field name="model" eval="'view.tree.display.address.list'" />
<field name="name">Method1 Wash State</field>
<field name="value" eval="'ir.actions.server,%d'%action_wash_st_method1"/>
<field name="object" eval="True" />
</record>

Related

No matching record found for external id 'groups_group1' in field 'Group'

Please i want to establish access rights for my module, so I modify the file csv I try to install the module, but this error appears at the time of installation of the module:
File "/home/omar/odoo/odoo11/odoo/modules/loading.py", line 95, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/home/omar/odoo/odoo11/odoo/tools/convert.py", line 785, in convert_file
convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/omar/odoo/odoo11/odoo/tools/convert.py", line 832, in convert_csv_import
raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
Exception: Module loading moduletest failed: file moduletest/security/ir.model.access.csv could not be processed:
No matching record found for external id 'groups_group1' in field 'Group'
No matching record found for external id 'groups_group2' in field 'Group'
One of the things that make this error occur is when you don't respect the order of security files, you have to put your .xml file that is related to security before the .csv file in your __ manifest __.py
Here's a simple example:
'data': [
'views/security.xml',
'security/ir.model.access.csv',
# ... other includes ...
]
this is a sample code for category and group
<record model="ir.module.category" id="module_category_stock_quotation_request"> -->
<!-- <field name="parent_id" ref="module_category_localization" /> -->
<!-- <field name="name">Stock Transfert Request</field>
<field name="visible" eval="0" />
</record>
<record id="group_stock_quotation_request_user" model="res.groups">
<field name="name">User</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="category_id" ref="module_category_stock_quotation_request"/>
</record>
<record id="group_stock_quotation_request_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('transfert_request.group_stock_quotation_request_user'))]"/>
<field name="category_id" ref="module_category_stock_quotation_request"/>
</record>

Odoo security guides and tutorials [duplicate]

I have developed a custom Module in OpenERP 7, My administrator user can only see this module.
1-How can I give access to normal users to my custom modules?
2-What are the steps to solve this problem.
Please give a detailed example.
Create a one Security folder which has below two files. For example,
test_security.xml and
ir.model.access.csv
security/test_security.xml file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.module.category" id="module_category_name_test">
<field name="name">Management</field>
<field name="sequence">7</field>
</record>
<record id="group_name_test_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_name_test_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('group_name_test_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>
After do this Management Option show with two selection value like User and Manager in setting => Users => Access Rights => Application
Now turn for security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
unique_id, test.name, model_test_name, group_name_test_user, 1,1,0,0
unique_id, test.name, model_test_name, group_name_test_manager, 1,1,1,1
test.name is a table name.
Example of csv file, how to create? Where
Fields => Value => Description
id => access_testing_for_user => id must be unique.
name => testing.for.user => name is given as we want.
model_id:id => model_test_name => model_id:id is given like model_our_class_name.
group_id:id => group_name_test_user => group_id:id is xml id of above we create like for User and Manager.
perm_read => 1 for True and 0 for False for read record.
perm_write => 1 for True and 0 for False for write record.
perm_create => 1 for True and 0 for False for create record.
perm_unlink => 1 for True and 0 for False for delete record.
NOTE
These two files .xml and .csv must be listed in __openerp__.py as other view files are given.

Can not customize hr module in openerp by adding additional fields

I was trying to add a extra field in hr module i.e in hr.employee object by inheritance but when I'm adding that field ,in Hr module employee form my given field is not displayed .So pls help. All I want to do is create another seperate module so whenever that module is installed then that column should appear.(my field jdate should appear after coach_id field)
class joining_date(osv.osv):
_name="joining.date"
_inherit = "hr.employee"
_columns={
'jdate':fields.date('Joining date'),
}
joining_date()
xml part:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_join_date" model="ir.ui.view">
<field name="name">Join_date</field>
<field name="model">joining.date</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//form/sheet/notebook/page/group[1]/group[2][#name='coach_id']" position="after">
<field name="jdate"/>
</xpath>
</data>
</field>
</record>
openerp file:
{
'name': 'HR join date',
'version': '1.0',
'category': 'Tools',
'description': """ To add extra join date field""",
'author': 'Greywind',
'website': 'http://www.greywind.com',
'depends': ['hr','base', 'account_accountant'],
'data': [
'joindate_view.xml'],
'demo': [],
'installable': True,
'auto_install': False,
}
I think your XML should look like this:
<record id="view_join_date" model="ir.ui.view">
<field name="name">Join_date</field>
<field name="model">joining.date</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<field name="coach_id" position="after">
<field name="jdate"/>
</field>
</field>
</record>
Try to -name and -inherits field as the same id. if its so you can add your field in to the inherited module.
Then ref=base module view idand also if you want all the fields of your base module to your new module then you just change ref = **base module view id . new module view id you should create the view for the new module with all the fields you needed from base & new field.
You should refer MrEthan Furman xml code.

OpenERP 7 How to give users access to custom module in OpenERP 7?

I have developed a custom Module in OpenERP 7, My administrator user can only see this module.
1-How can I give access to normal users to my custom modules?
2-What are the steps to solve this problem.
Please give a detailed example.
Create a one Security folder which has below two files. For example,
test_security.xml and
ir.model.access.csv
security/test_security.xml file
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.module.category" id="module_category_name_test">
<field name="name">Management</field>
<field name="sequence">7</field>
</record>
<record id="group_name_test_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_name_test_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_category_name_test"/>
<field name="implied_ids" eval="[(4, ref('group_name_test_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>
After do this Management Option show with two selection value like User and Manager in setting => Users => Access Rights => Application
Now turn for security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
unique_id, test.name, model_test_name, group_name_test_user, 1,1,0,0
unique_id, test.name, model_test_name, group_name_test_manager, 1,1,1,1
test.name is a table name.
Example of csv file, how to create? Where
Fields => Value => Description
id => access_testing_for_user => id must be unique.
name => testing.for.user => name is given as we want.
model_id:id => model_test_name => model_id:id is given like model_our_class_name.
group_id:id => group_name_test_user => group_id:id is xml id of above we create like for User and Manager.
perm_read => 1 for True and 0 for False for read record.
perm_write => 1 for True and 0 for False for write record.
perm_create => 1 for True and 0 for False for create record.
perm_unlink => 1 for True and 0 for False for delete record.
NOTE
These two files .xml and .csv must be listed in __openerp__.py as other view files are given.

2 Threads created when double clicking in tree/list in OpenERP

Why does OpenERP create 2 different threads when executing a tree_but_open event. When I double click an item in the tree, it appears to create 2 different threads for each click and then executes my Python method in each thread.
Is this normal behaviour?
<record id="action_wash_st_method1" model="ir.actions.server">
<field name="type">ir.actions.server</field>
<field name="condition">True</field>
<field name="state">code</field>
<field name="model_id" ref="model_view_tree_display_address_list"/>
<field eval="5" name="sequence"/>
<field name="code">
self.view_calc_sales_tax(cr, uid, context)
</field>
<field name="name">wash state action request</field>
</record>
<record model="ir.values" id="action_wash_st_tax_trigger_method1" >
<field name="key2" eval="'tree_but_open'" />
<field name="model" eval="'view.tree.display.address.list'" />
<field name="name">Method1 Wash State</field>
<field name="value" eval="'ir.actions.server,%d'%action_wash_st_method1"/>
<field name="object" eval="True" />
</record>
OpenERP Output: Notice the 2 different thread ids printed in my method when I double click in a tree/list.
********************before calling button_reset_taxes, 47494460417792
**************Entering button_reset_taxes: 47494460417792
2012-08-07 04:09:26,383 30080 INFO ? werkzeug: 71.195.148.241 - - [07/Aug/2012 04:09:26] "POST /web/action/run HTTP/1.1" 200 -
2012-08-07 04:09:26,402 30080 INFO ? werkzeug: 71.195.148.241 - - [07/Aug/2012 04:09:26] "POST /web/treeview/action HTTP/1.1" 200 -
2012-08-07 04:09:26,496 30080 INFO ? werkzeug: 71.195.148.241 - - [07/Aug/2012 04:09:26] "POST /web/session/eval_domain_and_context HTTP/1.1" 200 -
********************before calling button_reset_taxes, 47494452025088
**************Entering button_reset_taxes: 47494452025088
2012-08-07 04:09:26,590 30080 INFO ? werkzeug: 71.195.148.241 - - [07/Aug/2012 04:09:26] "POST /web/action/run HTTP/1.1" 200 -
Yes this is an Normal Behavior .
even at time of Import data from webclient.
when you click on the "IMPORT" it waits for the reply from server (to check to put web in loading mode). and if within that time if you click again it will import again .
Button are one Click Element in view, now you say you click Double click on button the lead to time trigger the button action that is defined on action. Else that is Normal it does not do any anonymous activity.
Thank YOU