Odoo - Override default company view - odoo

I am using odoo 10e. I want to change companies form and tree view. So i was following this tutorial
Help
and this is what i tried but its not working
<odoo>
<data>
<record model="ir.ui.view" id="view_crm_lead_form_inherited">
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute name="string">Custodian Name</attribute>
</field>
</field>
</record>
</data>
</odoo>
I see that company model have a field nameand i am trying to override default label of name fields.
Edit
__manifest__.py
# -*- coding: utf-8 -*-
{
'name': "Test",
'summary': """
Short (1 phrase/line) summary of the module's purpose, used as
subtitle on modules listing or apps.openerp.com""",
'description': """
Long description of module's purpose
""",
'author': "Ancient",
'website': "http://www.google.com",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/odoo/addons/base/module/module_data.xml
# for the full list
'category': 'Accounting',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['base', 'mail'],
# always loaded
'data': [
'security/ir.model.access.csv',
'security/amgl_security.xml',
'views/views.xml',
'views/customer.xml',
'views/dashboard.xml',
'views/products.xml',
'views/order.xml',
'views/order_line.xml',
'views/metal_movement.xml',
'views/possible_solutions.xml',
'views/possible_reasons.xml',
'views/pending_accounts.xml',
'views/dealer.xml',
'emailTemplates/mmr_create_mail.xml',
'emailTemplates/reject_mmr_email.xml',
'emailTemplates/mmr_approval_complete.xml',
'emailTemplates/mmr_approve_reject_button.xml',
'report/metal_movement_template.xml',
'report/metal_movement_view.xml',
'views/res_company.xml'
],
'qweb': [
"views/colspan.xml",
],
# only loaded in demonstration mode
'demo': [
'demo/demo.xml',
'demo/customer_view.xml'
]
}

Here the important part of the origin view:
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1>
<field name="name" class="oe_inline"/>
</h1>
<label for="rml_header1" class="oe_edit_only"/>
<h3>
<field name="rml_header1" placeholder="e.g. Global Business Solutions"/>
</h3>
</div>
You have to change the label, because the field label, which you try to override, is never used.
Following should work:
<label for="name" position="attributes">
<attribute name="string">Custodian Name</attribute>
<attribute name="for" />
</label>

Related

Display a field in the homepage odoo

I have created a module in odoo with a model called "product" and a string field called "formelab" , I want to display this "formelab" field just under the price on the product sheet.
I want to display "ABCCCC" on the PROD sheet under "$1.00"
that's the product_template.xml in the views folder
``
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="formelab_ref_id_form" model="ir.ui.view">
<field name="name">access.product.view.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='type']" position="after">
<field name="formelab_ref"/>
</xpath>
</field>
</record>
</odoo>
and that's the product.py in the models folder
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class product(models.Model):
_inherit = 'product.template'
formelab_ref = fields.Char("Formelab")
``
You need to alter the products_item template.
The following code add the formelab_ref value after the priceCurrency span:
<template inherit_id="website_sale.products_item" id="daz">
<xpath expr="//span[#itemprop='priceCurrency']" position="after">
<span t-field="product.formelab_ref"/>
</xpath>
</template>

Odoo statusbar widget for project.project

i'm trying to add a field to define statuses of project.project like:
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class Project(models.Model):
_inherit = 'project.project'
_name = 'project.project'
state = fields.Selection(
[('open', 'Open'), ('closed', 'Closed'), ('sleep', 'Sleep')],
string='Status',
default='open'
)
Add added to the view in a heritage:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="edit_project" model="ir.ui.view">
<field name="name">project.project.form</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<field name="state" widget="statusbar" statusbar_visible="open,closed,sleep" />
</xpath>
</field>
</record>
</odoo>
But the field is displayed like a span in the header.
I tried everything described in the documentation and in base of other usages but with this in particular is not working and i don't know why. Please help!
Well, after trying everything for some ultra strange reason it work with no change.

getting error like relation "_unknown" does not exist?

I have created one model, It contain 2 fields and one grid view. So I am trying to many2one for one field to create new id. Please let me know where i am making the mistake ?
.py code is here
from openerp.osv import fields, osv
class agile_portfolio(osv.Model):
_name = "agile.portfolio"
_rec_name = 'epic_owner'
_columns = {
'name': fields.char('Asset Name',),
'epic_owner':fields.many2one('Agile.assetid.name','Asset ID'),
'strat_id1' : fields.one2many('portfolio.grid','strat_id','Strategy Name'),
}
agile_portfolio()
class portfolio_grid(osv.Model):
_name = 'portfolio.grid'
_columns = {
'name' : fields.char('Part'),
'strat_code' : fields.char('Code'),
'strat_quty' : fields.char('Quantity '),
'strat_uom' : fields.char('UoM'),
'strat_id': fields.many2one('agile.portfolio','Strat Id'),
}
portfolio_grid()
class assetid_name(osv.Model):
_name = 'assetid.name'
_rec_name = 'asst_id'
_columns = {
'asst_id' : fields.char('Asset_ID'),
}
assetid_name()
.xml code is here
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--Portfolio View-->
<record id="agile_portfolio_form" model="ir.ui.view">
<field name="name">agile.portfolio.form</field>
<field name="model">agile.portfolio</field>
<field name="arch" type="xml">
<form string="AssetConfig">
<group>
<group>
<field name="name"/>
</group>
<group>
<field name="epic_owner"/>
</group>
</group>
<notebook>
<page string="Part Name">
<field name="strat_id1">
<form string="Part Name">
<group>
<field name="name"/>
<field name="strat_code"/>
<field name="strat_quty"/>
<field name="strat_uom"/>
</group>
</form>
<tree string="Part Name">
<field name="name"/>
<field name="strat_code"/>
<field name="strat_quty"/>
<field name="strat_uom"/>
</tree>
</field>
</page>
</notebook>
</form>
</field>
</record>
<record id="agile_portfolio_action" model="ir.actions.act_window">
<field name="name">AssetConfigs</field>
<field name="res_model">agile.portfolio</field>
<field name="view_type">form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Click to create a new portfolio</p>
</field>
</record>
<!--side menu's-->
<menuitem id="asset_config" name="AssetConfigs"/>
<menuitem id="portfolio_menu" name="AssetParts" parent="asset_config"/>
<menuitem id="portfolio_nxt_menu" name="AssetParts" parent="portfolio_menu" action="agile_portfolio_action"/>
</data>
</openerp>
openerp.py
{
'name': 'Agile',
'version':'1.0',
'description': """
Agile Methodology
- Portfolios
- Programs
- Projects
""",
'author': 'Suraj',
'depends': ['base_setup',],
'data': ['agile_view.xml',],
'installable': True,
'auto_install': False,
}
I think you have given the wrong model name in following field.
'epic_owner':fields.many2one('Agile.assetid.name','Asset ID')
Here instead of "Agile.assetid.name" you have to give "assetid.name" if you want to manage M2O of last model "assetid.name". I think no model have capital letter.
I think this will resolve your issue.

How to upload images in tree view and display it in the tree or list view in Openerp 7 or Odoo

I have used the below code and on clicking on save. It saves the file but on clicking on the saved file. It is downloading it with a bin file format.
I have 2 doubts:
How do I download it using the same filename and extension that was uploaded.
How can I view all the images in the tree view from where it was uploaded. Using widget="image" does not work.
The openerp.py file:
{
'name' : 'Vyas File Upload Demo',
'version' : '0.1',
'category' : 'Demo',
'description' :
"""
Module to test the working of File upload and download in Openerp 7
""",
'author' : 'Vyas Senthil',
'license' : 'AGPL-3',
'depends' : [],
'init_xml' : [],
'demo_xml' : [],
'update_xml' : ['file_upload_demo_view.xml'],
'active': False,
'installable': True,
}
file upload demo.py [Python file]:
from osv import osv,fields
from datetime import date,datetime
from openerp import netsvc
from openerp import SUPERUSER_ID
from openerp.tools.translate import _
from operator import itemgetter
import base64
import time
import re
import psycopg2 as psy
import sys
import pprint # To print python objects in a readable format , use "pprint.pprint(obj or dictionary)".
import pdb # To debug python files. Use pdb.set_trace()
class manage_inspection(osv.osv):
''' Inspection module'''
_name = 'manage.inspection'
_columns = {
'name': fields.char('Inspection Number',required=True), # Inspection Number
'file_upload_demo_grid': fields.one2many('file.upload.demo','manage_inspection_id', 'File upload Grid'),
}
class file_upload_demo(osv.osv):
#class to maintain plant type
_name = 'file.upload.demo'
def _get_contract_file_name(self, cr, uid, ids, field_name, arg, context=None):
''' To set the name_filename field'''
result = {}
for product_data in self.browse(cr, uid, ids, context=context):
result[product_data.id] = product_data['file_path']
return result
return result
_columns = {
'image_upload': fields.binary(string='Image Upload new'),
'file_path': fields.char('File Name and Extension', size=128),
'name_filename':fields.function(_get_contract_file_name, type="char", size=255, method=True, string="File Name"),
'manage_inspection_id': fields.many2one('manage.inspection','Manage Inspection Id'), # Connection to Parent form.
}
file_upload_demo()
file_upload_demo_view.xml [XML file]:
<?xml version="1.0" ?>
<openerp>
<data>
<!-- Top Menu -->
<menuitem name="Vyas File Upload Demo"
id="file_upload_demo_top_menu"
sequence="32"/>
<!-- Side Menu Heading -->
<menuitem name="File Upload Demo"
id="file_upload_demo_side_heading"
parent="file_upload_demo_top_menu"
sequence="1"/>
<!-- inspection form view -->
<record model="ir.ui.view" id="view_file_upload_demo_form">
<field name="name">manage.inspection.form</field>
<field name="model">manage.inspection</field>
<field name="arch" type="xml">
<form string="Manage Inspection" version="7.0">
<!-- File Upload method -->
<field name="name" placeholder="Inspection Number" style="width:30%%" />
<!-- Grid - Upload Photos -->
<field name="file_upload_demo_grid" />
</form>
</field>
</record>
<!-- file_upload_demo tree view -->
<record model="ir.ui.view" id="view_file_upload_demo_tree">
<field name="name">file.upload.demo.tree</field>
<field name="model">file.upload.demo</field>
<field name="arch" type="xml">
<tree string="file upload demo" editable="top">
<!-- File Upload method -->
<field name="file_path" />
<field name="image_upload" filename="file_path" />
</tree>
</field>
</record>
<!-- action menu -->
<record model="ir.actions.act_window" id="action_upload_files_demo">
<field name="name">Inspection </field> <!-- view label -->
<field name="res_model">manage.inspection</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Side menu to open Manage Sales Invoice -->
<menuitem
name="Upload Files Demo"
id="upload_file_demo"
parent="file_upload_demo_side_heading"
sequence="3"
action="action_upload_files_demo"/>
</data>
</openerp>
look for Document button in project module this is allow you to attach multiple attachment and view them it tree , view the most beautiful thing that is preserve your attachment name and extension (try to do like it )
Note:
this attachment can be image or any type of attachment

Error occurred while validating the field(s) arch: Invalid XML for View Architecture

I try to create a module in OpenERP 7 , but I have this error "Error occurred while validating the field(s) arch: Invalid XML for View Architecture! "
I spend many hours but i can resolve it.
My code is:
init.py
import ig_nomfurn
openerp.py
{
'name': 'ig_nomfurn',
'version': '1.0',
'category': 'Generic Modules/Others',
'description': """
Partea de infogest transcrisa in OpenERP
========================================
Porteaza o partea din functiunile infogest in OpenERP
""",
'author': 'bogdan # nvncompany.ro',
'depends': ['base'],
'data': [
'ig_nomfurn_view.xml',
],
'installable': True,
'auto_install': False,
}
ig_nomfurn.py
from openerp.osv import fields, osv
class ig_nomfurn(osv.osv):
_name = 'ig.nomfurn'
_description = "nomfurn"
_columns = {
'name': fields.char('Name', size=8),
}
ig_nomfurn_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem id="ig_openerp_main"
name="Ig OpenERP"/>
<menuitem id="ig_openerp"
name="IG OpenERP"
parent="ig_openerp_main"/>
<record id="view_ig_nomfurn" model="ir.ui.view">
<field name="name">ig.nomfurn.form</field>
<field name="model">ig.nomfurn</field>
<field name="arch" type="xml">
<form string="Create New Dashboard" version="7.0">
<group colspan="4">
<field name="name"/>
</group>
</form>
</field>
</record>
<record id="action_ig_nomfurn" model="ir.actions.act_window">
<field name="name">View Boars</field>
<field name="res_model">ig.nomfurn</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_ig_nomfurn"/>
<field name="target">new</field>
</record>
<menuitem action="action_ig_nomfurn"
id="ig_nomfurn"
name="Nomfurn"
parent="ig_openerp"
/>
</data>
</openerp>
cant find any issues.please try by adding ig_nomfurn() at the end of the class.