Metadata-Version: 2.1
Name: odoo-addon-base_line_numbering
Version: 19.0.1.0.0.2
Requires-Dist: odoo==19.0.*
Summary: Generic mixin to renumber an ordered set of lines
Home-page: https://github.com/OCA/server-ux
License: AGPL-3
Author: Camptocamp, 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
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

===================
Base Line Numbering
===================

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

.. |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%2Fserver--ux-lightgray.png?logo=github
    :target: https://github.com/OCA/server-ux/tree/19.0/base_line_numbering
    :alt: OCA/server-ux
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/server-ux-19-0/server-ux-19-0-base_line_numbering
    :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/server-ux&target_branch=19.0
    :alt: Try me on Runboat

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

Technical module providing ``line.numbering.mixin``, a mixin that
numbers the lines of a record (e.g. the lines of an order) with
consecutive positions (1, 2, 3, ... or, with a step of 10, 10, 20, 30,
...), following the lines' order.

It has no functional effect on its own. It is a building block for
modules that need a stable line reference, shown to users and exchanged
with third parties (e.g. a position on purchase, sale or stock move
lines).

Positions are renumbered automatically when lines are added or removed,
in any state of the record. Consuming modules can opt out for specific
records (e.g. records already sent to a partner).

**Table of contents**

.. contents::
   :local:

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

Several documents exchanged with partners (orders, deliveries, invoices)
refer to their lines by a position number, like ``10``, ``20``, ``30``.
Each module that needs it used to implement its own numbering. This
module provides the numbering once, so that every model numbers its
lines the same way.

Usage
=====

This module is meant for developers. Inherit the mixin on the parent
model and declare which lines to number and where to store their
position:

.. code:: python

   class PurchaseOrder(models.Model):
       _name = "purchase.order"
       _inherit = ["purchase.order", "line.numbering.mixin"]

       _line_numbering_lines_field = "order_line"
       _line_numbering_position_field = "position"
       _line_numbering_step = 10

- ``_line_numbering_lines_field``: the one2many field holding the lines
  to number.
- ``_line_numbering_position_field``: the integer field of the lines
  that stores the position.
- ``_line_numbering_step``: the gap between two consecutive positions
  (default: 1).

``renumber_lines_positions()`` numbers the lines of the records
explicitly. ``create()`` and ``write()`` call it automatically when the
lines change.

The behaviour can be adapted by overriding:

- ``_line_renumber_needed()``: return ``False`` to skip the automatic
  renumbering for a record (e.g. a locked one). By default, it is
  skipped only when the ``skip_line_auto_renumber`` context key is set.
- ``_line_renumber_trigger_fields()``: the ``write()`` keys that
  re-trigger the numbering. Defaults to
  ``[_line_numbering_lines_field]``. Override it when
  ``_line_numbering_lines_field`` is a computed one2many, which never
  appears in ``write()`` values.
- ``_line_renumber_get_lines()``: the lines to number, in the order they
  get their positions. Defaults to the lines of
  ``_line_numbering_lines_field`` in their model's order.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/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/server-ux/issues/new?body=module:%20base_line_numbering%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
=======

Authors
-------

* Camptocamp

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

- `Camptocamp <https://www.camptocamp.com>`__:

  - Akim Juillerat <akim.juillerat@camptocamp.com>
  - Ricardo Almeida Soares <ricardo.almeidasoares@camptocamp.com>
  - Iván Todorovich <ivan.todorovich@camptocamp.com>
  - Simone Orsi <simone.orsi@camptocamp.com>

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/server-ux <https://github.com/OCA/server-ux/tree/19.0/base_line_numbering>`_ project on GitHub.

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