Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better assignment of main category #237

Open
wants to merge 4 commits into
base: 8.0
Choose a base branch
from

Conversation

gfcapalbo
Copy link

When fetching categories from magento the connector returns a list of category ids.
To decide which one will be updated as categ_id (main category) the connector pops the last element of the categories and elects it as the main category of the product.
This randomness may cause unpredictable behaviour on update when using multiple categories in magento.
We had a client who wanted some products to be category: product_price/ 6 and product_price 5.
when updating products the connector would substitute some of the categories of some products and leave other intact. (depending on wich category happened to be the last in the magento category list.)

We are adding a little bit more logic to this decision. If the current main category of the odoo product exists already in the list of returned categories from magento, do not update the main category at all.

@hbrunn hbrunn added this to the 8.0 milestone Sep 29, 2016
if main_categ_id:
if self.backend_record.categ_id.id not in category_ids):
result['categ_id'] = main_categ_id
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would you need this? This branch causes the value to be overwritten with itself

# skip main cat assignment if the current main category is already in
# categ_ids
if main_categ_id:
if self.backend_record.categ_id.id not in category_ids):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python syntax error

current category in odoo is one of the categories fetched from magento.
@gfcapalbo gfcapalbo force-pushed the 8.0-issue_2954_category_random_overwrite_prevent branch from 1d9eadc to e6cf79f Compare September 29, 2016 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants