Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
21915 Näkymät
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
Hylkää

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?

Paras vastaus

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
Hylkää

It works...!!

Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
heinäk. 25
4665
2
jouluk. 24
7793
2
marrask. 24
28569
2
toukok. 24
7511
3
maalisk. 24
6929