跳至内容
菜单
此问题已终结
2 回复
9800 查看

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
8913
5
4月 19
5822
1
4月 16
4001
1
3月 15
8608
3
2月 24
10358