odoo inheritance of view element without name or id - xpath

In odoo I try to change the recruitement form, but some of the stuctural elements dont have a name or id. When I change those elements it works fine initially, but when I upgrade the database then the rendering of the xml is stricter for some reason and gives an ParseError.
The recruitement form:
<sheet>
<div class="oe_button_box" name="button_box"/>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name" placeholder="e.g. Sales Manager"/></h1>
</div>
<notebook>
<page string="Job Description">
<div attrs="{'invisible': [('state', '!=', 'recruit')]}">
<label for="description"/>
<field name="description" type="html"/>
</div>
</page>
<page name="description_page" string="Description">
<field name="description" type="html"/>
<div class="d-none oe_clear"/>
</page>
<page string="Recruitment">
<group>
<group name="recruitment">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field name="department_id"/>
</group>
<group>
<field name="no_of_recruitment"/>
</group>
</group>
</page>
</notebook>
</sheet>
As you can see; the sheet, notebook, pages and groups mostly dont have a name. The string attribute is also not sufficient to modify with a expression in xpath. So it feels like I'm just stuck with this framework.
What I try:
<xpath expr="//sheet/notebook" position="replace">
<notebook>
<page name="description_page" string="Description">
<field name="description" type="html"/>
<div class="d-none oe_clear"/>
</page>
<page string="Recruitment">
<group>
<group name="recruitment">
<field name="branch_concept" />
<field name="branch" />
<field name="department_id" />
</group>
<group>
<field name="no_of_recruitment"/>
</group>
</group>
</page>
</notebook>
</xpath>
And this works until I do a db upgrade, then I get a parseError.
Does anybody know I can use my own structure?

In the xpath expression you use //<some_node> to 'Selects nodes in the document from the current node that match the selection no matter where they are'. You can also use /<some_node>/<some_other_node> to locate a specific element.
for example /form/sheet/notebook/page[1]

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

how to change default delete icon of odoo 11

I have given editable bottom so i am getting default delete icon of odoo11. But i want to change it only to my module. How to change the delete icon to my own module ?
<field name="name"> Attachments</field>
<field name="model">attachments</field>
<field name="arch" type="xml">
<form string="Attachments">
<field name="line_ids" >
<tree string="Attachments" editable="bottom">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
</field>
Thanks in Advance !
just add delete="false" in tree view
<field name="name">Attachments</field>
<field name="model">attachments</field>
<field name="arch" type="xml">
<form string="Attachments">
<field name="line_ids" >
<tree string="Attachments" editable="bottom" delete="false">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
</field>
You can add delete="false" in tree tag
ex.
<tree string="Attachments" editable="bottom" delete="false">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>

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

How do I get an editable multilines layout in OpenERP?

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.

Resources