Odoo Help

0

I overrote a method and it was not called

By
Tarek Mohamed Ibrahim
on 5/28/15, 4:41 AM 595 views

Hi,

I inherited the class purchase_order and wrote my method _prepare_inv_line to override the one of the class, but when I ran the code it was not called.

The question is, why this method was not called,

second, how to override such functions ?


Here is my own method I inserted in the inherited class purchase_order


	def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None):
		res = super(purchase_order,self)._prepare_inv_line(cr, uid, account_id, order_line, context)
		line = self.pool.get('purchase.order.line').browse(cr,uid,order_line)
		if not line.order_id.requisition_id:
			""" get the account # defined as reserved for this department """
			account_obj = self.pool.get('account.account')
			acct_id = account_obj.search(cr,uid,[('department_id','=',line.order_id.department_id.id)])
			res['account_id'] = acct_id
		return res

I'm OpenERP 7.0

in this method if the PO is not linked to a Purchase Requisition then I have to get the account id from the chart of accounts that is related to the department of the user initiated the PO

This method has not been visited when I ran the code

thx in advance for help

Check the class instantiation at the end of the class. If your class is purchase_order then close it with an purchase_order()

Axel Mendoza
on 8/27/15, 10:05 PM

Check if the same method already overridden somewhere else.

Akhil P Sivan
on 8/28/15, 2:34 AM
0

Ghanshyam Prajapati

--Ghanshyam Prajapati--
1385
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 5/28/15, 6:15 AM

Hello Tarek,

please paste your code over here, so we can solve your exact problem.

thanks.

0
Kinner Vachhani
On 5/28/15, 9:47 AM

Check the followings 

* file not added in __init__.py

* class method signature different than base class method

To ensure your class is loaded put ipdb statement in class init method. 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/28/15, 4:41 AM
Seen: 595 times
Last updated: 8/28/15, 2:34 AM