Skip to Content
Menu
This question has been flagged
2 Replies
20666 Views
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')
Avatar
Discard

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?

Best Answer

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.

Avatar
Discard

It works...!!

Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
25087
2
May 24
5519
3
Mar 24
4964
0
Mar 24
262
3
Feb 24
11421