Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
21909 Vizualizări
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')
Imagine profil
Abandonează

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?

Cel mai bun răspuns

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.

Imagine profil
Abandonează

It works...!!

Cel mai bun răspuns

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.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iul. 25
4662
2
dec. 24
7790
2
nov. 24
28567
2
mai 24
7507
3
mar. 24
6928