| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Purchase (purchase)
• Invoicing (account) • Discuss (mail) |
| Lines of code | 101 |
| Technical Name |
purchase_advance_description |
| License | LGPL-3 |
| Website | https://github.com/kurniawanlucky/odoo_addons |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Purchase (purchase)
• Invoicing (account) • Discuss (mail) |
| Lines of code | 101 |
| Technical Name |
purchase_advance_description |
| License | LGPL-3 |
| Website | https://github.com/kurniawanlucky/odoo_addons |
Purchase Advance Description
Inject dynamic purchase line descriptions from product categories
Add short Python snippets on product categories to populate purchase order line descriptions automatically. You get code validation and typo checks before saving.
What this module does
- Adds a
Purchase Description Codefield on product categories. - Executes the snippet when a product from that category is added to a purchase order line.
- Provides validation: syntax check plus a dry-run on dummy data to catch typos.
- Exposes
product_id,product_template_id,purchase_order_line, andsale_order_linein the snippet context.
How to use
- Install the module and update the Apps list if needed.
- Open any product category > Purchase Description tab.
- Enter a Python snippet that assigns the final text to
result. - Save the category. Validation will catch syntax errors and obvious typos.
- Add a product from that category to a Purchase Order: the line description auto-includes your computed text.
Examples
| Scenario | Snippet |
|---|---|
| Internal reference + origin | result = product_id.default_code + " - " + product_id.country_of_origin.name |
| Template code fallback | result = product_template_id.default_code or product_id.default_code |
| Include UoM and vendor | result = f"{product_id.display_name} / {purchase_order_line.product_uom.name}" |
| Conditional note | result = product_id.default_code
if product_id.country_of_origin:
result += " - " + product_id.country_of_origin.name |
Validation behavior
- Syntax/opcode check via
test_python_expr. - Dry-run with dummy product/template/country objects to catch typos (e.g.,
contry_of_origin). - On error, the category save fails with a clear message; fix the snippet and save again.
Download & install
- Place this module directory under your Odoo addons path (see
addons_pathinodoo.conf). - Update the Apps list (Apps > Update Apps List).
- Search for Purchase Advance Description and install it.
If you ship this module elsewhere, include this index.html so users can read the quick guide.
Quick test recipe
- Create a category and paste
result = product_id.default_code + " - " + product_id.country_of_origin.name. - Assign a product to that category and set its Internal Reference and Country of Origin.
- Create a Purchase Order and add the product. The description should show the code and country.
Please log in to comment on this module