Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
18554 มุมมอง

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
2990
2
มี.ค. 15
5052
1
มี.ค. 15
5554
1
พ.ย. 24
1632
4
พ.ค. 24
7426