This question has been flagged
2 Replies
2735 Views

Hi everybody,

I am currently working on a project with OpenERP 7. I have already done a lot of things but I block in few points.

Someone can help me? I think it will not be hard for an expert. The questions are more like:

How can I link two fields in two different objects ( one of the two fields is an one2many). I can pay your help.

Thank you a lot.

Selverine

Avatar
Discard
Best Answer

Can you please elaborate your requirement so that it will be quite good to me to help you at my level best?

Avatar
Discard
Author Best Answer

Dear Navnath Desale,

Thank you for your answer.

I have three importantes questions:


First one:

I would like to add a new field in the sale.py : Table sale_order. This field will link to an purchase _order. It is why I add this in the python code

class sale_order(osv.osv):
_name = "sale.order"
_inherit = ['mail.thread', 'ir.needaction_mixin']
_description = "Sales Order"
 .  
 .
 .
_columns = {
    'name': fields.char('Order Reference', size=64, required=True,
        readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
      .
      .
      . 
    'link_Purchase': fields.many2one('purchase.order', 'Link Purchase'),
}

But it don't work. I have this error:

'NoneType' object has no attribute '_table' You know why please?


Second one :

Is it possible to print the result of an SQL queries? For exemple my SQL queries will send me the name of 10 products. I would like to have a tree with a line for each result. Is it possible? If yes how? With a field type function? How can I put in my field the names of the 10 products? How can I print it? For the moment I succeed in storing the result of my SQL queries in a field type text.

cr.execute('SELECT name from product_bat where name is not null')
res = cr.fetchall()
result['product_BAT'] = res

'product_BAT': fields.text('product.bat'),

<field name="product_BAT"/>

The problem is that I have the list of my result in one line, seperate by some coma.

name1,name2,name3


Third one:

I would like to know how is possible to get (or to link together) two fields in two differents tables?

To be more clear:

My first field (field1) is a one2many field. Table product.template. My second field (field2) is on the table sale.order.line.

The goal of this manipulation is to have the field1 (the one2many) for each product of the sale.order.line. Need I to declare my field2 as a one2many too? or can in make the link to say: My field 2 is my field 1?


You think you can help me? How many times you need?

Thank you a lot.

Selverine

Avatar
Discard

Yes...Of-course I can help you at my level best.please feel free to contact me on my email-id: desale.navnath@gmail.com

In your first question,You are getting this error due to missing dependency.Go to openerp.py file of sale module and in depends add purchase as an dependency.Restart your server and then try.You should not get above error.

Can you please provide me your files so that I can work on it to help you at my level best?

Author

Thanks a lot. I will send you an email right now.