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",
|
||||
"category": "Purchase",
|
||||
"summary": "Link customer requisition references to purchase orders",
|
||||
"description": """
|
||||
This module allows to:
|
||||
* Store customer-specific requisition references for suppliers
|
||||
* Automatically add these references to purchase order lines
|
||||
* Track customer requisition numbers across purchase orders
|
||||
"description": """\
|
||||
Advanced Customer Requisition Management
|
||||
|
||||
Key Features:
|
||||
- 🔗 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",
|
||||
"depends": [
|
||||
|
|
@ -21,7 +31,6 @@
|
|||
"data": [
|
||||
"views/purchase_views.xml",
|
||||
"views/purchase_requisition_views.xml",
|
||||
"views/purchase_order_views.xml",
|
||||
],
|
||||
"installable": True,
|
||||
"application": False,
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
from . import purchase_order_line
|
||||
from . import purchase_requisition
|
||||
from . import purchase_order
|
||||
|
|
|
|||
|
|
@ -3,28 +3,19 @@ from odoo import models
|
|||
class PurchaseOrder(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
|
||||
def _merge_alternative_po(self, rfqs):
|
||||
"""Override to handle requisition_id during merge.
|
||||
|
||||
Args:
|
||||
rfqs: recordset of purchase.order to merge
|
||||
def action_merge(self):
|
||||
"""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)
|
||||
|
||||
Returns:
|
||||
purchase.order: the merged purchase order
|
||||
"""
|
||||
# Only merge orders in draft or sent state
|
||||
rfqs = rfqs.filtered(lambda o: o.state in ('draft', 'sent'))
|
||||
|
||||
# Get the oldest order as base
|
||||
base_order = rfqs.sorted(lambda x: (x.date_order, x.id))[0]
|
||||
|
||||
# Call parent method to merge orders
|
||||
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
|
||||
# Only clear requisition_ids if they are different
|
||||
if len(unique_requisitions) > 1:
|
||||
self.write({'requisition_id': False})
|
||||
|
||||
# Call parent method to perform merge
|
||||
result = super().action_merge()
|
||||
|
||||
return result
|
||||
|
||||
return super().action_merge()
|
||||
|
|
|
|||
|
|
@ -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