2015-02-05 5 views
1

Я начинаю работать в Odoo v8.0. Я хочу добавить настраиваемое поле в модуль «продажа». Ошибка «Поле type_customer не существует»Odoo 8: добавьте настраиваемое поле в любой модуль

Итак, мой код здесь.

__init__.py:

from . import modify_type_quotation 

__openerp__.py:

{ 
     'name' : "Modify report template", 
     'description' : """Modify report template for Quotation/Sale report""", 
     'author' : "Nhu Van Tran", 
     'category' : "Tools", 
     'depends' : ['sale'], 
     'data' : ['modify_create_quotation.xml'], 
     'demo' : [], 
     'installable' : True, 
    } 

modify_type_quotation.py:

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

from openerp import models, fields 

class modify_print_content(models.Model): 

    _inherit = "sale.order" 
    _description = "Modify Print Content" 

    type_customer = fields.selection([ 
       ('Commercial', 'Commercial Customer'), 
       ('Residential', 'Risidential Customer'), 
       ], string = "Type of Customer", help = "Type of Customer", default = "Commercial", required = True) 

и modify_create_quotation.xml:

<?xml version="1.0" encoding="utf-8"?> 
    <openerp> 
     <data> 
      <record model = "ir.ui.view" id = "modify_view_sale"> 
      <field name ="name">sale.order.form</field> 
      <field name = "model">sale.order</field> 
      <field name = "inherit_id" ref="sale.view_order_form"></field> 
      <field name="arch" type="xml"> 
       <xpath expr="/form/sheet/group/group[2]/field[@name='client_order_ref']" position="after"> 
        <field name="type_customer">Type customer</field> 
       </xpath> 
      </field> 
      </record> 
     </data> 
    </openerp> 

ответ

1

Я думаю, что ошибка fields.selection, где вы сделали 's' в нижнем регистре, и это может быть ошибкой.

type_customer = fields.Selection([ 
       ('Commercial', 'Commercial Customer'), 
       ('Residential', 'Risidential Customer') 
       ], string = "Type of Customer", help = "Type of Customer", default = "Commercial", required = True) 

Удостоверьтесь, что вы перезагрузили свой сервер-оду, чтобы эти вещи вступили в силу.

1

Ваше поле в XPath может быть короче:

<xpath expr="/form/sheet/group/group[2]/field[@name='client_order_ref']" position="after"> 
     <field name="type_customer"/> 
    </xpath> 

Я не знаю, если это проблема, но добавление фильма параметра к объявлению selectionfield:

type_customer = fields.selection([ 
       ('Commercial', 'Commercial Customer'), 
       ('Residential', 'Risidential Customer'), 
       ], "Type of Customer", help = "Type of Customer", default = "Commercial",select=True, required = True) 

, и я думаю, решение могло бы быть таким: это добавило бы поля в sale.order вместо того, чтобы просто наследовать поля, которые у него уже есть

_name = "sale.order" 
_inherit = "sale.order" 
Смежные вопросы