From c7d32f4f82ebe8f3646149270eb74eb8b09568f2 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Mon, 17 Feb 2014 18:00:17 +0100 Subject: [PATCH] [ADD] a delivery addresse set as default to invoice address as we don't want commercial partner but an address to send back products --- crm_claim_rma/__openerp__.py | 1 + crm_claim_rma/crm_claim_rma.py | 15 ++++++++++++++- crm_claim_rma/crm_claim_rma_view.xml | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crm_claim_rma/__openerp__.py b/crm_claim_rma/__openerp__.py index 270239a3..92473db9 100644 --- a/crm_claim_rma/__openerp__.py +++ b/crm_claim_rma/__openerp__.py @@ -65,6 +65,7 @@ Contributors: * BenoƮt Guillot * Joel Grand-Guillaume * Guewen Baconnier + * Yannick Vaucher """, 'author': 'Akretion, Camptocamp', diff --git a/crm_claim_rma/crm_claim_rma.py b/crm_claim_rma/crm_claim_rma.py index 68fd0851..a1a60a32 100644 --- a/crm_claim_rma/crm_claim_rma.py +++ b/crm_claim_rma/crm_claim_rma.py @@ -393,6 +393,10 @@ class crm_claim(orm.Model): 'invoice_id': fields.many2one( 'account.invoice', string='Invoice', help='Related original Cusotmer invoice'), + 'delivery_address_id': fields.many2one( + 'res.partner', string='Partner delivery address', + help="This address will be used to deliver repaired or replacement" + "products."), 'warehouse_id': fields.many2one( 'stock.warehouse', string='Warehouse', required=True), @@ -425,12 +429,14 @@ class crm_claim(orm.Model): def onchange_invoice_id(self, cr, uid, ids, invoice_id, warehouse_id, context=None): invoice_line_obj = self.pool.get('account.invoice.line') + invoice_obj = self.pool.get('account.invoice') claim_line_obj = self.pool.get('claim.line') invoice_line_ids = invoice_line_obj.search( cr, uid, [('invoice_id', '=', invoice_id)], context=context) claim_lines = [] + value = {} if not warehouse_id: warehouse_id = self._get_default_warehouse(cr, uid, context=context) invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids, @@ -449,7 +455,14 @@ class crm_claim(orm.Model): 'location_dest_id': location_dest_id, 'state': 'draft', }) - return {'value': {'claim_line_ids': claim_lines}} + value = {'claim_line_ids': claim_lines} + delivery_address_id = False + if invoice_id: + invoice = invoice_obj.browse(cr, uid, invoice_id, context=context) + delivery_address_id = invoice.partner_id.id + value['delivery_address_id'] = delivery_address_id + + return {'value': value} def message_get_reply_to(self, cr, uid, ids, context=None): """ Override to get the reply_to of the parent project. """ diff --git a/crm_claim_rma/crm_claim_rma_view.xml b/crm_claim_rma/crm_claim_rma_view.xml index ea9dab7a..bebb0f80 100644 --- a/crm_claim_rma/crm_claim_rma_view.xml +++ b/crm_claim_rma/crm_claim_rma_view.xml @@ -166,6 +166,7 @@ +