Add module product_variant_csv_import

This commit is contained in:
Alexis de Lattre
2014-12-15 18:45:38 +01:00
parent b54b69d48f
commit 6a0d9043a2
7 changed files with 142 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Product Variant CSV Import module for Odoo
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import product

View File

@@ -0,0 +1,40 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Product Variant CSV Import module for Odoo
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Product Variant CSV Import',
'version': '0.1',
'category': 'Barroux',
'license': 'AGPL-3',
'summary': 'Add menu entry to allow CSV import of templates with variants',
'description': """
This module adds a menu entry in *Sales > Configuration > Product Categories and attributes > Product Template CSV Import", that will work with the import of CSV file product.template.csv that contains variants.
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['product'],
'data': ['product_view.xml'],
}

View File

@@ -0,0 +1,31 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Product Variant CSV Import module for Odoo
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class ProductProduct(models.Model):
_inherit = 'product.product'
attribute_value_ids = fields.Many2many(readonly=False)
# In the "product" module, attribute_value_ids is Readonly=True
# but this blocks the import of products template with variants via CSV

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="product_template_special_context_action" model="ir.actions.act_window">
<field name="name">Product Template CSV Import</field>
<field name="res_model">product.template</field>
<field name="view_mode">tree,form</field>
<field name="context">{"create_product_variant": True}</field>
</record>
<menuitem id="product_template_special_context_menu"
action="product_template_special_context_action" parent="product.prod_config_main"
groups="base.group_no_one" sequence="100"/>
</data>
</openerp>

View File

@@ -0,0 +1,3 @@
id,name
test.attribute_pointure,Pointure
test.attribute_cuir,Cuir
1 id name
2 test.attribute_pointure Pointure
3 test.attribute_cuir Cuir

View File

@@ -0,0 +1,8 @@
id,attribute_id/id,name
test.pointure_33,test.attribute_pointure,Pointure 33
test.pointure_34,test.attribute_pointure,Pointure 34
test.pointure_35,test.attribute_pointure,Pointure 35
test.pointure_36,test.attribute_pointure,Pointure 36
test.pointure_37,test.attribute_pointure,Pointure 37
test.cuir_noir,test.attribute_cuir,Cuir noir
test.cuir_marron,test.attribute_cuir,Cuir marron
1 id attribute_id/id name
2 test.pointure_33 test.attribute_pointure Pointure 33
3 test.pointure_34 test.attribute_pointure Pointure 34
4 test.pointure_35 test.attribute_pointure Pointure 35
5 test.pointure_36 test.attribute_pointure Pointure 36
6 test.pointure_37 test.attribute_pointure Pointure 37
7 test.cuir_noir test.attribute_cuir Cuir noir
8 test.cuir_marron test.attribute_cuir Cuir marron

View File

@@ -0,0 +1,13 @@
id,name,type,weight,weight_net,product_variant_ids/default_code,product_variant_ids/ean13,product_variant_ids/attribute_value_ids/id
test.sandale1,Sandale 1,product,0.723,0.723,SANDAL-1-N-33,3518378100019,"test.pointure_33,test.cuir_noir"
,,,,,SANDAL-1-M-33,3518378100033,"test.pointure_33,test.cuir_marron"
,,,,,SANDAL-1-N-34,3518378100057,"test.pointure_34,test.cuir_noir"
,,,,,SANDAL-1-M-34,3518378100071,"test.pointure_34,test.cuir_marron"
,,,,,SANDAL-1-N-35,3518378100095,"test.pointure_35,test.cuir_noir"
,,,,,SANDAL-1-M-35,3518378100118,"test.pointure_35,test.cuir_marron"
test.sandale2,Sandale 2,product,0.760,0.760,SANDAL-2-N-33,3518378100132,"test.pointure_33,test.cuir_noir"
,,,,,SANDAL-2-M-33,3518378100156,"test.pointure_33,test.cuir_marron"
,,,,,SANDAL-2-N-34,3518378100699,"test.pointure_34,test.cuir_noir"
,,,,,SANDAL-2-M-34,3518378100705,"test.pointure_34,test.cuir_marron"
,,,,,SANDAL-2-N-35,3518378100712,"test.pointure_35,test.cuir_noir"
,,,,,SANDAL-2-M-35,3518378100767,"test.pointure_35,test.cuir_marron"
1 id name type weight weight_net product_variant_ids/default_code product_variant_ids/ean13 product_variant_ids/attribute_value_ids/id
2 test.sandale1 Sandale 1 product 0.723 0.723 SANDAL-1-N-33 3518378100019 test.pointure_33,test.cuir_noir
3 SANDAL-1-M-33 3518378100033 test.pointure_33,test.cuir_marron
4 SANDAL-1-N-34 3518378100057 test.pointure_34,test.cuir_noir
5 SANDAL-1-M-34 3518378100071 test.pointure_34,test.cuir_marron
6 SANDAL-1-N-35 3518378100095 test.pointure_35,test.cuir_noir
7 SANDAL-1-M-35 3518378100118 test.pointure_35,test.cuir_marron
8 test.sandale2 Sandale 2 product 0.760 0.760 SANDAL-2-N-33 3518378100132 test.pointure_33,test.cuir_noir
9 SANDAL-2-M-33 3518378100156 test.pointure_33,test.cuir_marron
10 SANDAL-2-N-34 3518378100699 test.pointure_34,test.cuir_noir
11 SANDAL-2-M-34 3518378100705 test.pointure_34,test.cuir_marron
12 SANDAL-2-N-35 3518378100712 test.pointure_35,test.cuir_noir
13 SANDAL-2-M-35 3518378100767 test.pointure_35,test.cuir_marron