I'm trying to define custom settings in Odoo. I used this link to help me http://ludwiktrammer.github.io/odoo/custom-settings-odoo.html.
I replaced
<menuitem id="your_settings_menu" name="Your settings"
parent="base.menu_config" action="your_settings_action"/>
by
<menuitem id="mattermost_settings_menu" name="Mattermost settings" parent="base.menu_administration"
action="mattermost_settings_action" />
Because I had this error: External ID not found in the system: base.menu_config"
Now, there is no compilation error and when I click on the menu I have this error:
Uncaught TypeError: Cannot read property 'settingView' of undefined
http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:5
Traceback:
TypeError: Cannot read property 'settingView' of undefined
at Class._moveToTab (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:5:42)
at Class._renderLeftPanel (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:8:315)
at Class._render (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:7:716)
at Class.prototype.(anonymous function) [as _render] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
at Class.start (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:1275:335)
at Class.prototype.(anonymous function) [as start] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
at Class.start (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:1609:20)
at Class.prototype.(anonymous function) [as start] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
at Class.start (http://127.0.0.1:8069/web/content/514-0b4bd55/web.assets_backend.js:3:654)
at Class.prototype.(anonymous function) [as start] (http://127.0.0.1:8069/web/content/383-805b1f7/web.assets_common.js:3538:488)
Here is my xml file:
<record id="res_config_settings_mm" model="ir.ui.view">
<field name="name">Mattermost config</field>
<field name="model">mattermost.settings</field>
<field name="arch" type="xml">
<form string="Your configuration" class="oe_form_configuration">
<header>
<button string="Save" type="object"
name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object"
name="cancel" class="oe_link"/>
</header>
<group string="Company">
<label for="id" string="Name & Phone"/>
<div>
<div>
<label for="company_name"/>
<field name="company_name"/>
</div>
<div>
<label for="company_phone"/>
<field name="company_phone"/>
</div>
</div>
</group>
</form>
</field>
</record>
<record id="mattermost_settings_action" model="ir.actions.act_window">
<field name="name">Mattermost config</field>
<field name="res_model">mattermost.settings</field>
<field name="view_id" ref="res_config_settings_mm"/>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="mattermost_settings_menu" name="Mattermost settings" parent="base.menu_administration"
action="mattermost_settings_action" />
Here is my python file:
class MattermostConfig(models.TransientModel):
_inherit = 'res.config.settings'
_name = 'mattermost.settings'
company_name = fields.Char()
company_phone = fields.Char()
#api.model
def get_default_company_values(self, fields):
_logger.critical('\n\nget_default_company_values\n\n')
company = self.env.user.company_id
return {
'company_name': company.name,
'company_phone': company.phone,
}
#api.one
def set_company_values(self):
_logger.critical('\n\nset_company_values\n\n')
company = self.env.user.company_id
company.name = self.company_name
company.phone = self.company_phone
Do you know how to resolve this ?
First, base.menu_config is base_setup.menu_config in new versions of Odoo.
Second, on the log you are showing, the problem lies in a view that inherits from assets backend. So, if the problem persists and you have a Bash shell, you could try the following:
cd <your_module's_directory>
find . -type f -exec grep -I -n "settingView"
else you could comment all your XML files at the __manifest__.py file and then uncomment them one by one.
Related
I created a model like this
class FoundCheque(models.TransientModel):
_name = "found.cheque"
date_Found = fields.Date(string='Found Date', default=fields.Date.context_today, required=True, translate=True)
and its view
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>
but when I try to update the module after restarting the service
it just says:
Field `date_found` does not exist
Error context:
View `found.cheque.wizard`
[view_id: 4100, xml_id: n/a, model: found.cheque, parent_id: n/a]
None" while parsing /opt/odoo/odoo11-custom-addons/cheque_management/views/found_cheque.xml:4, near
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight" confirm="آیا مطمئن هستید؟"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
and just to add I restarted the service several times
more information will be added on request
Your field name in python file is date_Found and date_found in xml. Both are different. so change field name in xml file
the defined field in model was "date_Found" and the defined field in wizard was "date_found"
F
When i add an image field in kanban view in odoo11 it has raised the error as "QWeb2 - template['kanban-box']: Runtime Error: TypeError: Cannot read property 'raw_value' of undefined" ". And the same code worked for me in odoo 9. I'm struck in identifying the cause of the issue. Here's my code.
Python Code:
class Test(models.Model):
_name = "test.test"
image = fields.Binary(attachment=True)
XML Code:
<record id = "test_id" model = "ir.ui.view">
<field name = "name">Test Image</field>
<field name = "model">test.test</field>
<field name = "arch" type = "xml">
<kanban>
<field name="image" />
<templates>
<t t-name="kanban-box">
<div class="oe_resource_vignette">
<div class="oe_resource_image">
<img t-att-src="kanban_image('test.test','image',record.id.raw_value)" class="oe_resource_picture"/>
</div>
</templates>
</kanban>
</field>
</record>
Thanks for your support and time.
You need to add the id field to the kanban view (in any view) if you will be referencing it. This applies up to Odoo 14 as well.
Added <field name="id" attrs="{'invisible': True}"/> to code below:
<record id = "test_id" model = "ir.ui.view">
<field name = "name">Test Image</field>
<field name = "model">test.test</field>
<field name = "arch" type = "xml">
<kanban>
<field name="image" />
<templates>
<t t-name="kanban-box">
<div class="oe_resource_vignette">
<div class="oe_resource_image">
<img t-att-src="kanban_image('test.test','image',record.id.raw_value)" class="oe_resource_picture"/>
</div>
</templates>
<field name="id" attrs="{'invisible': True}"/>
</kanban>
</field>
</record>
Kanban Docs: https://www.odoo.com/documentation/11.0/howtos/backend.html#kanban
you can try it by adding the "id"
<record id = "test_id" model = "ir.ui.view">
<field name = "name">Test Image</field>
<field name = "model">test.test</field>
<field name = "arch" type = "xml">
<kanban>
<field name="id"/>
<field name="image"/>
<templates>
<t t-name="kanban-box">
<div class="oe_resource_vignette">
<div class="oe_resource_image">
<img t-att-src="kanban_image('test.test','image',record.id.raw_value)" class="oe_resource_picture"/>
</div>
</templates>
</kanban>
</field>
I have been battling with an issue for a while now....Kindly help me. Below is the issue:
I created a button on the header of a form, the idea of this button is to show a report of an image file on click. But anytime i click this button, nothing happens. And when i edited the form view from developer's mode, i realized that the button is picking a different name. i.e
<header>
<button name="reports/bh_customcustom.report_formdownload_view" type="report" string="Form Download" class="oe_highlight"/>
</header>
instead of this which is in the code:
<header>
<button name="action_formdownloader" type="object"
string="Form Downloader" class="oe_highlight"/>
</header>
Below are my code snippet:
The form view:
<record model="ir.ui.view" id="form_download_form_view">
<field name="name">form_download.form</field>
<field name="model">formdownload</field>
<field name="arch" type="xml">
<form string="Form Download Form">
<header>
<button name="action_formdownloader" type="object"
string="Form Downloader" class="oe_highlight"/>
</header>
<sheet>
<group string="Company Name">
<!--<field name="company_name_id"/>-->
<field name="name"/>
<!--<field name="form_serial_no" />-->
</group>
</sheet>
</form>
</field>
</record>
The model:
class FormDownload(models.Model):
_name = 'formdownload'
_rec_name = 'form_serial_no'
# #api.multi
def action_formdownloader(self):
return self.env['report'].get('bh_customcustom.report_formdownload_view')
name = fields.Many2one('companyname', string="Company Name", ondelete='cascade',
required=True)
form_serial_no = fields.Char(string="Form Serial No", readonly=True)
status = fields.Boolean(string="Status", default=False)
Part of the openerp.py file related to it
'depends': ['base', 'construction_plot_4devnet', 'bh_custom', 'report'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/bh_customcustom.xml',
'sequences.xml',
'report/form_download_report.xml',
'security/security_groups.xml',
'templates.xml',
],
'images': [
'img/firstpage.png',
],
The report file:
<openerp>
<data>
<report
id="report_form_download"
model="formdownload"
string="Form Download Report"
name="bh_customcustom.report_formdownload_view"
file="bh_customcustom.report_formdownload_view"
report_type="qweb-pdf"/>
<record id="paperformat_formdownloadcheck" model="report.paperformat">
<field name="name">Form Download Check</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">80</field>
<field name="page_width">175</field>
<field name="orientation">Portrait</field>
<field name="margin_top">3</field>
<field name="margin_bottom">3</field>
<field name="margin_left">3</field>
<field name="margin_right">3</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">3</field>
<field name="dpi">80</field>
</record>
<template id="report_formdownload_view">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<!--<img class="img img-responsive" src="/bh_customcustom/static/src/img/firstpage.png"-->
<!--style="max-height: 45px"/>-->
<img src="/static/src/img/firstpage.png"
style="max-height: 45px"/>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>
The problem was from my path on the view xml file cos i edited the form view now and it's picking the exact method that it suppose to pick after i reviewed the path. Moreso, the method that would pull the report should be like this:
#api.multi
def action_formdownloader(self):
return self.env['report'].get_action(self, 'bh_customcustom.report_formdownload_view')
my mission is to select several elements from the list view than click on "show wizard button" that is added to "more" option !
My code bellow adds the button but not in the ListView, but accually after clicking of the element and showing the formView!
Mytestmodule.wizard.py :
class wiz(models.TransientModel):
_name = 'mytestmodule.wizard'
name=fields.Text()
#api.multi
def create_request(self):
print "You click finish"
return True
My wizard form :
<record model="ir.ui.view" id="mywiz" >
<field name="name">mywiz</field>
<field name="model">mytestmodule.wizard</field>
<field name="arch" type="xml">
<form string="my wizard">
<group>
<field name="name"/>
</group>
<footer>
<button name="create_request" string="Finished" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>
The added button :
<act_window id ="addedButton" name="Show wizard"
res_model="mytestmodule.wizard"
src_model="mytestmodule.people"
view_type="tree"
view_mode="form"
target="new"
/>
I know it must be something missing or had to change in tag ! but i have no idea how to do so .
Thank you in advance .
I solved the problem by adding multi="True" attribute in tag :
<act_window id ="addedButton"
name="Show wizard"
res_model="account_voucher_bymail.wizard"
src_model="account.invoice"
view_type="tree"
view_mode="tree,form"
target="new"
multi="True"
/>
I've Created a Wizard in Tree View Mode and Just Want to add some button with it, is there a way to this in odoo 8?
Thanks
Yes, you can add button in the tree view like you are adding in the form view.
<tree string="My Tree">
<button name="%{action_wiz_open}d" string="Scrap Products" type="action" icon="terp-gtk-jump-to-ltr" help="calls window action" />
<button name="call_function" string="Process" type="object" help="calls python function" />
</tree>
Hope this helps!
To add a button in tree view try below code:
<tree>
<button name="your_action" icon="rupee-symbol"
String="Payment" type="action"
attrs="{'invisible':[('status','!=','Confirmed')]}" />
</tree>
Hope it will help you..
Create a folder wizard
which will have
__init__.py
file_name.py
file_name_view.xml
In Python file_name.py
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
if context is None:
context={}
res = super(class_name_wizard, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
return res
Add your function next to it
In file_name_view.xml
<record model="ir.ui.view" id="new_id">
<field name="name">New Wizard</field>
<field name="model">my.wizard</field>
<field name="arch" type="xml">
<form string="New Form">
<header>
<button name="do_generate" string="My Function" type="object"/>
or
<button string="Cancel" class ="oe_link" special="cancel"/>
</header>
</form>
</field>
</record>
<record id="action_my_function_wizard" model="ir.actions.act_window">
<field name="name">My Function</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">my.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<act_window name="My Function"
res_model="my.wizard"
src_model="product.master"
view_mode="form"
target="new"
multi="True"
key2="client_action_multi"
id="action_view_my_new_id"/>
Note:In src_model write the table name of the tree view
Hope this will help you