From 6a0d9043a2850b9631a18703b5591d8d849c23bb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 15 Dec 2014 18:45:38 +0100 Subject: [PATCH] Add module product_variant_csv_import --- product_variant_csv_import/__init__.py | 23 +++++++++++ product_variant_csv_import/__openerp__.py | 40 +++++++++++++++++++ product_variant_csv_import/product.py | 31 ++++++++++++++ product_variant_csv_import/product_view.xml | 24 +++++++++++ .../sample_csv/product.attribute.csv | 3 ++ .../sample_csv/product.attribute.value.csv | 8 ++++ .../sample_csv/product.template.csv | 13 ++++++ 7 files changed, 142 insertions(+) create mode 100644 product_variant_csv_import/__init__.py create mode 100644 product_variant_csv_import/__openerp__.py create mode 100644 product_variant_csv_import/product.py create mode 100644 product_variant_csv_import/product_view.xml create mode 100644 product_variant_csv_import/sample_csv/product.attribute.csv create mode 100644 product_variant_csv_import/sample_csv/product.attribute.value.csv create mode 100644 product_variant_csv_import/sample_csv/product.template.csv diff --git a/product_variant_csv_import/__init__.py b/product_variant_csv_import/__init__.py new file mode 100644 index 0000000..e6392dd --- /dev/null +++ b/product_variant_csv_import/__init__.py @@ -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 +# +# 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 . +# +############################################################################## + +from . import product diff --git a/product_variant_csv_import/__openerp__.py b/product_variant_csv_import/__openerp__.py new file mode 100644 index 0000000..c2b6c5c --- /dev/null +++ b/product_variant_csv_import/__openerp__.py @@ -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 +# +# 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 . +# +############################################################################## + + +{ + '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 +. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['product'], + 'data': ['product_view.xml'], +} diff --git a/product_variant_csv_import/product.py b/product_variant_csv_import/product.py new file mode 100644 index 0000000..22e2315 --- /dev/null +++ b/product_variant_csv_import/product.py @@ -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 +# +# 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 . +# +############################################################################## + +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 diff --git a/product_variant_csv_import/product_view.xml b/product_variant_csv_import/product_view.xml new file mode 100644 index 0000000..667e0a6 --- /dev/null +++ b/product_variant_csv_import/product_view.xml @@ -0,0 +1,24 @@ + + + + + + + + + Product Template CSV Import + product.template + tree,form + {"create_product_variant": True} + + + + + + + diff --git a/product_variant_csv_import/sample_csv/product.attribute.csv b/product_variant_csv_import/sample_csv/product.attribute.csv new file mode 100644 index 0000000..2dcdc34 --- /dev/null +++ b/product_variant_csv_import/sample_csv/product.attribute.csv @@ -0,0 +1,3 @@ +id,name +test.attribute_pointure,Pointure +test.attribute_cuir,Cuir diff --git a/product_variant_csv_import/sample_csv/product.attribute.value.csv b/product_variant_csv_import/sample_csv/product.attribute.value.csv new file mode 100644 index 0000000..51fbef4 --- /dev/null +++ b/product_variant_csv_import/sample_csv/product.attribute.value.csv @@ -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 diff --git a/product_variant_csv_import/sample_csv/product.template.csv b/product_variant_csv_import/sample_csv/product.template.csv new file mode 100644 index 0000000..4686005 --- /dev/null +++ b/product_variant_csv_import/sample_csv/product.template.csv @@ -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"