Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
603691a
[ADD] estate,estate_account: add initial modules
waqasahmed-gif Apr 24, 2026
ba79e3d
Added estate and estate account module.
waqasahmed-gif Apr 24, 2026
7875976
[IMP] estate: add agent/manager record rules
waqasahmed-gif Apr 24, 2026
27199c6
Added record rules to restrict agents to own/unassigned properties an…
waqasahmed-gif Apr 24, 2026
f192b33
Added restricted access to data for companies and agents.
muhammadqasimshabbir3-art Apr 28, 2026
f55732d
[IMP] estate: restrict access by company and role
muhammadqasimshabbir3-art Apr 28, 2026
9c18533
Added Pharma control Dashboard module.
muhammadqasimshabbir3-art Apr 29, 2026
44693f4
[ADD] pharma_control_center: add dashboard and base models
muhammadqasimshabbir3-art Apr 29, 2026
25977b5
Added cart feature.
muhammadqasimshabbir3-art Apr 30, 2026
2f5dafe
[IMP] pharma_control_center: add cart checkout flow
muhammadqasimshabbir3-art Apr 30, 2026
1ebdf76
Added remaining file.
muhammadqasimshabbir3-art May 4, 2026
da1ebb5
[IMP] pharma_control_center: add remaining views and security
muhammadqasimshabbir3-art May 4, 2026
7bd3671
Added Sales anylytics feature for graphs.
muhammadqasimshabbir3-art May 5, 2026
32ce200
[IMP] pharma_control_center: add sales analytics views
muhammadqasimshabbir3-art May 5, 2026
e7f5460
Merge pull request #1 from MuhammadQasimShabeer/main
MuhammadQasimShabeer May 5, 2026
06e4d9c
[IMP] pharma_control_center: add drug interaction checks
muhammadqasimshabbir3-art May 6, 2026
a83c07b
[IMP] pharma_control_center: update README
muhammadqasimshabbir3-art May 6, 2026
798fcc4
[IMP] pharma_control_center: split documentation files
muhammadqasimshabbir3-art May 7, 2026
545201c
[LINT] pharma_control_center: fix python style
muhammadqasimshabbir3-art May 7, 2026
b11ed10
[FIX] Apply drug interaction validation in cart checkout
muhammadqasimshabbir3-art May 7, 2026
878dd44
Fixed odoo pipelines issue.
muhammadqasimshabbir3-art May 7, 2026
640f352
[FIX] Code style issues: missing newlines, indentation, and ambiguous…
muhammadqasimshabbir3-art May 7, 2026
00581a7
Merge branch '19.0' into main
MuhammadQasimShabeer May 7, 2026
4f85ce6
Merge pull request #2 from MuhammadQasimShabeer/main
MuhammadQasimShabeer May 7, 2026
0d1169b
Fixed odoo pipelines issue.
muhammadqasimshabbir3-art May 7, 2026
dc99ba4
Merge pull request #3 from MuhammadQasimShabeer/feature/restricted_da…
MuhammadQasimShabeer May 7, 2026
538c364
Added privacy and policy.
MuhammadQasimShabeer May 11, 2026
67f100b
Removed the scanning using the camer for barcode.
MuhammadQasimShabeer May 11, 2026
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
13 changes: 13 additions & 0 deletions pharma_control_center/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM odoo:18.0

USER root

RUN apt-get update && apt-get install -y wkhtmltopdf

RUN mkdir -p /mnt/extra-addons

COPY ./pharma_control_center /mnt/extra-addons/pharma_control_center

RUN chown -R odoo:odoo /mnt/extra-addons

USER odoo
757 changes: 757 additions & 0 deletions pharma_control_center/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pharma_control_center/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
44 changes: 44 additions & 0 deletions pharma_control_center/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
'name': 'Pharma Control Center',
'version': '1.0',
'summary': 'Pharmacy Dashboard, Medicines, Inventory & Operations',
'sequence': 10,
'description': """
Pharma Control Center
=====================
Central system for pharmacy operations:
- Medicine catalog with batch, expiry, price, stock
- Dashboard showing total medicines and stock value
- Role‑based access (Patient, Doctor, Manager)
""",
'category': 'Healthcare/Pharmacy',
'author': "Muhammad Qasim Shabbir AI developer.",
'website': 'https://www.odoo.com/app/invoicing',
'depends': [
'base_setup',
'product',
'account',
'sale',
],
'data': [
'security/groups.xml',
'security/pharmacy_security.xml',
'security/pharmacy_patient_security.xml',
'security/sale_order_security.xml',
'security/ir.model.access.csv',
'data/demo_patients.xml',
'data/demo_medicines.xml',
'views/pharma_control_center_views.xml', # root menu defined here
'views/pharmacy_medicine_views.xml',
'views/pharmacy_patient_views.xml', # now includes the menuitem
'views/pharmacy_category_views.xml',
'views/pharmacy_order_views.xml',
'views/pharmacy_cart_views.xml',
'views/sales_report_views.xml',
'views/manager_analytics_views.xml',
'views/privacy_policy_views.xml',
],
'installable': True,
'application': True,
'license': 'LGPL-3',
}
52 changes: 52 additions & 0 deletions pharma_control_center/data/demo_medicines.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<!-- Create a demo category first -->
<record id="demo_category_painkiller" model="pharmacy.category">
<field name="name">Painkiller</field>
<field name="code">PAIN</field>
<field name="description">Medicines for pain relief</field>
</record>

<!-- Demo medicine with white license (OTC) -->
<record id="demo_medicine_1" model="pharmacy.medicine">
<field name="name">Paracetamol 500mg</field>
<field name="batch_number">BATCH-001</field>
<field name="expiry_date">2025-12-31</field>
<field name="price">5.99</field>
<field name="cost_price">3.50</field>
<field name="quantity">100</field>
<field name="license_category">white</field>
<field name="category_id" ref="demo_category_painkiller"/>
<field name="storage_location">room_temp</field>
<field name="dosage">1 tablet every 4-6 hours</field>
</record>

<!-- Optional: Add blue (limited) and green (full) medicines -->
<record id="demo_medicine_2" model="pharmacy.medicine">
<field name="name">Amoxicillin 500mg</field>
<field name="batch_number">BATCH-002</field>
<field name="expiry_date">2026-06-30</field>
<field name="price">12.99</field>
<field name="cost_price">7.25</field>
<field name="quantity">50</field>
<field name="license_category">blue</field>
<field name="category_id" ref="demo_category_painkiller"/>
<field name="storage_location">cold</field>
<field name="dosage">1 capsule every 8 hours</field>
</record>

<record id="demo_medicine_3" model="pharmacy.medicine">
<field name="name">Morphine Sulphate</field>
<field name="batch_number">BATCH-003</field>
<field name="expiry_date">2025-08-15</field>
<field name="price">49.99</field>
<field name="cost_price">25.00</field>
<field name="quantity">10</field>
<field name="license_category">green</field>
<field name="category_id" ref="demo_category_painkiller"/>
<field name="storage_location">room_temp</field>
<field name="dosage">As prescribed by doctor</field>
</record>
</data>
</odoo>
43 changes: 43 additions & 0 deletions pharma_control_center/data/demo_patients.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<!-- Demo patients -->
<record id="demo_patient_1" model="pharmacy.patient">
<field name="name">Ali Khan</field>
<field name="doctor_id" ref="base.user_admin"/>
<field name="age">32</field>
<field name="gender">male</field>
<field name="blood_group">O+</field>
<field name="phone">+92 300 0000001</field>
<field name="email">ali.khan.demo@example.com</field>
<field name="address">Demo Address 1</field>
<field name="medical_history">Seasonal allergies</field>
<field name="allergies">Pollen</field>
</record>

<!-- ... more patients ... -->

<!-- Demo category -->
<record id="demo_category_painkiller" model="pharmacy.category">
<field name="name">Painkiller</field>
<field name="code">PAIN</field>
<field name="description">Medicines for pain relief</field>
</record>

<!-- Demo medicines -->
<record id="demo_medicine_1" model="pharmacy.medicine">
<field name="name">Paracetamol 500mg</field>
<field name="batch_number">BATCH-001</field>
<field name="expiry_date">2025-12-31</field>
<field name="price">5.99</field>
<field name="cost_price">3.50</field>
<field name="quantity">100</field>
<field name="license_category">white</field>
<field name="category_id" ref="demo_category_painkiller"/>
<field name="storage_location">room_temp</field>
<field name="dosage">1 tablet every 4-6 hours</field>
</record>

<!-- ... more medicines ... -->
</data>
</odoo>
108 changes: 108 additions & 0 deletions pharma_control_center/docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Architecture

This document describes how the `pharma_control_center` addon is structured and how the main flows work.
odoo-tutorials/pharma_control_center/
├── data/
│ ├── demo_medicines.xml
│ └── demo_patients.xml
├── docs/
│ ├── ARCHITECTURE.md
│ ├── CHANGELOG.md
│ ├── DEMO_DATA.md
│ ├── SECURITY.md
│ ├── TECHNICAL_DETAILS.md
│ └── USER_GUIDE.md
├── models/
│ ├── __init__.py
│ ├── pharma_control_center.py
│ ├── pharmacy_cart.py
│ ├── pharmacy_category.py
│ ├── pharmacy_interaction.py
│ ├── pharmacy_patient.py
│ ├── pharma_medicine.py
│ └── __pycache__/
├── security/
│ ├── groups.xml
│ ├── ir.model.access.csv
│ ├── pharmacy_patient_security.xml
│ ├── pharmacy_security.xml
│ └── sale_order_security.xml
├── tests/
│ └── (test files not shown)
├── views/
│ ├── manager_analytics_views.xml
│ ├── pharma_control_center_views.xml
│ ├── pharmacy_cart_views.xml
│ ├── pharmacy_category_views.xml
│ ├── pharmacy_interaction_views.xml
│ ├── pharmacy_medicine_views.xml
│ ├── pharmacy_order_views.xml
│ ├── pharmacy_patient_views.xml
│ └── sales_report_views.xml
├── __init__.py
├── __manifest__.py
├── README.md
└── __pycache__/
### Models

- `pharmacy.medicine`: medicine master data + custom stock + expiry logic
- `pharmacy.category`: medicine categories (parent/child hierarchy)
- `pharmacy.patient`: patient records linked to a doctor (`res.users`)
- `pharmacy.interaction`: interaction pairs used for cart warnings / blocking
- `pharmacy.cart` + `pharmacy.cart.line`: per-user cart and checkout logic
- `pharma.control.center`: dashboard/profile record

### Views / Menus

All menus live under the root menu **“💊 Your Pharma CC”**:

- **👤 User Dashboard**: `pharma.control.center` (form)
- **💊 Medicines**: `pharmacy.medicine` (kanban/list/form)
- **🛒 Order from Cart**: `pharmacy.cart` (form, filtered to the current user)
- **📄 Orders**: `sale.order` (list/form, restricted by record rules)
- **👥 Patients**: `pharmacy.patient` (doctor/manager only)
- **⚙️ Configuration → 📂 Categories**: `pharmacy.category` (manager only)
- **⚠️ Drug Interactions**: `pharmacy.interaction` (manager only)
- **📊 Analytics**: `sale.order` graph/pivot reporting (manager only)

## Key Business Flows

### 1) Add Medicine to Cart

Source: `models/pharma_medicine.py` (`pharmacy.medicine.add_to_cart`)

1. User sets `order_qty` on a medicine record.
2. The module finds (or creates) a `pharmacy.cart` for the current user.
3. A `pharmacy.cart.line` is created or updated for that medicine.

### 2) Cart Checkout

Source: `models/pharmacy_cart.py` (`pharmacy.cart.action_checkout`)

1. Validate cart is not empty.
2. Detect interactions between medicines in the cart:
- Any interaction with severity `severe` blocks checkout.
3. For each cart line:
- Ensure there is a linked `product.product` (created on demand).
- Build `sale.order.line` values (quantity + unit price from the medicine).
4. Create a `sale.order` for the current user’s partner.
5. Confirm the sale order.
6. Create an invoice and post it.
7. Reduce `pharmacy.medicine.quantity` by the purchased quantities.
8. Clear the cart lines.

### 3) Dashboard Statistics

Source: `models/pharma_control_center.py`

The dashboard computes live KPIs by querying:
- `pharmacy.medicine` (counts, expiry buckets, stock totals/value)
- `sale.order.line` (today’s quantity and sales amount)
- `pharmacy.patient` (doctor’s assigned patients / all patients for managers)
12 changes: 12 additions & 0 deletions pharma_control_center/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 1.0

- Medicine catalog with expiry/reorder indicators
- Per-user cart with barcode quick add
- Checkout flow: Sales Order creation + invoice posting + custom stock reduction
- Dashboard KPIs and “today’s orders” drill-down
- Patient records with doctor assignment
- Drug interaction warnings + severe-interaction checkout blocking
- Manager sales analytics (graph/pivot on Sales Orders)

24 changes: 24 additions & 0 deletions pharma_control_center/docs/DEMO_DATA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Demo Data

This addon ships optional demo data in `data/` (loaded when demo data is enabled for the database).

## Medicines

File: `data/demo_medicines.xml`

Creates:
- A sample category: **Painkiller** (`pharmacy.category`)
- Sample medicines (`pharmacy.medicine`) covering different license categories:
- Paracetamol 500mg (white)
- Amoxicillin 500mg (blue)
- Morphine Sulphate (green)

The demo expiry dates are intentionally mixed so you can test the *Fresh / Expiring Soon / Expired* badges depending on the current date.

## Patients

File: `data/demo_patients.xml`

Creates three sample patients (`pharmacy.patient`) assigned to:
- `base.user_admin` (Administrator)

44 changes: 44 additions & 0 deletions pharma_control_center/docs/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Security / Roles

This addon defines custom groups, model access rights (ACLs), and record rules under `security/`.

## Groups

Defined in `security/groups.xml`:
- `pharma_control_center.group_pharmacy_patient` (Patient)
- `pharma_control_center.group_pharmacy_doctor` (Doctor)
- `pharma_control_center.group_pharmacy_manager` (Manager)

All three groups currently imply `account.group_account_invoice` (invoice access).

## Record Rules (ir.rule)

### Medicines (`pharmacy.medicine`)
Defined in `security/pharmacy_security.xml`:
- Patient: only `license_category = white`
- Doctor: only `license_category in (blue, white)`
- Manager: no rule in this addon (sees all medicines)

### Patients (`pharmacy.patient`)
Defined in `security/pharmacy_patient_security.xml`:
- Doctor: only patients where `doctor_id = current user` (delete is not granted by the rule)
- Manager: all patients

### Sales Orders (`sale.order`)
Defined in `security/sale_order_security.xml`:
- Patient: only orders created by the current user
- Doctor: only orders created by the current user
- Manager: all orders

## Model Access Rights (ACL)

Defined in `security/ir.model.access.csv`.

Important notes:
- Odoo ACLs are **additive** across all groups a user belongs to. If a user has broad permissions from another group, that can widen access beyond what you expect.
- This addon currently includes several `base.group_user` ACL entries (full CRUD) for custom models. If you want strict Patient/Doctor separation, review and tighten these ACLs.

## UI-Level Restrictions

Some views/menus are restricted using `groups="..."` or view attributes (`create="false"`, `edit="false"`, `delete="false"`). These help with the user experience, but they are not a replacement for properly configured ACLs/record rules.

Loading