It is currently Sat Feb 11, 2012 7:41 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [Solved] Bad inheritance in merge orders action
PostPosted: Tue Feb 09, 2010 5:35 pm 
Offline

Joined: Thu Oct 01, 2009 4:27 pm
Posts: 9
Hi,
I inherit "purchase.order.line" by adding my new field like this:

Code:
class purchase_order_line(osv.osv):
    _inherit = "purchase.order.line"
    _columns = {
         'myfield_id': fields.many2one('my_class','Field', required=True),
.......


Everything works fine, I've got a new field, I have to fill it before saving records (I added field in inherit xml view ).
Next I fill my purchase orders with two different products producing by the same supplier. So I've got two different purchase orders , each with one purchase order line.
Next I make merge orders action via "Action" --> "Merge Orders" , I've got one line in "Purchase Orders" and inside this purchase order two purchase order lines.
The problem is that after marge action I don't have my new field added in inheritance, field is empty (but is required).

Before :
Purchase Order (Supplier A)
|
|____> Purchase Order Line (with my new field)

Purchase Order (Supplier A)
|
|____> Purchase Order Line (with my new field)

After merge :

Purchase Order (Supplier A)
|
|____> Purchase Order Line (without my new field, field is empty)
|
|____> Purchase Order Line (without my new field, field is empty)

It looks like merge action gets objects not from my class but from parent class. Any ideas how to fix it ?

Trying to fix this problem I Also extended purchase.order class and overwrote it putting print "My statement" inside _get_order function like this:
Code:
class purchase_order(osv.osv):
    _inherit = "purchase.order"
    def _get_order(self, cr, uid, ids, context={}):
        print "My statement"
        result = {}
        for line in self.pool.get('purchase.order.line').browse(cr, uid, ids, context=context):
            result[line.order_id.id] = True
        return result.keys()


But there is no print during merge action , parent class function is invoked. Any ideas ?
Thanks in advance .


Last edited by tulator on Fri Feb 12, 2010 6:49 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Bad inheritance in merge orders action
PostPosted: Fri Feb 12, 2010 6:46 pm 
Offline

Joined: Thu Oct 01, 2009 4:27 pm
Posts: 9
Solved.
In purchase module, purchase/wizard/wizard_group.py in _merge_orders function I added :


Code:
line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id','
myfield_id'))


Now it works fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP