Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions magentoerpconnect/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def product_type_get(self):
('simple', 'Simple Product'),
('configurable', 'Configurable Product'),
('virtual', 'Virtual Product'),
('downloadable', 'Downloadable Product'),
# XXX activate when supported
('downloadable', 'Downloadable Product'),# XXX activate when supported
# ('grouped', 'Grouped Product'),
# ('bundle', 'Bundle Product'),
]
Expand Down Expand Up @@ -469,10 +468,10 @@ def website_ids(self, record):
def categories(self, record):
mag_categories = record['categories']
binder = self.binder_for('magento.product.category')

category_ids = []
product_id=[]
curr_product = self.binder_for('magento.product.product').to_openerp(record['product_id'], browse=True)
category_ids = []
main_categ_id = None

for mag_category_id in mag_categories:
cat_id = binder.to_openerp(mag_category_id, unwrap=True)
if cat_id is None:
Expand All @@ -482,16 +481,21 @@ def categories(self, record):

category_ids.append(cat_id)

#do not pop from extra categories
if category_ids:
main_categ_id = category_ids.pop(0)
main_categ_id = category_ids[0]

if main_categ_id is None:
default_categ = self.backend_record.default_category_id
if default_categ:
main_categ_id = default_categ.id

result = {'categ_ids': [(6, 0, category_ids)]}
if main_categ_id: # OpenERP assign 'All Products' if not specified
# OpenERP assign 'All Products' if not specified
# skip main cat assignment if the current main category is already in
# categ_ids
if ((main_categ_id and not curr_product) or
(main_categ_id and curr_product.categ_id not in category_ids)):
result['categ_id'] = main_categ_id
return result

Expand Down