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
Related
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>
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')
I'm create simple module with 4 fields (name,date,user,description).Below is my .xml file.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_my_report_form" model="ir.ui.view">
<field name="name">penalty.form</field>
<field name="model">my.report</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<form string="Project">
<sheet string="My report">
<group>
<div class="oe_title">
<h1 class="o_row">
<field name="name" placeholder="Name..." />
</h1>
</div>
</group>
<group>
<field name="user" placeholder="User..."/>
</group>
<group>
<field name="date" placeholder="Date..."/>
</group>
<notebook>
<page name="description_page" string="Description">
<field name="description"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_my_report_form">
<field name="name">Add new</field>
<field name="res_model">my.report</field>
</record>
<menuitem name="MY report" id="menu_penalty" action="action_my_izvjestaj_form" sequence="1"/>
</data>
</openerp>
When open from menu in grid view visble is only name.
https://postimg.org/image/ccms5aww3/
How add date and user fields?
You need to declare Tree view for that model.
<!-- Tree Views BEGIN-->
<record model="ir.ui.view" id="view_my_report_tree">
<field name="name">penalty.tree</field>
<field name="model">my.form</field>
<field name="arch" type="xml">
<tree string="Project">
<field name="name"/>
<field name="user"/>
<field name="date"/>
</tree>
</field>
</record>
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
I want to create Delivery orders based on a selection of order lines to invoices (as shown below) with the possibility to adjust quantity used in the delivery order.
Expected UI
Looking around, I found a UI similar to want I want in Delivery orders > More > Return Shipments (cf. _stock/wizard/stock_return_picking_view.xml_).
What I got
But I don't get the same result with my XML
view.xml
<record id="view_create_delivery_button" model="ir.ui.view">
<field name="name">Create Delivery</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<form string="Create Delivery" version="7.0">
<label string="Select the quantities to create."/>
<group>
<field name="order_id"/>
<field name="name"/>
<field name="product_uom_qty"/>
<field name="state" invisible="1" />
</group>
<footer>
<button name="create_returns" string="Create delivery" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
Question
How do I get this editable multilines layout?
What you see in the Return Shipments wizard is a one2many field that related to stock.return.picking.line on it tree view with editable=top attribute.
I am assuming this is what you wanted:
<record id="view_create_delivery_button" model="ir.ui.view">
<field name="name">Create Delivery</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<form string="Create Delivery" version="7.0">
<label string="Select the quantities to create."/>
<field name="order_line" >
<tree editable="top">
<field name="order_id"/>
<field name="name"/>
<field name="product_uom_qty"/>
<field name="state" invisible="1" />
</tree>
</field>
<footer>
<button name="create_returns" string="Create delivery" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
Note: This is just a sample of how to use the field many2one's tree view, you might need adjust to your on needs.