Metadata-Version: 2.1
Name: odoo-addon-connector_mercadolibre_product
Version: 19.0.1.0.0.4
Requires-Dist: odoo-addon-connector_mercadolibre==19.0.*
Requires-Dist: odoo==19.0.*
Summary: Listings, prices, and seller stock for Mercado Libre
Home-page: https://github.com/OCA/connector-mercadolibre
License: AGPL-3
Author: Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 19.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Development Status :: 3 - Alpha
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

==================================
Mercado Libre Connector - Products
==================================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:531cb17816743ea773b8e92d37e3f4c871d112bdea583d645aabd137131d0cf6
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
    :target: https://odoo-community.org/page/development-status
    :alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector--mercadolibre-lightgray.png?logo=github
    :target: https://github.com/OCA/connector-mercadolibre/tree/19.0/connector_mercadolibre_product
    :alt: OCA/connector-mercadolibre
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/connector-mercadolibre-19-0/connector-mercadolibre-19-0-connector_mercadolibre_product
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/connector-mercadolibre&target_branch=19.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Bind Mercado Libre listings to Odoo products and keep price and seller
stock aligned.

Listings are matched by the ``SELLER_SKU`` attribute, then by
``seller_custom_field``, then by the product internal reference. A
listing that does not match stays unbound. **Create missing products**
is off by default.

Price export uses the Mercado Libre Prices API. Stock export sends
``available_quantity`` for legacy items and
``PUT /user-products/{id}/stock/type/seller_warehouse`` when the backend
version is User products. Fulfillment stock is read-only.

.. IMPORTANT::
   This is an alpha version, the data model and design can change at any time without warning.
   Only for development or testing purpose, do not use in production.
   `More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
   :local:

Installation
============

Install ``connector_mercadolibre`` first, then this module.

Map each seller warehouse on the backend before enabling **Export
stock**. A warehouse mapped as fulfillment is displayed and is never
updated from Odoo.

Configuration
=============

1. Open the Mercado Libre backend and the page **Catalog**.
2. Enable **Import listings**, **Export prices**, and **Export stock**
   as needed.
3. Add a line per Odoo warehouse: Mercado Libre store id, network node
   id, and stock type (``seller_warehouse``, ``selling_address``, or
   ``fulfillment``).
4. Set **Versions** on the backend. After connect, the core fills this
   from the ``user_product_seller`` tag on ``/users/me``. Keep **User
   products** for sellers already migrated.
5. Run **Import listings** on the backend. Review unmatched rows under
   **Mercado Libre / Catalog / Listings**.
6. Open a product and use the **Mercado Libre** smart button to see its
   bindings. Set the internal reference to the seller SKU before the
   next import if the first pass did not match.

Usage
=====

A change to a product list price enqueues one price export for each
binding of that product. A done stock move enqueues one stock export per
binding and mapped warehouse. Both jobs use an identity key, so a burst
of moves becomes a single pending job.

**Mercado Libre / Catalog / Categories** shows the cached category tree
and the attribute schema used when a publisher component creates a
listing. **Refresh categories** on the backend reloads that tree.

The notification topics ``items`` and ``stock-location`` update the
binding. ``stock-location`` writes the last marketplace quantity on the
binding and does not create ``stock.quant`` rows.

Development
===========

Stock export is two components with usage ``stock.exporter``.
``_component_match`` keeps the component for the backend version:

- ``mercadolibre.product.exporter.stock.legacy`` writes
  ``available_quantity`` on ``PUT /items/{id}`` when **Versions** is
  Legacy items.
- ``mercadolibre.product.exporter.stock.user_product`` writes
  ``PUT /user-products/{id}/stock/type/seller_warehouse`` (or
  ``selling_address``) when **Versions** is User products.

A binding with an empty ``user_product_id`` uses the legacy call,
including when the backend version is User products. Fulfillment
bindings and fulfillment warehouse lines are skipped. The quantity is
``product.with_context(warehouse_id=warehouse).free_qty`` for that
mapped warehouse only.

``_apply_on`` has to be an Odoo model. The Mercado Libre topic is not a
model, so the handlers set ``_topic`` to ``items`` or ``stock-location``
and ``_apply_on`` to ``mercadolibre.notification``. The core dispatcher
selects the handler by ``_topic``.

``mercadolibre.product.binder`` resolves a listing with
``to_internal(external_id, variation_id=...)``. An empty variation id is
the item that has no variations. ``to_external`` returns the Mercado
Libre item id.

Publishing a new listing is the component usage ``product.publisher``.
This module ships a publisher that raises ``UserError`` with "Listing
publication is not installed." A localization replaces that component
with ``POST /items`` without changing price or stock export.

Import and export mappers are separate (``import.mapper`` and
``export.mapper``). The export mapper exposes ``price_payload``,
``legacy_stock_payload``, and ``user_product_stock_payload`` so a price
body is never merged into a stock body.

Import jobs use the identity key ``meli:item:{backend_id}:{item_id}:``.
One job imports every variation of the item. Price jobs use
``meli:price:{backend_id}:{binding_id}``. Stock jobs use
``meli:stock:{backend_id}:{binding_id}:{mapping_id}``.

Known issues / Roadmap
======================

- Picture binary synchronization. The binding stores picture URLs.
- Listing creation (``product.publisher``) with category attributes,
  listing types, and picture upload.
- Price lists other than the product list price.
- Multi-company stock rules beyond the warehouse map on the backend.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-mercadolibre/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector-mercadolibre/issues/new?body=module:%20connector_mercadolibre_product%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/connector-mercadolibre <https://github.com/OCA/connector-mercadolibre/tree/19.0/connector_mercadolibre_product>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
