addons-cm/product_get_price_helper/README.md
snt b10ba1fc15 [DOC] all: Reorganize and consolidate project documentation
- Create .github/copilot-instructions.md with global development guidelines
- Add comprehensive README.md at project root with quick start guide
- Create docs/ directory for technical documentation
- Move installation and linter docs to docs/
- Add docs/TRANSLATIONS.md with complete translation system guide
- Create README.md for OCA modified addons (product_origin, product_get_price_helper, product_main_seller)
- Document translation best practices (no _() in field definitions)
- Add references between all documentation files
- Clean up project root by moving technical docs to docs/

All documentation now properly references addon-specific READMEs for detailed architecture and implementation.
2026-02-12 16:25:49 +01:00

124 lines
2.7 KiB
Markdown

# Product Get Price Helper
## Summary
Provides a helper utility function to compute product prices with taxes, discounts, and unit of measure conversions.
## Features
- **Price Calculation Utility**: Helper method `get_product_price_for_pricelist`
- **Tax Handling**: Automatically computes prices with or without taxes
- **Discount Support**: Handles single and multiple discounts
- **UoM Conversion**: Converts prices between different units of measure
- **Reusable**: Can be used by other modules for price calculations
## Technical Details
### Utility Function
Located in `utils.py`:
```python
def get_product_price_for_pricelist(
product,
qty,
pricelist,
partner=None,
uom=None,
date=None,
include_tax=False
)
```
**Parameters**:
- `product`: Product record (product.product or product.template)
- `qty`: Quantity
- `pricelist`: Pricelist to use for calculation
- `partner`: Partner record (optional)
- `uom`: Unit of measure (optional, uses product default if not provided)
- `date`: Date for pricelist rules (optional, uses today if not provided)
- `include_tax`: Boolean, whether to include taxes in the result
**Returns**: Decimal price
### How It Works
1. Gets base price from pricelist
2. Applies any applicable discounts
3. Converts price if different UoM is specified
4. Adds taxes if `include_tax=True`
## Dependencies
- `account` (Odoo core)
- `product` (Odoo core)
## Installation
```bash
docker-compose exec odoo odoo -d odoo -u product_get_price_helper --stop-after-init
```
## Usage
### Example: Calculate Price with Tax
```python
from odoo.addons.product_get_price_helper.utils import get_product_price_for_pricelist
price = get_product_price_for_pricelist(
product=product_record,
qty=10,
pricelist=pricelist_record,
partner=partner_record,
include_tax=True
)
```
### Example: Calculate Price with Different UoM
```python
price = get_product_price_for_pricelist(
product=product_record,
qty=1,
pricelist=pricelist_record,
uom=kg_uom, # Different from product's default UoM
include_tax=False
)
```
## OCA Source
- **Repository**: [product-attribute](https://github.com/OCA/product-attribute)
- **Original Author**: ACSONE SA/NV
- **License**: AGPL-3
## Modifications for Kidekoop
None - Used as-is from OCA.
## Used By
This helper is used by other modules in the project:
- `product_sale_price_from_pricelist` - For automatic price calculations
- `product_price_category` - For category-based pricing
## Demo Data
Includes demo data with:
- Sample accounts
- Sample pricelists
Located in `demo/` directory.
## Translations
- ✅ Spanish (es)
- ✅ Euskera (eu)
Located in `i18n/` directory.
---
**Version**: 18.0.1.1.0
**License**: AGPL-3