Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
18587 Представления

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.')

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
февр. 24
3020
2
мар. 15
5066
1
мар. 15
5579
1
нояб. 24
1651
4
мая 24
7461