Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

sales module , customization Sales Management

By
sanaa tayb
on 6/2/13, 7:37 PM 2,561 views

hello everyone , i'm trying to customize the Sales Management module ... Actually i've already created another module where i can manage a list of patients , i want in my Sales Management module to put a list of patients in the place of customers ...

i tried this :

ventes.py

# -*- coding: utf-8 -*-
##############################################################################

##############################################################################
from osv import fields,osv
import time
from datetime import datetime
from tools.translate import _

class ventes(osv.osv):
    _name = 'sale.shop'
    _inherit='sale.shop'
    _columns = {
      'prenom': fields.many2one('patient','Patient', required=True),
    }
ventes()

in ventes_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
    <record model="ir.ui.view" id="view_sales_inherit">
        <field name="name">sale.order.tree.inherit</field>
        <field name="model">sale.order</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="sale.view_order_form">form</field>
        <field name="arch" type="xml">
            <field name="name" position="after">
                <label for="prenom" class="oe_edit_only"/>
                <h1><field name="prenom"/></h1>
            </field>

            <field name="partner_id" position="replace"/>
        </field>
    </record>   
 </data>
</openerp>

when i install the module i get this error while i want to create a new sale Order :

View error

Can't find field 'prenom' in the following view parts composing the view of object model 'sale.order':
* sale.order.tree.inherit

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model
0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 6/2/13, 7:49 PM

you have defined the field prenom in the model ventes (which extends sale.shop).

In the view, you say you use sale.order, and try to look for the field.

You have to change the model which ventes is extending (so change sale.shop to sale.order), or change the view where you want to add the new field.

Another thing, you do not have to define _name in a module which extends another module.

I made the changes you suggested but still not working , Plzz i really need help :s

sanaa tayb
on 6/2/13, 8:24 PM

So it is working now?

patrick
on 6/5/13, 4:43 AM

Yes it did work .. Thank you very much for your help :)

sanaa tayb
on 6/5/13, 8:38 AM
2
Dharmesh Rathod
On 6/3/13, 3:50 AM

Hi,

You are inheriting object of "sale.shop" instead of "sale.order". And you are inheriting view of "sale.order" object.

"prenom" field seems not added into "sale.order" so it is raising an error.

class ventes(osv.osv):
_inherit='sale.order'
_columns = {
'prenom': fields.many2one('patient','Patient', required=True),
}
ventes()

And no need to use "_name" attribute again when you are inheriting existing object.

Email : info@acespritech.com
Skype : acespritech
Blog : acespritechblog.wordpress.com

Hii, i made those changes and still the module is not working , do you think that the XML file is OK?? Plz answer me

sanaa tayb
on 6/3/13, 10:11 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/2/13, 7:37 PM
Seen: 2561 times
Last updated: 3/16/15, 8:10 AM