Skip to Content
Menu
This question has been flagged
1 Reply
7254 Views

Guys, how can I import data from CSV file but if for example some lines contains data related to the same "order number"? 

Picture below should explain everything.


Same customer, multiple items. I would like to combine it into one single record.

| 143306 | 18-Sep-2015 | 18-Sep-2015 | 250869522623 Full Height Matrox G550 PCI Card F7011-0001G55MDDAP32DB,
 260747082667 Matrox G200 MMS Quad Display Graphics Card 4 DVI fp, 261084913104 NVidia NVS285 PCI-E x16 New Shape 128MB Low Profile Card+Dual DVI Splitter Cable | .....

Or maybe every record should contain a table (many2one fields)?

Going that way I added a class:

class item_list(models.Model):
_name = 'item.list'
_description = "Item list in record"
nitem_id = fields.Many2one('item_id')
nitem_title = fields.Many2one('item_title')
nquantity = fields.Many2one('quantity')
item_log_id = fields.Many2one('item_list','Product')
and in main class I added
items_list = fields.One2many('item.list','item_log_id', string="Items ordered ⇒")

   Now loading a data from CSV and still got nothing not even one item is added :(


Avatar
Discard
Best Answer

Dr Obx,

you can use the following format for your csv file to add the data if you are using systems default import functionality.

You don't need to give the order name again in every line, just change the product and quantity in every next line for same orders.:

Order Date,Order Reference,Supplier,Destination,Pricelist,Order Lines / Product,Order Lines / Quantity

2012-12-15,PO00008,ASUSTeK,Stock,Default Purchase Pricelist,ADPT,20

,,,,,CARD,30

,,,,,C-Case,40

2012-12-15,PO00009,Axelor,Stock,Default Purchase Pricelist,CD,5

,,,,,CPUa8,15

Hope this will help you

Avatar
Discard
Author

Hi Pawan, unfortunately I have no choice, CSV file comes from outside source so I prefer not to change anything (to be hones for me it doesn't matter but third person can have a problem with it) so better if it will as it is (CSV file). As we spoken earlier, I just importing ready (downloaded) CSV file without change option :)

then you have to write a customized functionality for reading a csv file and import data from it for creating your orders...

Author

Should be data written into the table into class which inherits from parent class ?

Author

or is it there but need to be loaded into the table ?

Author

Studying examples ... still not found how to ...

where are you stucked??

Author

It's difficult to say where i'm not stucked :) I just need one more time to do everything step by step with you i guess ;) First thing: I created a class order_lines and inside this class I have item_id, item_title, quantity, sale_price. However I found that is a very bad idea because a lot of other things require item_id for example. So once I update module getting a lot of errors :) However, sorted it out but still when I'm trying to load CSV it won't load anything into those fields. Also, getting errors like:

2015-09-23 09:38:13,562 4533 WARNING GNG openerp.fields: Field order.lines.item_order_line with unknown comodel_name 'iprodstep_log'
2015-09-23 09:38:13,562 4533 WARNING GNG openerp.fields: Field order.lines.item_title with unknown comodel_name 'iprodstep_log'
2015-09-23 09:38:13,562 4533 WARNING GNG openerp.fields: Field order.lines.item_id with unknown comodel_name 'iprodstep_log'
2015-09-23 09:38:13,563 4533 WARNING GNG openerp.fields: Field order.lines.sale_price with unknown comodel_name 'iprodstep_log'
2015-09-23 09:38:13,563 4533 WARNING GNG openerp.fields: Field order.lines.sales_record_number with unknown comodel_name 'iprodstep_log'
2015-09-23 09:38:13,800 4533 WARNING GNG openerp.fields: Field product.line.state with unknown comodel_name 'iprodstep_log'
I know why, baceuse in this class 'order_lines' I should create a fields like: item_id = fields.Char() but I tried with item_id = fields.Many2one(). So once I add:
#----------------- Order lines ----------------
class order_lines(models.Model):
	_name = 'order.lines'
	_description = 'Order lines'
	
	item_order_line = fields.Many2one('iprodstep_log','Item')
	item_id = fields.Char()
	item_title = fields.Char()
	quantity = fields.Integer()
	sale_price = fields.Char()

	
#----------------- Main class -----------------    
class iprodstep_log(models.Model):
	_name = 'iprodstep.log'
	_description = 'iprodstep log'
	_inherit = ['ir.needaction_mixin','order.lines']

#------------------ Sub table -----------------
	order_line = fields.One2many('order.lines','item_order_line',string='item lines')

#--------- Sub table related fields -----------
	item_id = fields.Char('Item Number')
	item_title = fields.Char('Item Title')
	quantity = fields.Integer('Quantity')
	sale_price = fields.Char('Sale price')

I have a table but how can i write some data from one class to another ? Tried using write:
			record.write({'order_lines.item_id': 'item_id'})
2015-09-23 11:29:03,314 6987 WARNING GNG openerp.models: iprodstep.log.write() with unknown fields: order_lines.item_id
Author

New week, new, ideas, new challenges ! Any thoughts how to solve this issue ??

New week, new ideas, new challenges, and new solution.... new problem.... ;)

anyway, please provide a brief what has been done till now in that....

Author

Hi Pawan, been busy last week, so I had no time to try. This week I will buid custom import module and I hope it will work :):)

Related Posts Replies Views Activity
4
Oct 20
6593
0
Oct 15
2639
3
Feb 24
8438
3
May 24
13829
1
Nov 23
902