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

[16.0][ADD] sale_import_amazon #83

Draft
wants to merge 11 commits into
base: 16.0
Choose a base branch
from
Draft

Conversation

clementmbr
Copy link
Member

@clementmbr clementmbr commented Mar 5, 2024

Odoo-Amazon connector for OCA based on sale_import.
Needs OCA/sale-channel#17 for channel_type field on sale.channel.

TODO:

  • register Amazon delivery when order is "Shipped"
  • encrypt credentials fields (for API connection)
  • company_id in basic module sale_channel with rule multi-company
  • if no pricelist in sale.channel and currency_code in JSON, catch the first pricelist with the JSON's currency
  • Amazon's SaleOrder extendable model fields in sale_import_amazon following Florian's syntax

QUESTIONS:

  • how to check API connection without real credentials? => Not possible to connect do SP-API sandbow without credentials
  • how to avoid creating invoice/shipping address when it's the same as the customer's address? => Important to keep duplicatesd address_invoicing and address_customer to preserve order's history if address_customer changes!
  • how to catch order's currency_code and avoid using pricelist_id? => pricelist_id is mandatory!
  • is there a better way to manage existing SO? => No, there is'nt
  • is it possible to inherit SaleOrder's extendable_pydantic in sale_import_amazon instead of adding optional fields in sale_import_base? => Yes!

@clementmbr
Copy link
Member Author

@sebastienbeau @bealdav (@florian-dacosta let me jnow if you're interested)
I made this first version of the sale_import_amazon module.

I still need to manage the encrypt part of credentials fields and how to register Amazon delivery in Odoo, but it can already connect to the API and create odoo Sale Orders with (I hope) all the information we need.

However I have many questions I listed in the PR description about the work I've done so far. I'd be glad if you can have a look and clarify these questions before going further.

Thanks!

@clementmbr
Copy link
Member Author

FYI @sebastienbeau @bealdav
@florian-dacosta just answered most of my questions! 🙏

Now I only need to know to test API connection without sharing real credentials in the OCA module... And I'll need your reviews sooner or later! :)

@bealdav
Copy link
Member

bealdav commented Mar 6, 2024

@bealdav
Copy link
Member

bealdav commented Mar 12, 2024

@clementmbr Did you find a way to test with fake credentials ?

@clementmbr clementmbr force-pushed the 16.0-add-sale-import-amazon branch 4 times, most recently from 6cca2b7 to 8267afe Compare March 20, 2024 16:43
@clementmbr
Copy link
Member Author

@bealdav @sebastienbeau Following @florian-dacosta advises I added the dependency on server_environment to avoid storing in db the Amazon credentials (and allowing the user to encrypt these fields with server_environment_data_encryption).

Also, I managed to use the module on a real db. It works as expected but I faced some difficulties as the company_id on the Amazon's sale_channel must the same as the one on the selected crm.team and the one on the products referenced in the Amazon's payload.
It seems this module's scope doesn't include handling these kind of problems... but I imagine it can be quite annoying for the user anyway as the current errors are not very explicit. How would you suggest to handle this thing?

Beside that, I think I really need some review before trying it in production. Thanks!

@bealdav
Copy link
Member

bealdav commented Apr 4, 2024

@clementmbr What is the key in ORDER_SHIPPED test data which define the company to import into ?
If this key is linked to sale.channel, I don't understand the problem with product with the same company_id or no company_id.

Other topic #84

@clementmbr
Copy link
Member Author

@clementmbr What is the key in ORDER_SHIPPED test data which define the company to import into ? If this key is linked to sale.channel, I don't understand the problem with product with the same company_id or no company_id.

@bealdav Unfortunately, there is no key in the JSON given by Amazon that can be used to identify the destination company, as there is no multi-company setup on the Amazon side.

But your comment gave me the idea to search for the product only on channel's company (with an explicit error message):
https://github.com/akretion/sale-import/pull/83/files#diff-27e4483cdc08344f76a62e3859deaafd9e5ac59ddedb1a44d839c17b3b4c0b77R187

Like this we are sure to have a product with the correct company, and we let the user clean its database if needed.

What do you think?

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.

3 participants