コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
18578 ビュー

Hi, I have this sample code in my file procurement.py :

class procurement_order(models.Model):

_inherit = 'procurement.order'

analytic_account_id = fields.Many2one('account.analytic.account', string='Compte Analytique')

But i can't load my module on my server because there is this error :

AttributeError: 'module' object has no attribute 'Many2one'

アバター
破棄

Have you imported models at the top of your Python file? from openerp import models, fields, api

著作者

Yes, exactly with this : "from openerp import models, fields, api, _"

show us the file with import statement.

最善の回答

AttributeError: 'module' object has no attribute 'Many2one'

from odoo import fields, models, api

class SaleOrderSeries(models.Model):
_name = "sale.order.series"
_description = "Sale Order Series Initialisation"

series_code = fields.Char(string="Series Code")
series_desc = fields.Char(string="Series Description")

code = fields.Many2One('category',string="catcode")


アバター
破棄
最善の回答

For me works fine in Odoo 8 this way:

from openerp import models, fields, api, _

class res_partner(models.Model):

    _inherit = 'res.partner'

    _description = 'Add a second salesperson to the client view'


    second_salesperson = fields.Many2one('res.users', string='Salesperson 2', help='Add a second Salesperson to client form view.')

アバター
破棄
関連投稿 返信 ビュー 活動
1
2月 24
3011
2
3月 15
5061
1
3月 15
5573
1
11月 24
1648
4
5月 24
7444