Metadata-Version: 2.1
Name: odoo-addon-account_edi_ubl_cii_purchase_match
Version: 16.0.1.0.0.4
Summary: Extend UBL vendor bill import to automatically match and link bill lines to purchase order lines using the OrderReference and product label.
Home-page: https://github.com/OCA/edi
Author: ACSONE SA/NV,Odoo Community Association (OCA)
Author-email: support@odoo-community.org
License: AGPL-3
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 16.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Requires-Python: >=3.10
Requires-Dist: odoo<16.1dev,>=16.0a

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

==================================
Account Edi Ubl Cii Purchase Match
==================================

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

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |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%2Fedi-lightgray.png?logo=github
    :target: https://github.com/OCA/edi/tree/16.0/account_edi_ubl_cii_purchase_match
    :alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-account_edi_ubl_cii_purchase_match
    :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/edi&target_branch=16.0
    :alt: Try me on Runboat

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

This module extends the UBL vendor bill import process to improve how
vendor bill lines are linked to purchase order lines.

Instead of replacing the imported UBL lines with the purchase order
lines (standard behavior), this module:

1. **Reads the OrderReference** in the UBL document.

2. **Identifies the corresponding Purchase Order** using the vendor
   reference (``partner_ref``) or the purchase order ref.

3. **Matches each UBL line** with a purchase order line based on:

   - product name,
   - supplier product name

4. **Links the vendor bill line** to the matched PO line

5. When a user manually selects a purchase order line from the bill:

   - the system stores the supplier product name,
   - future imports will auto-match using that supplier information.

This ensures accurate line-level linking while preserving the supplier’s
invoice data.

**Table of contents**

.. contents::
   :local:

Use Cases / Context
===================

In the standard behavior, when importing a vendor bill from a UBL
document:

- If a Purchase Order is found, **all imported UBL lines are replaced**
  by the Purchase Order lines.
- This causes a **loss of original UBL data**, such as:

  - line-level descriptions,
  - quantities,
  - pricing,
  - tax information received from the supplier.

- Additionally, the standard flow performs **no matching based on
  product labels**, so incorrect PO lines may be added if PO content
  does not reflect what is actually on the invoice.

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

No configuration is required to use this module.

However, for optimal matching:

- Ensure that *OrderReference* in the vendor UBL document corresponds to
  the Purchase Order Ref or the **Vendor Reference** (``partner_ref``).
- Maintain consistent **product names** or **supplier product names** so
  that UBL line descriptions can be matched to the correct purchase
  order line.

Optional but recommended:

- Define supplier product names (``product.supplierinfo``) to improve
  matching accuracy.

Usage
=====

1. Import a vendor bill in UBL format through: Accounting / Vendors /
   Bills / Upload
2. The module will automatically:

   - Extract the OrderReference from the UBL.
   - Find the matching purchase order via ``partner_ref`` or purchase
     order ref.
   - Attempt to match each UBL line with the correct purchase order line
     using:

     - product name,
     - supplier product name

3. When a match is found: the vendor bill line is linked to the purchase
   order line.
4. If no match is found:

   - Click "Select purchase line" button in invoice line
   - Select a purchase order and a purchase order line

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

This module implements custom purchase order line matching and replaces
the standard behavior of linking vendor bills to purchase orders via
UBL.

Before migrating to future versions, it is recommended to verify
whether:

- Odoo natively supports precise line-level matching,
- supplier product names and UBL descriptions are matched out of the
  box,
- and the original UBL lines are preserved.

If the standard behavior evolves to fully cover this business
requirement, this module may become unnecessary.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/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/edi/issues/new?body=module:%20account_edi_ubl_cii_purchase_match%0Aversion:%2016.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
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Souheil Bejaoui souheil.bejaoui@acsone.eu

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.

.. |maintainer-sbejaoui| image:: https://github.com/sbejaoui.png?size=40px
    :target: https://github.com/sbejaoui
    :alt: sbejaoui

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sbejaoui| 

This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/16.0/account_edi_ubl_cii_purchase_match>`_ project on GitHub.

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