Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
21926 Lượt xem
class sale_customer(models.Model):
_inherit='res.partner'
pan_number=fields.Char(string='PAN Number')
vat_number = fields.Char(string='VAT Number')

class sales_ext_invoice(models.Model):
_inherit = 'account.invoice'
sno = fields.Char(index=True,string='S.O No.')
payment_type = fields.Selection(
[('not_started', '--Select Payment Type--'), ('cash', 'Cash'), ('cheque', 'Cheque'), ('credit', 'Credit'),
('others', 'Others')], default='not_started')

vehicle_no = fields.Char(string='Vehicle No')
pan_num=fields.Char(string="PAN Number",related='partner_id.pan_number', store=True,)
created_by = fields.Many2one('hr.employee', string='Bill Prepared By')
Ảnh đại diện
Huỷ bỏ

Please describe your problem a little more. Does this keyerror happen on installing the module? Or when uninstalling? Or only when you access a model? Can you also post the full stacktrace?

Câu trả lời hay nhất

It's very simple, if you use a related field you need to append the modul in the manifest file, where the related field is coming from.

example:

you related order_id from module 'sale', just add 'sale' as depends in your module manifest file.

Ảnh đại diện
Huỷ bỏ

It works...!!

Câu trả lời hay nhất

After searching the code of Odoo10 for field = target._fields[name] I noticed that there is only one occurence. It is in the odoo/fields.py file in the method _setup_related_full. 

Now that we know this, we can safely say that the problem is with your related field.

Are you sure that the field pan_number was successfully created? (Quick test if you have sql access: SELECT pan_number FROM res_partner LIMIT 1;)

If column not found: Restart server, try to update your module, if installing/updating is the action that is throwing the error, comment the pan_num field in account.invoice, your module should install/update properly, now the field pan_number should be in db; You can test this again with the previous SQL-query.
Uncomment the related field, restart server, update module.


If the column was found we will probably need some more info as to what you were trying to do/achieve.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
4670
2
thg 12 24
7798
2
thg 11 24
28577
2
thg 5 24
7516
3
thg 3 24
6938