跳至內容
選單
此問題已被標幟
2 回覆
9833 瀏覽次數

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
頭像
捨棄
最佳答案

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

So it is working now?

作者

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

最佳答案

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

相關帖文 回覆 瀏覽次數 活動
4
10月 20
9016
5
4月 19
5899
1
4月 16
4094
1
3月 15
8679
3
2月 24
10455