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
105 changes: 105 additions & 0 deletions lims_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
=========================
LIMS Purchase Integration
=========================

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

.. |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_purchase
: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_purchase
: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 Purchase Integration
====================================================

This module integrates **Odoo LIMS** with **Purchase Orders**, allowing
laboratories to sell LIMS services directly as products.

Link a LIMS order to a purchase order

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

**Table of contents**

.. contents::
:local:

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

========================== LIMS Purchase Integration
====================================================

This module integrates **Odoo LIMS** with **Purchase Orders**, allowing
laboratories to sell LIMS services directly as products.

Link a LIMS order to a purchase order

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

Usage
=====

Usage
=====

Link a LIMS order to a purchase order

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_purchase%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
------------

- Hardik-OSI 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.

This module is part of the `OCA/connector-lims <https://github.com/OCA/connector-lims/tree/18.0/lims_purchase>`_ 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_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions lims_purchase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "LIMS Purchase Integration",
"version": "18.0.1.0.0",
"depends": ["purchase", "lims"],
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-lims",
"category": "LIMS",
"summary": "Link LIMS orders and Purchase Orders; Smart buttons for navigation",
"license": "AGPL-3",
"data": [
"views/purchase_order_views.xml",
"views/lims_order_views.xml",
],
"installable": True,
"application": False,
}
2 changes: 2 additions & 0 deletions lims_purchase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import purchase_order
from . import lims_order
63 changes: 63 additions & 0 deletions lims_purchase/models/lims_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from odoo import fields, models


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

purchase_order_ids = fields.One2many(
"purchase.order",
"lims_order_id",
string="Purchase Orders",
help="Purchase Orders created/linked for this LIMS Order",
)

purchase_order_count = fields.Integer(
string="PO Count",
compute="_compute_purchase_order_count",
)

purchase_order_m2m_ids = fields.Many2many(
"purchase.order",
"lims_order_purchase_rel",
"lims_order_id",
"purchase_order_id",
string="Linked Purchase Orders (M2M)",
help="Attach existing Purchase Orders that relate to this LIMS Order.",
)

def _compute_purchase_order_count(self):
for rec in self:
# read_group is faster in bulk but simple search_count is fine here
rec.purchase_order_count = self.env["purchase.order"].search_count(
[("lims_order_id", "=", rec.id)]
)

def action_view_purchase_orders(self):
"""Open purchase orders linked to this LIMS order."""
self.ensure_one()
purchase_orders = self.purchase_order_ids

# Use the standard Purchase action (the one that lists RFQs/POs)
action = self.env.ref("purchase.purchase_rfq").read()[0]

# If no POs, open the empty list
if not purchase_orders:
action["domain"] = [("id", "in", [])]
return action

# If only one PO → open form view directly
if len(purchase_orders) == 1:
form_view = self.env.ref("purchase.purchase_order_form", False)
action.update(
{
"view_mode": "form",
"views": [(form_view.id, "form")] if form_view else [],
"res_id": purchase_orders.id,
"domain": [],
}
)
return action

# Multiple → show list view filtered
action["domain"] = [("id", "in", purchase_orders.ids)]
return action
38 changes: 38 additions & 0 deletions lims_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from odoo import fields, models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

lims_order_id = fields.Many2one(
"lims.order",
string="LIMS Order",
ondelete="set null",
help="Link to the LIMS Order related to this Purchase Order",
)

def action_open_linked_lims_order(self):
"""
Smart-button action: open the related LIMS Order.
If no lims_order_id is set, return an action to search for none (or raise).
"""
self.ensure_one()
if not self.lims_order_id:
# Best UX: return an empty tree view filtered to nothing
action = self.env.ref("lims.action_lims_operation_order").read()[0]
action["domain"] = [("id", "in", [])]
return action

# If you want to open the form directly:
action = self.env.ref("lims.action_lims_operation_order").read()[0]
# If the action supports views, prefer to open the form for the single record
action.update(
{
"views": [(self.env.ref("lims.lims_order_form").id, "form")]
if self.env.ref("lims.lims_order_form", False)
else action.get("views"),
"res_id": self.lims_order_id.id,
"target": "current",
}
)
return action
3 changes: 3 additions & 0 deletions lims_purchase/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
10 changes: 10 additions & 0 deletions lims_purchase/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
==========================
LIMS Purchase Integration
==========================

This module integrates **Odoo LIMS** with **Purchase Orders**, allowing laboratories
to sell LIMS services directly as products.

Link a LIMS order to a purchase order

This module extends the `lims` and `purchase` modules.
1 change: 1 addition & 0 deletions lims_purchase/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Hardik-OSI <hsuthar@opensourceintegrators.com>
10 changes: 10 additions & 0 deletions lims_purchase/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
==========================
LIMS Purchase Integration
==========================

This module integrates **Odoo LIMS** with **Purchase Orders**, allowing laboratories
to sell LIMS services directly as products.

Link a LIMS order to a purchase order

This module extends the `lims` and `purchase` modules.
5 changes: 5 additions & 0 deletions lims_purchase/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Usage
=====

Link a LIMS order to a purchase order

Loading
Loading