Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
9754 Widoki

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
Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
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 :)

Najlepsza odpowiedź

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

Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
4
paź 20
8813
5
kwi 19
5775
1
kwi 16
3981
1
mar 15
8570
3
lut 24
10259