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

[10.0] migrate connector_magento #255

Merged
merged 88 commits into from
Oct 3, 2017
Merged

[10.0] migrate connector_magento #255

merged 88 commits into from
Oct 3, 2017

Conversation

guewen
Copy link
Member

@guewen guewen commented Jun 16, 2017

@pedrobaeza
Copy link
Member

There are conflicts right now.

Shouldn't this be better renamed to connector-magento?

@guewen
Copy link
Member Author

guewen commented Jun 16, 2017

There are conflicts right now.

Yep, I'll fix them, but my focus is elsewhere at this moment, will do it soon.

Shouldn't this be better renamed to connector-magento?

It would be nice, and the right moment to do it, anyway addons that depend on it need changes.

@guewen guewen force-pushed the 10.0-components branch from 7463d1b to 8d578f1 Compare June 20, 2017 11:57
guewen and others added 25 commits June 20, 2017 14:03
Because it does not apply for Magento 1.9

Closes OCA#126
It reduces the risk of incompatibility between modules if both replace
the product mapper.
So we don't replace the entire sale order mapper which has more chances
to provoke conflicts between modules.
… new line character to the returned string. This character is not allowed in in the httprequest header. Use base64.b64encode to avoid trailing new line character in the encoded string
… now possible to the analytic account and the fiscal position to use when creating a sale order from magento. Theses options can be specified at any level of the hierarchy of the backend models according to the needs. In this way it become possible for exemple to specify a fiscal position to use for a specific store and take advantage of the taxes mapping defined for this specific position to map the right taxe on the sale order line
So it doesn't fail when it receives a MagicMock instead of a str
@sbidoul
Copy link
Member

sbidoul commented Sep 13, 2017

@guewen Except the one failing test, do you think this PR is good enough for merging? That would facilitate further contributions.

@guewen
Copy link
Member Author

guewen commented Sep 15, 2017

@guewen Except the one failing test, do you think this PR is good enough for merging? That would facilitate further contributions.

Yes it is and indeed it would make contributions a lot easier, I have to find some time to fix the test.

@guewen
Copy link
Member Author

guewen commented Sep 15, 2017

Every time I import an order, a new 'archived' partner is created for both the partner_invoice_id and partner_shipping_id. The orders do use an existing partner for the partner_id field, but not for the other two.

The newly created 'archived' partners do not have any bindings, but are children of the main partner_id which does have bindings.

This is normal: on its side, Magento creates a new address for every order (and the API doesn't return us ids for them), so we have to replicate the same behavior. The addresses are archived so you can use them on the sales orders and related document but not in the searches/lists. This is the difference between the "address book" (the not archived addresses) and the "sales addresses".

@jaredkipe
Copy link

This is normal: on its side, Magento creates a new address for every order (and the API doesn't return us ids for them), so we have to replicate the same behavior. The addresses are archived so you can use them on the sales orders and related document but not in the searches/lists. This is the difference between the "address book" (the not archived addresses) and the "sales addresses".

Makes sense.

Regarding the failing test case. Perhaps I am not reading it correctly, but I can't find anywhere where it would appear that you are only looking for the stock on the location given by ref("stock.stock_location_components") (5.0 qty).

It would seem that ref("stock.stock_location_components") is inside WH (WH/Stock/Shelf 1), so I would expect its inventory to contribute to WH's inventory (and that is the warehouse assigned to the backend in MagentoTestCase.setUp().

If you want the test to pass, you can put this line after line 192 (my_location_id = ...) binding = binding.with_context(location=my_location_id)

That makes the test pass, but only because of the implementation of the implementation. I think changing line 208 to self.assertEqual(binding.magento_qty, 35.0) is correct.

All this said, I'd rather get to select a field (probably optional) for a location, falling back to the WH location if not set. This would allow you to combine or filter stock going out based on views or physical locations. (e.g. if you have more than one warehouse you can send the stock location 'Physical Locations' to send all of them combined)

if not sync:
return True
record = self.backend_adapter.read(self.magento_id,
record = self.backend_adapter.read(self.external_id,
attributes=['updated_at'])
if not record['updated_at']:
# in rare case it can be empty, in doubt, import it
return False
Copy link

Choose a reason for hiding this comment

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

Shouldn't this be True?

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems so... according to the comment I'd say it should be True.

@guewen
Copy link
Member Author

guewen commented Sep 21, 2017

Thanks @jaredkipe, you're helping me a lot! It turns out this test has been added here guewen#6 so @Cedric-Pigeon might have his say on your proposal for the location field. I'll start by fixing the test so we can move forward :)

* Rename it because it was shadowing another test
* Compute in the location's context
@guewen
Copy link
Member Author

guewen commented Sep 21, 2017

The last commit should fix the test. I took the approach to change the location in the context of the binding, because it seems the test tries to check that we are exporting the value for "this" location. @Cedric-Pigeon your approval would be great :)

Thanks again for the help @jaredkipe

@jaredkipe
Copy link

Thanks @jaredkipe, you're helping me a lot! It turns out this test has been added here guewen#6 so @Cedric-Pigeon might have his say on your proposal for the location field. I'll start by fixing the test so we can move forward :)

@guewen You are very welcome, thank you for your fantastic work on all of these projects!

In my 'customizations' I actually added a location field to use like this. This allowed me to 'group' several warehouses by injecting an intermediate 'view' location. This isn't ideal, I'd prefer to specify multiple locations or warehouses and put those into the context. This should be possible as stock.models.product.Product._get_domain_locations() will use a list of location ids or a list of warehouse ids. I'll get there eventually, I just have larger things to do.

@jaredkipe
Copy link

@guewen I'm still being plagued by the imports eventually freezing up. When I go to import 3k products, eventually the process will stop without explicitly failing.

Sometimes they fail with a result 'Could not acquire advisory lock'. If this happens I need to restart odoo.

Here is a gist of active Postgres activity when I come back after trying to import stuff overnight. https://gist.github.com/jaredkipe/e81599fe5610e5a7f0eb59334d6529ed

If I find the 'started' jobs, I can requeue them, sometimes that gets them going again.. but only for so long. I'm testing right now with various timeouts for transactions and and idle sessions in Postgres (9.6).

The same problem exists in threaded and worker modes.

@guewen
Copy link
Member Author

guewen commented Sep 25, 2017

I'm still being plagued by the imports eventually freezing up. When I go to import 3k products, eventually the process will stop without explicitly failing.

Do you have a magento test database dump to provide or is a private one?

@guewen
Copy link
Member Author

guewen commented Sep 26, 2017

Can we merge?

@jaredkipe
Copy link

Do you have a magento test database dump to provide or is a private one?
It is private. I've found that if I can work the list down more confidently by setting lock_timeout and idle_in_transaction_session_timeout to a couple of minutes, the whole process is much more reliable.

An improvement that could be made to the item import would be to batch the products right after returning from the initial search of product ids as you must wait quite a while between the return (with thousands + product ids) to jobs actually starting to run. (presumably because until the main transaction commits, the queue can't see them).

Bear in mind that the contention I have been dealing with is as it is importing individual products. I have never had a problem with the initial import other than thinking it wasn't working while waiting for it to finish.

Can we merge?

I think so. I think all of the remaining issues I have will have to wait until later as things like the bind by SKU are now integral to my current workflow and I cannot stop to work on them.

@jaredkipe
Copy link

@guewen I forgot to mention, the dependencies could use updating. Here is the list of modules I needed to install the magento connector and the packages they come from (symlinks)

account_payment_mode -> ../oca/bank-payment/account_payment_mode
account_payment_partner -> ../oca/bank-payment/account_payment_partner
account_payment_sale -> ../oca/bank-payment/account_payment_sale
base_exception -> ../oca-beta/server-tools/base_exception
base_technical_user -> ../oca-beta/server-tools/base_technical_user
component -> ../oca-beta/connector/component
component_event -> ../oca-beta/connector/component_event
connector -> ../oca-beta/connector/connector
connector_base_product -> ../oca-beta/connector/connector_base_product
connector_ecommerce -> ../oca-beta/connector-ecommerce/connector_ecommerce
connector_magento -> ../oca-beta/connector-magento/connector_magento
dbfilter_from_header -> ../oca-server-tools/dbfilter_from_header
partner_gravatar -> ../hibou-gravatar-partner
product_multi_category -> ../oca/product-attribute/product_multi_category
queue_job -> ../oca/queue/queue_job
sale_automatic_workflow -> ../oca/sale-workflow/sale_automatic_workflow
sale_automatic_workflow_payment_mode -> ../oca/sale-workflow/sale_automatic_workflow_payment_mode
sale_exception -> ../oca/sale-workflow/sale_exception

All of those are out of beta now, and if memory serves, the only one I couldn't find a use for was the e-commerce module itself (connector_ecommerce for sure though).

@jaredkipe
Copy link

jaredkipe commented Sep 29, 2017

I've been looking more into the hangups. Basically the only commonality I'm ever able to see is that the product import binding will be created (logged from _create) but that product is not actually in the database. And then in Postgres there is an 'idle in transaction' with a query of one of the two of these. https://gist.github.com/jaredkipe/1ab32a983e02c9ada64c21e90572f0a6

Okay. After spending more hours working on this. It 'looked' like it was somewhere having to do with downloading the image right after the product is created. It appears that CloudFlare was doing something to make that hang (no timeout?) in _get_binary_image. After hard coding the IP in /etc/hosts in the container suddenly I'm able to do thousands and thousands in the time it would have hung up on a couple.

This also explains why it was so degenerative, it seemed to only get worse and worse. Well I guess because CloudFlare was limiting/throttling it more and more.

@guewen guewen merged commit c4e1bef into OCA:10.0 Oct 3, 2017
@guewen
Copy link
Member Author

guewen commented Oct 3, 2017

@jaredkipe thanks for the details, this is very reassuring :)

Could you retarget your pull requests on 10.0 now that's merged? So it'll ease the review.

@jaredkipe
Copy link

@guewen Will do! (I asked about that between getting the notice that this was merged and getting this comment. :D )

lmignon pushed a commit to acsone/connector that referenced this pull request May 10, 2019
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
bealdav pushed a commit to akretion/connector that referenced this pull request Oct 12, 2020
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
FrancoMaxime pushed a commit to acsone/connector that referenced this pull request Aug 30, 2022
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
asierneiradev pushed a commit to factorlibre/connector that referenced this pull request Oct 4, 2022
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
asierneiradev pushed a commit to factorlibre/connector that referenced this pull request Jan 30, 2023
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
nguyenminhchien pushed a commit to nguyenminhchien/connector that referenced this pull request Nov 23, 2023
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
nguyenminhchien pushed a commit to nguyenminhchien/connector that referenced this pull request Dec 8, 2023
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
thienvh332 pushed a commit to thienvh332/connector that referenced this pull request Sep 19, 2024
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
thienvh332 pushed a commit to thienvh332/connector that referenced this pull request Oct 8, 2024
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
thienvh332 pushed a commit to thienvh332/connector that referenced this pull request Oct 9, 2024
The cache entries for events were including instance of the components,
hence, they included the work instance / odoo environment.

Only the component class and the events it provides are new cached, the
instances of components being instanciated when needed.

Reported on:
OCA/connector-magento#255 (comment)
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.