fix for merge PO with requisition id
This commit is contained in:
parent
996fb3767e
commit
e1e8c94c94
4 changed files with 31 additions and 44 deletions
|
|
@ -3,11 +3,21 @@
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"category": "Purchase",
|
"category": "Purchase",
|
||||||
"summary": "Link customer requisition references to purchase orders",
|
"summary": "Link customer requisition references to purchase orders",
|
||||||
"description": """
|
"description": """\
|
||||||
This module allows to:
|
Advanced Customer Requisition Management
|
||||||
* Store customer-specific requisition references for suppliers
|
|
||||||
* Automatically add these references to purchase order lines
|
Key Features:
|
||||||
* Track customer requisition numbers across purchase orders
|
- 🔗 Customer-specific requisition tracking in purchase orders
|
||||||
|
- 👥 Multi-customer agreement management
|
||||||
|
- 🔄 Automated price synchronization from framework contracts
|
||||||
|
- 🔍 Optimized search via key field indexing
|
||||||
|
- 📊 Full integration with Purchase, Sale and Stock modules
|
||||||
|
|
||||||
|
Use Cases:
|
||||||
|
1. Centralized management of customer procurement agreements
|
||||||
|
2. Automated PO line referencing from customer contracts
|
||||||
|
3. Real-time price updates from master agreements
|
||||||
|
4. Unified purchasing/customer reporting
|
||||||
""",
|
""",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"depends": [
|
"depends": [
|
||||||
|
|
@ -21,7 +31,6 @@
|
||||||
"data": [
|
"data": [
|
||||||
"views/purchase_views.xml",
|
"views/purchase_views.xml",
|
||||||
"views/purchase_requisition_views.xml",
|
"views/purchase_requisition_views.xml",
|
||||||
"views/purchase_order_views.xml",
|
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"application": False,
|
"application": False,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
from . import purchase_order_line
|
from . import purchase_order_line
|
||||||
from . import purchase_requisition
|
from . import purchase_requisition
|
||||||
|
from . import purchase_order
|
||||||
|
|
|
||||||
|
|
@ -3,28 +3,19 @@ from odoo import models
|
||||||
class PurchaseOrder(models.Model):
|
class PurchaseOrder(models.Model):
|
||||||
_inherit = 'purchase.order'
|
_inherit = 'purchase.order'
|
||||||
|
|
||||||
def _merge_alternative_po(self, rfqs):
|
def action_merge(self):
|
||||||
"""Override to handle requisition_id during merge.
|
"""Override to clear requisition_id before merging multiple POs"""
|
||||||
|
if len(self) > 1:
|
||||||
|
# Check if all POs have the same requisition_id
|
||||||
|
unique_requisitions = set(order.requisition_id.id for order in self if order.requisition_id)
|
||||||
|
|
||||||
Args:
|
# Only clear requisition_ids if they are different
|
||||||
rfqs: recordset of purchase.order to merge
|
if len(unique_requisitions) > 1:
|
||||||
|
self.write({'requisition_id': False})
|
||||||
|
|
||||||
Returns:
|
# Call parent method to perform merge
|
||||||
purchase.order: the merged purchase order
|
result = super().action_merge()
|
||||||
"""
|
|
||||||
# Only merge orders in draft or sent state
|
|
||||||
rfqs = rfqs.filtered(lambda o: o.state in ('draft', 'sent'))
|
|
||||||
|
|
||||||
# Get the oldest order as base
|
return result
|
||||||
base_order = rfqs.sorted(lambda x: (x.date_order, x.id))[0]
|
|
||||||
|
|
||||||
# Call parent method to merge orders
|
return super().action_merge()
|
||||||
merged_order = super()._merge_alternative_po(rfqs)
|
|
||||||
|
|
||||||
# After merge, ensure lines are properly linked to their requisitions
|
|
||||||
for line in merged_order.order_line:
|
|
||||||
line._compute_requisition_id()
|
|
||||||
if line.requisition_id and line.requisition_line_id:
|
|
||||||
line.price_unit = line.requisition_line_id.price_unit
|
|
||||||
|
|
||||||
return merged_order
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="purchase_order_form_inherit_requisition" model="ir.ui.view">
|
|
||||||
<field name="name">purchase.order.form.inherit.requisition</field>
|
|
||||||
<field name="model">purchase.order</field>
|
|
||||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<!-- Masquer le champ requisition_id -->
|
|
||||||
<field name="requisition_id" position="attributes">
|
|
||||||
<attribute name="invisible">1</attribute>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
Loading…
Reference in a new issue