Odoo 10 : How to increase the field width? - css

I have a form view which looks like this :
the xml looks like this :
<notebook>
<page>
<group string="In case of student employee or intern">
<field name="immatriculation" attrs="{'readonly':True}"/>
<field name="studentStatus" attrs="{'readonly':True}"/>
<field name="studentQuestionnaire" attrs="{'readonly':True}"/>
<field name="studentOtherjobs" attrs="{'readonly':True}"/>
</group>
</page>
</notebook>
I would like to increase the width of these fields so that All text (e.g. Confirmation of Student Status (Mandatory Internship) )
comes in a single line. I tried below but didnt see any changes in width :
<field name="studentStatus" attrs="{'readonly':True}" style="width:200px"/>
What is the right way to change the width of these fields inside a group?

Just put a <div/> tag it will render 50% space for label and 50% for fields
Like this
<group string="In case of student employee or intern">
<div /> <!-- here it is -->
<field name="immatriculation" attrs="{'readonly':True}"/>
<field name="studentStatus" attrs="{'readonly':True}"/>
<field name="studentQuestionnaire" attrs="{'readonly':True}"/>
<field name="studentOtherjobs" attrs="{'readonly':True}"/>
</group>
if you need space more then 50% then you have to apply style

When the checkbox string is long, I'd put the string to the right of the box.
You may consider below view.
<group>
<label string="Confirmation" for="confirm1" class="oe_inline"/>
<div>
<field name="confirm1" nolabel="1" class="oe_inline" modifiers="{}"/>
<label string="blah blah blah" class="oe_inline"/>
</div>
<label string=" " for="confirm2" class="oe_inline"/>
<div>
<field name="confirm2" nolabel="1" class="oe_inline" modifiers="{}"/>
<label string="blah blah blah" class="oe_inline"/>
</div>
<label string=" " for="confirm3" class="oe_inline"/>
<div>
<field name="confirm3" nolabel="1" class="oe_inline" modifiers="{}"/>
<label string="blah blah blah" class="oe_inline"/>
</div>
</group>

It's a bit tricky but you could try a simple solution by setting colspan to use the whole width of the notebook page.
<group string="In case of student employee or intern" colspan="4">

Try this one ... maybe u have to do it on every field
<field name="field1" style="width:40%%" />

Related

how to create a button that opens a popup without automatic registration / creation of the form odoo13

I want to create a button that opens a popup that takes over some form fields.
These fields can be modified / filled in.
When closing the fields concerned are updated.
without saving or creating the record before I click on the save button.
I don't see how to get there knowing that there are no relational fields.
Should I create a widget, a wizard, both ....
Help me please.
Here is my current code :
test_scale.py :
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class TestScale(models.Model):
_name = 'test.scale'
name = fields.Char(required=True)
weighing = fields.Integer('weighing', default=0)
test_scale.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="test_scale_tree_view" model="ir.ui.view">
<field name="name">test.scale.tree</field>
<field name="model">test.scale</field>
<field name="arch" type="xml">
<tree string="Test scale">
<field name="name"></field>
<field name="weighing"></field>
</tree>
</field>
</record>
<record id="test_scale_form_view" model="ir.ui.view">
<field name="name">test.scale.form</field>
<field name="model">test.scale</field>
<field name="arch" type="xml">
<form string="Test scale">
<sheet>
<group name="main_info">
<field name="name"></field>
<field name="weighing"></field>
<button name="%(test_scale_configurator_action)d"
type="action"
string="Weighing"
class="oe_highlight"
context="{'weighing': weighing}"></button>
</group>
</sheet>
</form>
</field>
</record>
<record id="saisie_menu_action" model="ir.actions.act_window">
<field name="name">Test_scale</field>
<field name="res_model">test.scale</field>
<field name="type">ir.actions.act_window</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Aucun enregistrement
</p>
</field>
</record>
<menuitem id="test_scale_menu"
name="Test_scale"/>
<menuitem id="test_scale_saisie_menu"
parent="test_scale_menu"
name="Saisie"
action="saisie_menu_action"/>
</odoo>
test_scale_configurator.xml :
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="test_scale_configurator_view_form" model="ir.ui.view">
<field name="name">test.scale.configurator.view.form</field>
<field name="model">test.scale.configurator</field>
<field name="arch" type="xml">
<form>
<field name="weighing"/>
<footer>
<button type="object"
name="button_save"
string="Save"
/>
<button special="cancel"
string="Cancel"
class="btn-secondary"/>
</footer>
</form>
</field>
</record>
<record id="test_scale_configurator_action" model="ir.actions.act_window">
<field name="name">Test Scale</field>
<field name="res_model">test.scale.configurator</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="test_scale_configurator_view_form"/>
</record>
</odoo>
test_scale_configurator.py :
# -*- coding: utf-8 -*-
from odoo import models, fields
class TestScaleConfigurator(models.TransientModel):
_name = 'test.scale.configurator'
weighing = fields.Integer(string='weighing')
def button_save(self):
self.ensure_one()
return True
This thing is done by relational fields of odoo , For EX:-
In your test.scale model your field is weighing,
First you need to configure your current model test.scale 's id in wizard so you can reference it, like this you can add the field in wizard.
test_scale_id = fields.Many2one(string="Test Scale")
After that add context in you main model's xml file where is the button which one opens the wizard like this.
<button name="%(test_scale_configurator_action)d"
type="action"
string="Weighing"
class="oe_highlight"
context="{'default_test_scale_id': active_id}"></button>
After that this field needs to be invisible in your wizard's form in order to save data in wizard so you can refernce it later.
<field name="test_scale_id" invisible="1"/>
and in your wizard weighing field is stayed like this.
weighing = fields.Integer(string='weighing', related='test_scale_id.weighing', readonly=False)
Note: This process , making field is one time process.
after that you can use any field which is in your main model and you want to use in wizard you can get those fields by test_scale_id.any_of_your_field.

Odoo 10 : Removing a button from customer form view

I want to remove 'Unpublished on Website' button from customer form view.
This button is not part of form view so when i tried below code ,i got an error that element doesn't exist in parent view:
<xpath expr='//div[#class="oe_button_box"]//button[#name="website_publish_button"]' position='replace'>
<button type="object" name="callSurvey" icon="contacts_custom/static/description/survey.png" class="oe_stat_button">
<field string="Surveys" name="survey_count" widget="statinfo" modifiers="{'readonly': true}"/>
</button>
</xpath>
Then i tried to remove it using css. My css.css file :
button[name=website_publish_button]
{
display:none !important;
}
and template :
<openerp>
<data>
<!-- Adds all assets in Odoo -->
<template id="assets_backend" name="contacts_custom assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<!--These links will be called when loading your Odoo -->
<link rel="stylesheet" href="/contacts_custom/static/css/css.css"/>
</xpath>
</template>
</data>
</openerp>
But still button appears.Am i doing something wrong or Is there any other method to remove this button?
You could do it extending the view like this:
<record id="view_partners_form_website" model="ir.ui.view">
<field name="name">view.res.partner.form.website</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="website_partner.view_partners_form_website"/>
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<data>
<button name="website_publish_button" position="replace">
<button type="object" name="callSurvey" icon="contacts_custom/static/description/survey.png" class="oe_stat_button">
<field string="Surveys" name="survey_count" widget="statinfo" modifiers="{'readonly': true}"/>
</button>
</button>
</data>
</field>
</record>
Add a depends entry to the module website_partner to be able to inherit the view that add the button like the snippet above

How can add new fields inside crm.lead model via custom module inheriting crm.lead model in odoo 11?

According to requirements, need to customize Contact Us form which inserts into CRM.lead model (CRM module - Odoo 11)
I need to add additional fields in this model.
Issue! Already added new fields in this model but now showing on form view.
<record id="crm_case_form_view_leads_inherited" model="ir.ui.view">
<field name="name">crm.lead.form.lead.inherited</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<notebook position="inside">
<page string="Extra fields">
<group>
<field name="field_x"/>
<field name="field_y"/>
<field name="field_z"/>
</group>
</page>
</notebook>
</field>
class Lead(models.Model):
_inherit = 'crm.lead'
field_x = fields.Char(string='Field X)
field_y = fields.Text(string='Field Y')
field_z = fields.Char(string='Field Z')
Problem is not showing fields values on form view.
Check this link which appears as issue :
https://drive.google.com/file/d/1ZoqU2REHlpwJm_oQ7mXJmNJSqF8v22KA/view
<record id="crm_case_form_view_leads_inherited" model="ir.ui.view">
<field name="name">crm.lead.form.lead.inherited</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor" />
<field name="arch" type="xml">
<xpath expr="//page[#name='lead']" position="after">
<page string="Extra fields">
<group>
<field name="field_x"/>
<field name="field_y"/>
<field name="field_z"/>
</group>
</page>
</xpath>
</field>

Change the position of a smart button in ODOO

To change the position of the smart button whether it is inherited or newly created, it is a method to add this in the code.
Add this line in your code
<field name="priority" eval="99" />
Add this line like this:
<record id="view_custom_inherit" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="priority" eval="99" />
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
The priority in this code is which position that button should be placed

Configure Solr Index With File Metadata using TikaEntityProcessor & FieldStreamDataSource

I have created an index that pulls data from a SQL Server database using TikaEntityProcessor. The query associated with my configuration file pulls from a table containing file information, as well as the file content as a binary column. My index returns all fields from the database table in which I have configured, as well as the column for "text" that is the body of the file content. It correctly indexes the file text! However, the meta columns are not working! You can see I have a field for text/body, this works fine. However, I cannot get any metadata from the file such as last modified date or author.
Any suggestions would be greatly appreciated!!
data-config:
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://server;databaseName=db1;integratedSecurity=false"
user="user"
password="XXXXXX" convertType="false"
name="ds"/>
<dataSource name="fieldReader"
type="FieldStreamDataSource" />
<document name="tika">
<entity name="tika" pk="id" transformer="TemplateTransformer" dataSource="ds"
query="select id, title from myDatabaseTable">
<entity name="tika-test" processor="TikaEntityProcessor" dataSource="fieldReader"
dataField="tika.FileContent" format="text">
<field column="text" name="body"/>
<field column="Last-Modified" name="lastModified" meta="true" /> <!-- not working -->
</entity>
</entity>
</document>
</dataConfig>
schema:
<field name="id" type="integer" indexed="true" stored="true" />
<field name="body" type="text" indexed="true" stored="true" />
<field name="lastModified" type="text" indexed="true" stored="true" />
<field name="title" type="text" indexed="true" stored="true" />
Thanks!!

Resources