Wrong value for ir.ui.menu.action on view side - odoo-view

i am new odoo dev. current i created new a model view and menu action i am not geting Error in model
my custom modules work without a view when enabling view then occurred Error
model
class ResPartner(models.Model):
_inherit = 'res.partner'
partner_firstname = fields.Char(string="Partner Firstname")
View code
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="res_pr_forms" model="ir.ui.view">
<field name="name">resPatientforms</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<form >
<sheet>
<group>
<field name="partner_firstname"/>
</group>
</sheet>
</form>
</field>
</record>
<!-- This Menu Item will appear in the Upper bar, That's why It needs NO parent or action -->
<menuitem id="test_view_root" name="Test yvonne " />
<!-- This Menu Item must have a parent and an action -->
<menuitem id="test_sub_categ" name="Test form Open" parent="test_view_root" action="res_pr_forms" sequence="15"/>
</data>
</odoo>
Error
ValueError: Wrong value for ir.ui.menu.action: 'form,765'
raise ValueError("Wrong value for %s: %r" % (self, value))
odoo.tools.convert.ParseError: "Wrong value for ir.ui.menu.action: 'form,765'"

You need to provide a valid action (ir.actions.act_window) to the menu item, not a form view (ir.ui.view).
Check the following example taken from Building a module/Actions and Menus:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- window action -->
<!--
The following tag is an action definition for a "window action",
that is an action opening a view or a set of views
-->
<record model="ir.actions.act_window" id="course_list_action"> <!-- Action definition -->
<field name="name">Courses</field>
<field name="res_model">openacademy.course</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">Create the first course
</p>
</field>
</record>
<!-- top level menu: no parent -->
<menuitem id="main_openacademy_menu" name="Open Academy"/>
<!-- A first level in the left side menu is needed
before using action= attribute -->
<menuitem id="openacademy_menu" name="Open Academy"
parent="main_openacademy_menu"/>
<!-- the following menuitem should appear *after*
its parent openacademy_menu and *after* its
action course_list_action -->
<menuitem id="courses_menu" name="Courses" parent="openacademy_menu"
action="course_list_action"/> <!-- specify the ation -->
<!-- Full id location:
action="openacademy.course_list_action"
It is not required when it is the same module -->
</odoo>

Related

Custom view of model inside the form view

I have this two models EstatePropertyModel and AuthorsModel, and I would like to display the entries of the AuthorsModel in the form of the EstatePropertyModel:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_estate_property_advertisement_form" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
name="name"/>
name="description"/>
name="postcode"/>
name="date_availability"/>
name="expected_price"/>
name="selling_price"/>
name="bedrooms"/>
name="living_area"/>
name="facades"/>
name="garage"/>
name="garden"/>
name="garden_area"/>
name="garden_orientation"/>
name="state_property"/>
name="active"/>
<field name="author_ids" position="after">
<div class="oe_title">Authors</div>
<div class="oe_subtitle">
<t t-if="len(record.author_ids) == 0">No authors</t>
<t t-if="len(record.author_ids) > 0">
<t t-foreach="record.author_ids" t-as="author">
<span t-field="author.name"/>
</t>
</t>
</div>
</field>
</odoo>
Is this possible?
I am new in the odoo development, and I am asking to point me the direction where to look! 
Thanks
yeeah it's possible through One2many field in odoo, after that, create a Notebook in the form view in that notebook and create a page, on that page add the one2many view in it
it will be made like this...
<notebook>
<page>
<field name="one2many_field_name">
<tree string="Example" editable="bottom">
<field name="field_1_from_2nd_model"/>
<field name="field_2_from_2nd_model"/>
</tree>
</field>
</page>
</notebook>
as per the comment below the answer is below this:
class ExampleModelFirst(models.Model):
_name = 'first.model'
field_1 = fields.Char(string='Field 1')
field_2 = fields.Integer(string='Field 2')
class ExampleModelSecond(models.Model):
_name = 'second.model'
field_3 = fields.Many2one('first.model', string='reference')
field_4 = fields.Char(related='field_3.field_1')
field_5 = field.Integer(related='field_3.field_2')
Add these second.model field in form view you will get the values...
author_ids should be one2many field
To create a One2many field you can refer to this https://www.odoo.com/documentation/16.0/developer/howtos/rdtraining/08_relations.html#one2many
Do this if you want to show all fields
<notebook>
<page string="Authors">
<field name="author_ids"/>
</page>
</notebook>
Do this if you want to show specific fields
<notebook>
<page string="Authors">
<field name="author_ids">
<tree>
<field name="author_ids.name"/>
</tree>
</field>
</page>
</notebook>

odoo wizard cant inherit the model

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

odoo ir.actions.server id not found

I'm new to Odoo. While trying to call a server action from a menuitem it can't find the model_id.
My view code:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.actions.server" id="open_calculator">
<field name="name">Open Calculator</field>
<field name="model_id" ref="calculator"/>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
<!--code-->
</field>
</record>
<!-- Top menu item -->
<menuitem name="Calculator" id="calculator.menu_root"
action="open_calculator"/>
</data>
</openerp>
The error:
raise ValueError('External ID not found in the system: %s' % (xmlid))
ParseError: "External ID not found in the system: calculator.calculator" while parsing /home/administrador/Escritorio/calculator-test-project/calculator/views/views.xml:4, near
<record model="ir.actions.server" id="open_calculator">
<field name="name">Open Calculator</field>
<field name="model_id" ref="calculator"/>
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
<!--code-->
</field>
</record>
Model:
# -*- coding: utf-8 -*-
from openerp import models, fields, api, http
class Calculator(models.Model):
_name = 'calculator'
What am I missing?
It appears that there is a convention you have to follow in model_id's ref attr. You have to add '_model' before your model name:
<field name="model_id" ref="model_calculator"/>
instead of:
<field name="model_id" ref="calculator"/>
or it won't work.
Just as in this question

Launching Wizard from ListView after selecting elements odoo8

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

How to show currency symbol instead of currency name?

I created a module to show related Purchase Orders from projects:
After clicking the Compras (Purchases) button a custom tree view is shown with the currency_id field:
Is there a way to show the symbol of the currency instead of the name? Something like you would do for example using Django: currency_id.symbol. Even better, I want to drop the currency_id field and prepend the currency symbol in the total amount, is that possible? Something like S/. 336.30 in the amount_total field.
Here's my tree view:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
....
....
<record id="purchase_order_project_tree" model="ir.ui.view">
<field name="name">purchase.order.tree</field>
<field name="model">purchase.order</field>
<field name="arch" type="xml">
<tree string="Compras"
colors="grey:state=='cancel';blue:state in ('wait','confirmed');red:state in ('except_invoice','except_picking')">
<field name="name" string="Reference"/>
<field name="date_order" />
<field name="partner_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="currency_id" />
<field name="amount_total" />
<field name="state"/>
</tree>
</field>
</record>
....
....
</data>
</openerp>
You can add a field called currency_symbol in your module (py) that gets the currency symbol when the currency changues with an on_changue to the currency. So you bring that field to the view, you cant directly do it from the XML.
When you click on the that button to get the tree get listed, you can override the "name_get" method of "Currency" and fetch the "currency symbol" instead of name. For this you can pass a flag in the context to limit this modification specific to your module only.
Hope this helps!!.

Resources