Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
9755 Vistas

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
Avatar
Descartar
Mejor respuesta

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.

Avatar
Descartar
Autor

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

So it is working now?

Autor

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

Mejor respuesta

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

Avatar
Descartar
Autor

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

Publicaciones relacionadas Respuestas Vistas Actividad
4
oct 20
8814
5
abr 19
5775
1
abr 16
3981
1
mar 15
8570
3
feb 24
10260