The great OpenERP 7 directory structure mystery - centos
I am currently deploying OpenERP 7 on a CentOS 6.4 machine.
I'm virtualizing the whole thing so that I can backup the whole system if I mess up.
Everything seems to be fine, I changed my models, my views, but it's been 2 days I've been banging my head against a seemingly impossible problem.
My deployment is for a book factory, so the product needed to be customized (number of pages, binding type , and so forth...)
In the new product view, I need something that can sum to fields x_colorpages and x_bwpages to populate a third field: x_totalpages. Easy huh?
I've got my XML , product.normal.form view based on the product.poduct object
When I change the value in "x_paginecolori" or "xpagineBN" it should automatically trigger the onchange function.
So I went in the product module code and coded my cal_change_event
In the python file product.py located in:
/usr/lib/python2.6/site-packages/openerp-7.0_20130524_231019-py2.6.egg/openerp/addons/account/product.py
def cal_change_event(self, cr, uid, ids, x_PagineColori, x_PagineBN):
res = {}
sum = 0
if not x_PagineColori:
return {}
else if not x_PagineBN:
return {}
else:
sum = x_PagineColori + x_PagineBN
res={'x_pagine':sum }
return {'value':res}
NO matter what i do , the onchange event will allways trigger a warning popup:
File "/usr/lib/python2.6/site-packages/openerp-7.0_20130524_231019-py2.6.egg/openerp/osv/osv.py", line 185, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
AttributeError: 'product.product' object has no attribute 'cal_change_event'
It seems to me that the function is not seen, where should I put it?
How can Product.Product not have this attribute if I placed it in the class inside product.py?
I grep'd the whole CENTOS installation in search for multiple instances of openerp , or to see if I missed something about product.py
It seems that the product.py is not the right file, even if I erase other On_change functions, nothing bad really happens.
But the directory must be right, because the error log gives me that same location in the debug popup window.
Should I be building a custom module fron scratch to make this work? Is it forbidden somehow to modify the standard product module?
Thanks in advance for any insight, my brain is defaulting on this one.
here is my Xml:
<?xml version="1.0"?>
<form string="Product" version="7.0">
<sheet>
<div>
<label for="x_partner2" string="Cliente Referente del prodotto"/>
<field name="x_partner2" />
</div>
<field name="image_medium" widget="image" class="oe_avatar oe_left"/>
<div class="oe_title">
<div class="oe_edit_only">
<label for="name" string="Product Name"/>
</div>
<h1>
<field name="name"/>
</h1>
<label for="categ_id" class="oe_edit_only"/>
<h2><field name="categ_id"/></h2>
<div name="options" groups="base.group_user">
<field name="sale_ok"/>
<label for="sale_ok"/>
</div>
</div>
<div class="oe_right oe_button_box" name="buttons">
</div>
<notebook>
<page string="Information">
<group>
<group>
<field name="type"/>
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
<field name="list_price"/>
</group>
<group>
<field name="default_code"/>
<label for="ean13"/>
<div name="ean">
<field name="ean13" placeholder="e.g. 5901234123457"/>
</div>
</group>
<group>
<field groups="product.group_product_variant" name="variants"/>
<field name="price_margin" groups="product.group_product_variant"/>
<field name="price_extra" groups="product.group_product_variant"/>
</group>
</group>
<field name="description" placeholder="describe the product characteristics..."/>
</page>
<page string="Dati del volume Universal Book">
<group>
<group>
<field name="x_DataCreazione" />
<field name="x_DataUltimaModifica" />
<field name="x_Autore" />
<field name="x_Larghezza"/>
<field name="x_Altezza" />
<field name="x_Dorso"/>
<field name="x_Rilegatura" />
<field name="x_volumiformati" />
</group>
</group>
<group>
<field name="x_PagineColori" on_change="cal_change_event(x_PagineColori,x_PagineBN)" />
<field name="x_PagineBN" on_change="cal_change_event(x_PagineColori,x_PagineBN)" />
<field name="x_pagine" />
</group>
<group>
<field name="x_prezzo" />
</group>
</page>
<page string="Copertina">
<group>
<group>
<field name="x_TipoCartaCopertina"/>
<field name="x_TipoStampaCopertina"/>
<field name="x_TipoFFR"/>
<field name="x_PlastificazioneCopertina" />
<field name="x_NumeroCopertinePerPagina" />
</group>
<group>
<field name="x_TipoCartaSovracopertina"/>
<field name="x_TipoStampaScopertina"/>
<field name="x_TipoFFRSovracopertina"/>
<field name="x_PlastificazioneSovracopertina"/>
</group>
</group>
<label for="x_aletta" string="Libro con alette?"/>
<field name="x_aletta" />
<label for="x_Note" string="Note"/>
<field name="x_Note" />
</page>
<page string="Margini">
<group>
<field name="x_pagriferimento"/>
<field name="x_MargineDestro"/>
<field name="x_MargineDestro"/>
<field name="x_MargineInferiore" />
<field name="x_MargSinistro" />
<field name="x_MargineSuperiore"/>
<field name="x_RiferimentoLIFRE" />
<field name="x_MergineSuperioreLIFRE" />
<field name="x_MargineInferioreLIFRE" />
</group>
</page>
<page string="Procurements" groups="base.group_user">
<group name="procurement">
<group name="general">
<field name="cost_method" groups="product.group_costing_method"/>
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
</group>
<group name="procurement_uom" groups="product.group_uom" string="Purchase">
<field name="uom_po_id"/>
</group>
</group>
<separator string="Description for Suppliers"/>
<field name="description_purchase" placeholder="This note will be displayed on requests for quotation..."/>
</page>
<page string="Inventory" groups="base.group_user">
<group name="inventory">
<group name="status" string="Status">
<field name="state"/>
<field name="product_manager"/>
</group>
<group name="Weights" groups="product.group_stock_packaging" string="Weights">
<field digits="(14, 3)" name="volume" attrs="{'readonly':[('type','=','service')]}"/>
<field name="weight" attrs="{'readonly':[('type','=','service')]}"/>
<field name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
</group>
</group>
</page>
<page string="Sales" attrs="{'invisible':[('sale_ok','=',False)]}">
<group name="sale">
<group string="Sale Conditions">
<label for="warranty"/>
<div>
<field name="warranty" class="oe_inline"/> months
</div>
</group>
<group groups="product.group_uos" string="Unit of Measure">
<field name="uos_id"/>
<field name="uos_coeff"/>
<field name="mes_type"/>
</group>
</group>
<field name="packaging" groups="product.group_stock_packaging">
<form string="Packaging" version="7.0">
<group col="4">
<field name="ean"/>
<field name="sequence" invisible="1"/>
<newline/>
<field name="qty"/>
<field name="ul"/>
<field name="weight_ul"/>
<separator colspan="4" string="Palletization"/>
<field name="ul_qty"/>
<field name="rows"/>
<field name="weight"/>
<separator colspan="4" string="Pallet Dimension"/>
<field name="height"/>
<field name="width"/>
<field name="length"/>
</group>
<separator colspan="4" string="Description"/>
<field name="name"/>
</form>
</field>
<separator string="Description for Quotations"/>
<field name="description_sale" placeholder="note to be displayed on quotations..."/>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
It's not forbidden to modify the standard modules, but it is generally recommended to write your own modules to extend OpenERP.
I don't know how much experience you've got with OpenERP (if you are new to OpenERP, the problem could be caused by very simple mistakes), so forgive me for assuming you are a newbie.
Have you restarted OpenERP and reinstalled the product module?
Is the cal_change_event() method defined in a class whose _name = "product.product" ?
Could you post your XML code? The problem could be nothing to do with your Python code.
All the code here works FINE. The problem seemed to be my CENTOS install.
This code works correctly on WINDOWS and a new XUBUNTU Machine I just made.
Unfortunately the reason why it didn't work in CentOS still eludes me.
I'm closing this topic, hopefully the code pf my .XML and .PY can be a useful template for all those who wish to have personalized fields in their products and have them interactively change. thanks Wenshan for your assistance, as you noticed in the beginning, nothing was wrong with the code.
Related
How to display your custom app on home page
I tried to make a menu for my custom app but it doesn't display to home page. Any idea on how to make it happen? I wanted to display my app beside to installed apps. I am using Odoo 14. This is my form: <record id="view_custom_module_form" model="ir.ui.view"> <field name="name">view.custom.module.form</field> <field name="model">custom.model</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Custom" create="false" delete="false" edit="false"> <sheet> <group> <group> <field name="name" readonly="1"/> <field name="number" readonly="1"/> </group> </group> </sheet> </form> </field> </record> <record id="action_custom_module" model="ir.actions.act_window"> <field name="name">Custom Module</field> <field name="type">ir.actions.act_window</field> <field name="res_model">custom.model</field> <field name="view_mode">form</field> <field name="view_id" ref="view_custom_module_form"/> </record> And this is my menu: <menuitem name="Custom" id="menu_custom_menu" sequence="1" web_icon="custom_module,static/description/icon.png" groups="base.group_user,base.group_partner_manager"/> <menuitem id="submenu_custom_menu" name="Custom" parent="menu_custom_menu" action="action_custom_menu" sequence="1"/> And I wanted to display my custom app icon here:
I already solved it. This is what I did to show my app. I put the sequence on it. Make sure you already make your form view so that your custom module will show up. <menuitem id="menu_custom_form_root" name="Custom FOrm" sequence="9"/> <menuitem id="menu_form" name="Forms" parent="menu_custom_form_root" action="action_forms" sequence="9"/>
How to solve"Uncaught TypeError: Cannot read property 'type' of undefined when adding button to tree view of Odoo"?
This is my code; I want to add it at the footer of the tree. <tree string="Generate Payment" create="false"> <group><field name="name"/> <field name="x_leave_generate"/> <field name="x_overtime_generate"/> <field name="x_attendance_generate"/> </group> </tree> <button name="method_name" string="Check" type="object" class="oe_button oe_form_button oe_highlight" />
If you are adding button in view it must be added in view like below. You can hader tag if you want to display in top of tree view. <tree string="Generate Payment" create="false"> <button name="method_name" string="Check" type="object" class="oe_button oe_form_button oe_highlight" /> <group> <field name="name"/> <field name="x_leave_generate"/> <field name="x_overtime_generate"/> <field name="x_attendance_generate"/> </group> </tree>
Is possible treeView inside treeView in odoo
i want to display treeview inside line_ids. look picture. group by is sale.order field /line sale.order.line/ How to decision?
Old fashoned tree view: To get this view you have to define action with view_type="tree" f. e. <record id="res_partner_action_form" model="ir.actions.act_window"> <field name="name">Partners</field> <field name="res_model">res.partner</field> <field name="view_type">tree</field> <field name="view_mode">tree,form</field> <field name="help" type="html"> <p class="oe_view_nocontent_create"> </p> <p> </p> </field> </record> Tree view definition looks the same as normal one. The diffrence is that here you can use parent_id. <tree string="Account Reports Hierarchy"> <field name="name"/> <field name="type"/> <field name="parent_id" invisible="1"/> <field name="account_report_id"/> </tree>
how to create wizard to copy an object many time?
I am beginner in OpenERP, I want to create a wizard to duplicate an object many time, which when i click on the button the wizard open a form the content if this form it's ( textbox + ok button) the textBox for to write how many time the wizard will call copy function to copy the object This is my class class immo_article(osv.osv): _name = "immo.article" _description = "immo article" _columns = { 'name':fields.integer('N d inventaire',required=True , size=10), } _defaults = { 'date_creation': fields.date.context_today, } immo_article() and this my view <record id="immo_article_form" model="ir.ui.view"> <field name="name">immo.article.form</field> <field name="model">immo.article</field> <field name="arch" type="xml"> <form string="article" > <button string="%(action_duplicate_object)d" type="action" name="duplicate.wiz"/> <field name="name" /> </form> </field> </record> <record id="immo_article_tree" model="ir.ui.view"> <record id="immo_article_tree" model="ir.ui.view"> <field name="name">immo.article.tree</field> <field name="model">immo.article</field> <field name="arch" type="xml"> <tree string="articles"> <field name="name" /> </tree> </field> </record> <record id="immo_article_form_act" model="ir.actions.act_window"> <field name="name">Article</field> <field name="res_model">immo.article</field> <field name="view_mode">tree,form</field> <field name="type">ir.actions.act_window</field> <field name="view_type">form</field> <field name="view_id" ref="immo_article_tree"/> <field name="help" type="html"></field> </record> and this my wizard .py class duplicate_wiz(osv.osv_memory): _name = 'duplicate.wiz' _description = 'duplicate wizard' _columns = { 'number_of_copies':fields.integer('Number of copies', size=2 , required=True), } _defaults = { 'number_of_copies': '0', } def duplicate_object(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids)[0] article_id = context['active_id'] try: number_of_copies = data['number_of_copies'] except: raise osv.except_osv(_('Error'), _('Trouble!')) return {'type': 'ir.actions.act_window_close'} duplicate_wiz() and this my wizard view <record id="dup_view" model="ir.ui.view"> <field name="name">duplicate.wizard</field> <field name="model">duplicate.wiz</field> <field name="priority">1</field> <field name="arch" type="xml"> <form string="Duplicate" version="7.0"> <group col="2"> <field name="number_of_copies"/> </group> <footer> <button name="duplicate_object" string="_Import" type="action" class="oe_highlight"/> <button string="Cancel" class="oe_link" special="cancel"/> </footer> </form> </field> </record> <record id="action_duplicate_object" model="ir.actions.act_window"> <field name="name">duplicater action</field> <field name="type">ir.actions.act_window</field> <field name="res_model">duplicate.wiz</field> <field name="view_type">form</field> <field name="view_mode">form</field> <field name="target">new</field> <field name="view_id" ref="dup_view"/> </record> </data> I know I have many errors in wizard code, because I don't know how to it and how I can call the wizard from the button, anyone can help me with this ?
I don't have time now to read all your code, but the button on immo.article.form should have action reference in name attribute, not in string: <button name="%(action_duplicate_object)d" type="action" string="A string"/>
how to add a field in res.partner in open erp
I'm new to OpenErp. I want to Add a new field "mother_name" in res.partner.So i have added the following code to res.partner.py In column's i have add like this _columns = { 'name': fields.char('Name', size=128, required=True, select=True), 'date': fields.date('Date', select=1), 'title': fields.many2one('res.partner.title', 'Title'), 'parent_id': fields.many2one('res.partner', 'Related Company'), 'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts', domain=[('active','=',True)]), # force "active_test" domain to bypass _search() override 'ref': fields.char('Reference', size=64, select=1), 'date_delivery': fields.date('Expected Delivery Date'), 'mother_ln': fields.char('Mother', size=64), . . . } Now in res_partner_view.xml . I'm using the following code <record id="view_partner_tree" model="ir.ui.view"> <field name="name">res.partner.tree</field> <field name="model">res.partner</field> <field eval="8" name="priority"/> <field name="arch" type="xml"> <tree string="Contacts"> <field name="name"/> <field name="function" invisible="1"/> <field name="phone"/> <field name="email"/> <field name="user_id" invisible="1"/> <field name="is_company" invisible="1"/> <field name="country" invisible="1"/> <field name="country_id" invisible="1"/> <field name="date_delivery"/> <field name="mother_ln"/> <field name="parent_id" invisible="1"/> </tree> </field> </record> <record id="view_partner_form" model="ir.ui.view"> <field name="name">res.partner.form</field> <field name="model">res.partner</field> <field eval="1" name="priority"/> <field name="arch" type="xml"> <form string="Partners" version="7.0"> <sheet> <field name="image" widget='image' class="oe_left oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/> <div class="oe_title"> <div class="oe_edit_only"> <label for="name"/> ( <field name="is_company" on_change="onchange_type(is_company)" class="oe_inline"/> <label for="is_company" string="Is a Company?"/>) </div> <h1> <field name="name" default_focus="1" placeholder="Name" /> </h1> <field name="parent_id" placeholder="Company" domain="[('is_company', '=', True)]" context="{'default_is_company': True, 'default_supplier': supplier}" attrs="{'invisible': [('is_company','=', True),('parent_id', '=', False)]}" on_change="onchange_address(use_parent_address, parent_id)"/> <!-- <field name="category_id" widget="many2many_tags" placeholder="Tags..."/> --> </div> <div class="oe_right oe_button_box" name="buttons"> </div> <group> <group> <label for="type" attrs="{'invisible': [('parent_id','=', False)]}"/> <div attrs="{'invisible': [('parent_id','=', False)]}" name="div_type"> <field class="oe_inline" name="type"/> </div> <label for="street" string="Address"/> <div> <field name="use_parent_address" class="oe_edit_only oe_inline" on_change="onchange_address(use_parent_address, parent_id)" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/> <label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/> <button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only" attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/> <field name="street" placeholder="Street..." attrs="{'readonly': [('use_parent_address','=',True)]}"/> <field name="street2" attrs="{'readonly': [('use_parent_address','=',True)]}"/> <div class="address_format"> <field name="city" placeholder="City" style="width: 40%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/> <field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}' on_change="onchange_state(state_id)" attrs="{'readonly': [('use_parent_address','=',True)]}"/> <field name="zip" placeholder="ZIP" style="width: 20%%" attrs="{'readonly': [('use_parent_address','=',True)]}"/> </div> <field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}' attrs="{'readonly': [('use_parent_address','=',True)]}"/> </div> </group> <group> <!-- We Don't require Job Position for Customer --> <!-- <field name="function" placeholder="e.g. Sales Director" attrs="{'invisible': [('is_company','=', True)]}"/> --> <field name="phone" placeholder="e.g. +32.81.81.37.00"/> <field name="mobile"/> <field name="fax"/> <field name="email" widget="email"/> <!-- <field name="title" domain="[('domain', '=', 'contact')]" options='{"no_open": True}' attrs="{'invisible': [('is_company','=', True)]}" /> --> </group> <field name="date_delivery"/> <field name="mother_ln"/> </group> . . . </record>
Better is you inherit that code and add your field rather doing changes to main code. for your py file class res_partner(osv.osv): _inherit= 'res.partner' _columns = { 'mother_ln': fields.char('Mother', size=64), 'father_name': fields.char('Father', size=64), # this is comment. -> you can add as many types of fields as you want - eg. char , # boolean, float, integer, one2many, many2one etc. } res_partner() for your xml file :- <record id="view_res_partner_inherited" model="ir.ui.view"> <field name="name">view.res.partner.inherited</field> <field name="model">res.partner</field> <field name="inherit_id" ref="base.view_partner_form" /> <field name="arch" type="xml"> <field name="date_delivery" position="after"> <field name="mother_ln" /> <field name="father_name" /> <!--comment- likewise this is your view, add all your fields here in view --> </field> </field> </record>