Launching Wizard from ListView after selecting elements odoo8 - odoo-8

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"
/>

Related

Unable to acces view in Odoo

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.

TypeError: dict.record.id is undefined when I access to my custom kanban view in Odoo 11

I have a custom module that had a kanban view. His model inherits from res.users (and res.users inherits from res.partner).
I have a problem when I try to access to kanban view of my module. I know where is the error, but i donĀ“t have idea for how to solve.
The error is:
Error: QWeb2 - template['kanban-box']: Runtime Error: TypeError: dict.record.id is undefined
This is my kanban view (maestro):
<record model="ir.ui.view" id="maestro_kanban_view">
<field name="name">maestro.kanban.view</field>
<field name="model">aula10.maestro</field>
<field name="groups_id" eval="[(4, ref('grupo_maestros'))]"/>
<field name="arch" type="xml">
<kanban>
<field name='name'/>
<field name='image'/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div class="o kanban_image">
<img t-att-src="kanban_image('maestro','image_medium', record.id.value)"/>
<div class="oe_kanban_details">
<!-- Title and Data content -->
<h4>
<a type="open">
<field name="name"/>
</a>
</h4>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
I know the problem is in the image, in record.id.value, because when I erase the img tag, the error disappear.
How can I fix this?
In kanban view you must mention every fields you use in the field list like in your code you have mentioned two fields nameand image just add id to them and Odoo should recognize it.
<field name='id'/>
<field name='name'/>
<field name='image'/>

Odoo - Change specific column color in one2many tree view

I am using odoo 10. I have a customer view and in that customer form view i am also showing all order that are associated with that specific customer in one2many tree view (editable).
What i want to do is i want to show a button in one2many tree view but i want to change that button's color only based on condition.
Here is what i tried but its not working.
<record id="amgl.customer_form" model="ir.ui.view">
<field name="name">Customer</field>
<field name="model">amgl.customer</field>
<field name="arch" type="xml">
<form string="Create New Customer" duplicate="0">
<sheet>
<group colspan="4">
<group>
<field name="is_admin" invisible="1"/>
<field name="is_custodian" invisible="1"/>
<field name="is_vault" invisible="1"/>
<field name="is_o2m" invisible="1"/>
<field name="is_goldstar" invisible="1"/>
<field name="custodian_edit" invisible="1"/>
<field name="first_name"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="last_name"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="account_number"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="gst_account_number" string="GoldStar Account Number"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)], 'invisible':[('is_goldstar','=',False)]}"/>
</group>
<group>
<field name="date_opened"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="account_type"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
<field name="custodian_id" options='{"no_open": True}'
attrs="{'readonly':[('is_admin','=', False)]}"/>
<field name="customer_notes"
attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
</group>
</group>
<notebook>
<!--CURRENT INVENTORY-->
<page string="CURRENT INVENTORY">
<field name="customer_order_lines2"
attrs="{'readonly':['|',('is_custodian','=', True),('is_o2m','=', False)]}"
context="{'default_is_deposit_related': True,'group_by':'products'}"
groups="amgl.group_amark_admins,amgl.group_amark_vault,amgl.group_amark_custodian,amgl.group_amark_sub_admins"
domain="[('state','=','completed')]" default_order='state desc'
widget="one2many_list">
<h4 style="float:right;">
<field name="total_received_quantity"/>
</h4>
<tree open="false" editable="bottom"
groups="amgl.group_amark_admins,amgl.group_amark_vault,amgl.group_amark_custodian,amgl.group_amark_sub_admins">
<field name="is_deposit_related" invisible="1"/>
<field name="is_vault_edit" invisible="1"/>
<field name="is_admin" invisible="1"/>
<field style="color:red !important;" name="products" attrs="{'readonly':[('is_vault_edit','=', True)]}"/>
<field name="commodity"/>
<field name="total_received_quantity"
attrs="{'readonly':[('is_vault_edit','=', True)]}" class="oe_edit_only"
col_border="1" string="Received"/>
<field name="temp_received_weight" class="oe_edit_only" col_border="1"/>
<field name="date_received" attrs="{'readonly':[('is_vault_edit','=', True)]}"
class="oe_edit_only" col_border="1"/>
<field name="state" invisible="1"/>
<field name="notes_boolean" invisible="1"/>
<button attrs="{'invisible':[('notes_boolean','=', False)]}" type="object" name="add_notes" class="btn btn-primary btn-sm o_list_button_add">
<i class="fa-lg fa-pencil-square"></i>
</button>
<button attrs="{'invisible':[('notes_boolean','=', True)]}" type="object" name="add_notes" class="btn btn-default">
<i class="fa-lg fa-pencil-square"></i>
</button>
<!--<button colors="red: notes_boolean is True" name="add_notes" type="object"-->
<!--string="Add Notes" icon="fa-lg fa-pencil-square" class="btn btn-primary btn-sm o_list_button_addhlight"/>-->
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
What you are doing is the right solution you cannot change attributes of button using attrs
so you need to create two button with the same name and label and show or hide one of them
based on condition.
but this code will not work on tree because Odoo will not take your class attribute or style attribute
in consideration no matter what you put there if you inspect the button element in your browser you will find that
the two buttons are the same and the classes are the same and your classes are not there and there is no style attribute.
I don't know why Odoo developer decided to do so.
I needed something like this before what I did is to add css in backend_assets that select a button in tree
view with data-field attribute equal the name of the method because that attribute will not change in translation.
/* make button color red in temporary exit tree view.*/
.openerp .oe_list_content [data-field='cancel_entry'] button{
background-color: red !important;
color: white !important;
}
you will notice that only this attribute change in the buttons that are in the tree view.
so if you want to do something like this you need to to create two method
#api.multi
def add_notes_red(self): # i added _red to make sure no one else will name he's method like this
pass
#api.multi
def add_notes_green(self):
return self.add_notes_red() # because it does the same thing just call the orignal method
And in your custom css file
/* make button color red.*/
.openerp .oe_list_content [data-field='add_notes_red'] button{
background-color: red !important;
color: white !important;
}
/* make button color green.*/
.openerp .oe_list_content [data-field='add_notes_green'] button{
background-color: green !important;
color: white !important;
}
Note: Don't forget to css file in backend_assets template.

Button not displaying report in odoo

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

Adding a Button in Tree View Odoo 8

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

Resources