Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions lims_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
=====================================================
Laboratory Information Management System (LIMS) Sales
=====================================================

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

.. |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/licence-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--lims-lightgray.png?logo=github
:target: https://github.com/OCA/connector-lims/tree/18.0/lims_sale
:alt: OCA/connector-lims
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-lims-18-0/connector-lims-18-0-lims_sale
: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-lims&target_branch=18.0
:alt: Try me on Runboat

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

========================== LIMS Sale Integration
================================================

| This module integrates **Odoo LIMS** with **Sales Orders**, allowing
laboratories to sell LIMS services directly as products.
| When a sale order is confirmed, corresponding LIMS Orders are
automatically created based on the configuration defined on each
product.

The module supports multiple creation strategies for LIMS Orders via the
field ``lims_tracking`` on the product template.

- **No** – No LIMS order is created.
- **Per Sales Order** – One LIMS order is created for the whole sale
order.
- **Per Sales Order Line** – One LIMS order is created for each sale
order line.
- **Per Quantity** – One LIMS order is created per quantity unit in the
sale line.

Each LIMS Order is generated using the selected **LIMS Template**,
carrying details such as categories, operator, and test configurations
defined within the template.

This module extends the ``lims`` and ``sale`` modules.

**Table of contents**

.. contents::
:local:

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

========================== LIMS Sale Integration
================================================

| This module integrates **Odoo LIMS** with **Sales Orders**, allowing
laboratories to sell LIMS services directly as products.
| When a sale order is confirmed, corresponding LIMS Orders are
automatically created based on the configuration defined on each
product.

The module supports multiple creation strategies for LIMS Orders via the
field ``lims_tracking`` on the product template.

- **No** – No LIMS order is created.
- **Per Sales Order** – One LIMS order is created for the whole sale
order.
- **Per Sales Order Line** – One LIMS order is created for each sale
order line.
- **Per Quantity** – One LIMS order is created per quantity unit in the
sale line.

Each LIMS Order is generated using the selected **LIMS Template**,
carrying details such as categories, operator, and test configurations
defined within the template.

This module extends the ``lims`` and ``sale`` modules.

Usage
=====

Usage
=====

1. Go to *Sales › Products* and open or create a product.
2. Under the *LIMS Configuration* section:

- Select a **LIMS Template**.
- Choose the **LIMS Tracking** mode (No / Order / Line / Quantity).

3. Create a **Sale Order** and add products with a configured LIMS
Template.
4. Confirm the sale order:

- LIMS Orders will be automatically generated.
- A smart button **“LIMS Orders”** appears on the sale order form.

5. Click the button to view all generated LIMS Orders linked to the
sale.

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

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

* Open Source Integrators

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

- Rodrigo Madrid rmadrid@opensourceintegrators.com
- Adriana Alpizar aalpizar@opensourceintegrators.com
- Maxime Chambreuil mchambreuil@opensourceintegrators.com
- Hardik Suthar hsuthar@opensourceintegrators.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.

.. |maintainer-max3903| image:: https://github.com/max3903.png?size=40px
:target: https://github.com/max3903
:alt: max3903
.. |maintainer-jasiel-osi| image:: https://github.com/jasiel-osi.png?size=40px
:target: https://github.com/jasiel-osi
:alt: jasiel-osi
.. |maintainer-Hardik-OSI| image:: https://github.com/Hardik-OSI.png?size=40px
:target: https://github.com/Hardik-OSI
:alt: Hardik-OSI

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

|maintainer-max3903| |maintainer-jasiel-osi| |maintainer-Hardik-OSI|

This module is part of the `OCA/connector-lims <https://github.com/OCA/connector-lims/tree/18.0/lims_sale>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions lims_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions lims_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (C) 2025 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Laboratory Information Management System (LIMS) Sales",
"summary": "Manage LIMS Instruments, Analysis and Tests Sales Integration",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"category": "LIMS",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-lims",
"depends": ["lims", "sale"],
"data": [
"views/product_template_views.xml",
"views/sale_order_views.xml",
"views/lms_order_view.xml",
],
"application": False,
"development_status": "Beta",
"maintainers": ["max3903", "jasiel-osi", "Hardik-OSI"],
}
4 changes: 4 additions & 0 deletions lims_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import sale_order
from . import product_template
from . import lims_order
from . import lims_template
24 changes: 24 additions & 0 deletions lims_sale/models/lims_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import fields, models


class LimsOrder(models.Model):
_inherit = "lims.order"

sale_order_id = fields.Many2one("sale.order", string="Sale Order", index=True)
sale_order_line_id = fields.Many2one(
"sale.order.line", string="Sale Order Line", index=True
)
sale_origin = fields.Char(help="Original sale reference")

def action_open_sale_order(self):
self.ensure_one()
if not self.sale_order_id:
return
return {
"type": "ir.actions.act_window",
"name": "Sale Order",
"res_model": "sale.order",
"view_mode": "form",
"res_id": self.sale_order_id.id,
"target": "current",
}
56 changes: 56 additions & 0 deletions lims_sale/models/lims_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from odoo import fields, models


class LimsTemplate(models.Model):
_inherit = "lims.template"

def create_lims_order_from_template(self, sale_order=None, sale_line=None):
"""Generate a lims.order record based on this
template and optionally link it to Sale Order."""
self.ensure_one()

test_commands = []
for test in self.test_ids:
if hasattr(test, "_prepare_order_test_values"):
values = test._prepare_order_test_values()
else:
values = {
"name": test.name,
"instrument_id": getattr(test, "instrument_id", False)
and test.instrument_id.id
or False,
"company_id": test.company_id.id
if test.company_id
else self.company_id.id,
}

if self.operator_id:
values["operator_id"] = self.operator_id.id

test_commands.append(fields.Command.create(values))

vals = {
"name": f"{self.name} - {fields.Date.today()}",
"template_id": self.id,
"operator_id": self.operator_id.id if self.operator_id else False,
"company_id": self.company_id.id or self.env.company.id,
"category_ids": [(6, 0, self.category_ids.ids)],
"test_ids": test_commands,
}

if sale_order:
vals.update(
{
"sale_order_id": sale_order.id,
"partner_id": sale_order.partner_id.id,
}
)
if sale_line:
vals.update(
{
"sale_line_id": sale_line.id,
"partner_id": sale_order.partner_id.id,
}
)

return self.env["lims.order"].create(vals)
23 changes: 23 additions & 0 deletions lims_sale/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

lims_tracking = fields.Selection(
[
("no", "No LIMS Order"),
("order", "Per Sales Order"),
("line", "Per Sales Order Line"),
("quantity", "Per Quantity"),
],
string="LIMS Tracking",
default="no",
help="Defines how LIMS orders are generated when a sale order is confirmed.",
)

lims_template_id = fields.Many2one(
"lims.template",
string="LIMS Template",
help="Template used to create the LIMS Order when a Sale Order is confirmed.",
)
72 changes: 72 additions & 0 deletions lims_sale/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from odoo import fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

lims_order_count = fields.Integer(
string="LIMS Orders", compute="_compute_lims_order_count", store=False
)

def _compute_lims_order_count(self):
lims_order_data = self.env["lims.order"].read_group(
[("sale_order_id", "in", self.ids)], ["sale_order_id"], ["sale_order_id"]
)
mapped_data = {
data["sale_order_id"][0]: data["sale_order_id_count"]
for data in lims_order_data
}
for order in self:
order.lims_order_count = mapped_data.get(order.id, 0)

def action_view_lims_orders(self):
self.ensure_one()
return {
"name": "LIMS Orders",
"type": "ir.actions.act_window",
"res_model": "lims.order",
"view_mode": "list,form",
"domain": [("sale_order_id", "=", self.id)],
"context": {"default_sale_order_id": self.id},
}

def action_confirm(self):
res = super().action_confirm()
for order in self:
for line in order.order_line:
product = line.product_id
if product.lims_tracking and product.lims_tracking != "no":
template = product.lims_template_id
if not template:
continue

if product.lims_tracking == "order":
lims_order = template.create_lims_order_from_template()
lims_order.write(
{
"sale_order_id": order.id,
"sale_origin": order.name,
}
)

elif product.lims_tracking == "line":
lims_order = template.create_lims_order_from_template()
lims_order.write(
{
"sale_order_id": order.id,
"sale_order_line_id": line.id,
"sale_origin": order.name,
}
)

elif product.lims_tracking == "quantity":
for i in range(int(line.product_uom_qty)):
lims_order = template.create_lims_order_from_template()
lims_order.write(
{
"sale_order_id": order.id,
"sale_order_line_id": line.id,
"sale_origin": f"{order.name}-{i+1}",
}
)
return res
3 changes: 3 additions & 0 deletions lims_sale/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Loading
Loading