From c512f006abfecc1c08ba363a1fc33715a620614b Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Mon, 11 Jun 2012 12:23:57 +0200 Subject: [PATCH] [IMP] add links between claim and invoice and picking --- crm_claim_rma/__init__.py | 2 ++ crm_claim_rma/__openerp__.py | 2 ++ crm_claim_rma/account_invoice.py | 33 +++++++++++++++++++ crm_claim_rma/account_invoice_view.xml | 27 +++++++++++++++ crm_claim_rma/crm_claim_rma.py | 2 ++ crm_claim_rma/crm_claim_rma_view.xml | 4 +++ crm_claim_rma/stock.py | 33 +++++++++++++++++++ crm_claim_rma/stock_view.xml | 27 +++++++++++++++ .../wizard/picking_from_returned_lines.py | 4 ++- .../wizard/refund_from_returned_lines.py | 7 ++-- 10 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 crm_claim_rma/account_invoice.py create mode 100644 crm_claim_rma/account_invoice_view.xml create mode 100644 crm_claim_rma/stock.py create mode 100644 crm_claim_rma/stock_view.xml diff --git a/crm_claim_rma/__init__.py b/crm_claim_rma/__init__.py index 14e4b193..4a6a0527 100644 --- a/crm_claim_rma/__init__.py +++ b/crm_claim_rma/__init__.py @@ -23,3 +23,5 @@ import wizard import crm_claim_rma +import account_invoice +import stock diff --git a/crm_claim_rma/__openerp__.py b/crm_claim_rma/__openerp__.py index 6c129557..06706b47 100644 --- a/crm_claim_rma/__openerp__.py +++ b/crm_claim_rma/__openerp__.py @@ -53,6 +53,8 @@ THIS MODULE REPLACES Akretion stock_rma from V6.0 'wizard/get_empty_serial_view.xml', 'crm_claim_rma_view.xml', 'security/ir.model.access.csv', + 'account_invoice_view.xml', + 'stock_view.xml', # 'report/crm_claim_report_view.xml', ], 'demo_xml': [ diff --git a/crm_claim_rma/account_invoice.py b/crm_claim_rma/account_invoice.py new file mode 100644 index 00000000..c710f968 --- /dev/null +++ b/crm_claim_rma/account_invoice.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +######################################################################### +# # +# # +######################################################################### +# # +# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, # +# Emmanuel Samyn, Benoît Guillot # +# # +#This program is free software: you can redistribute it and/or modify # +#it under the terms of the GNU General Public License as published by # +#the Free Software Foundation, either version 3 of the License, or # +#(at your option) any later version. # +# # +#This program is distributed in the hope that it will be useful, # +#but WITHOUT ANY WARRANTY; without even the implied warranty of # +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +#GNU General Public License for more details. # +# # +#You should have received a copy of the GNU General Public License # +#along with this program. If not, see . # +######################################################################### + +from osv import fields, osv + +class account_invoice(osv.osv): + + _inherit = "account.invoice" + + + _columns = { + 'claim_id': fields.many2one('crm.claim', 'Claim'), + } diff --git a/crm_claim_rma/account_invoice_view.xml b/crm_claim_rma/account_invoice_view.xml new file mode 100644 index 00000000..0a6eb798 --- /dev/null +++ b/crm_claim_rma/account_invoice_view.xml @@ -0,0 +1,27 @@ + + + + + + + + + crm_claim_rma.invoice_form + account.invoice + + + form + + + + + + + + + + diff --git a/crm_claim_rma/crm_claim_rma.py b/crm_claim_rma/crm_claim_rma.py index 2a978a16..b1e71dec 100644 --- a/crm_claim_rma/crm_claim_rma.py +++ b/crm_claim_rma/crm_claim_rma.py @@ -263,6 +263,8 @@ class crm_claim_product_return(osv.osv): 'planned_cost': fields.float('Expected cost'), 'real_revenue': fields.float('Real revenue'), # A VOIR SI COMPTA ANA ou lien vers compte ana ? 'real_cost': fields.float('Real cost'), # A VOIR SI COMPTA ANA ou lien vers compte ana ? + 'invoice_ids': fields.one2many('account.invoice', 'claim_id', 'Refunds'), + 'picking_ids': fields.one2many('stock.picking', 'claim_id', 'RMA') } _defaults = { 'sequence': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'crm.claim'), diff --git a/crm_claim_rma/crm_claim_rma_view.xml b/crm_claim_rma/crm_claim_rma_view.xml index 5ab0de33..f51b6b94 100644 --- a/crm_claim_rma/crm_claim_rma_view.xml +++ b/crm_claim_rma/crm_claim_rma_view.xml @@ -215,6 +215,10 @@ crm.claim + + + + diff --git a/crm_claim_rma/stock.py b/crm_claim_rma/stock.py new file mode 100644 index 00000000..ac7522b6 --- /dev/null +++ b/crm_claim_rma/stock.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +######################################################################### +# # +# # +######################################################################### +# # +# Copyright (C) 2009-2011 Akretion, Raphaël Valyi, Sébastien Beau, # +# Emmanuel Samyn, Benoît Guillot # +# # +#This program is free software: you can redistribute it and/or modify # +#it under the terms of the GNU General Public License as published by # +#the Free Software Foundation, either version 3 of the License, or # +#(at your option) any later version. # +# # +#This program is distributed in the hope that it will be useful, # +#but WITHOUT ANY WARRANTY; without even the implied warranty of # +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +#GNU General Public License for more details. # +# # +#You should have received a copy of the GNU General Public License # +#along with this program. If not, see . # +######################################################################### + +from osv import fields, osv + +class stock_picking(osv.osv): + + _inherit = "stock.picking" + + + _columns = { + 'claim_id': fields.many2one('crm.claim', 'Claim'), + } diff --git a/crm_claim_rma/stock_view.xml b/crm_claim_rma/stock_view.xml new file mode 100644 index 00000000..c6191a3e --- /dev/null +++ b/crm_claim_rma/stock_view.xml @@ -0,0 +1,27 @@ + + + + + + + + + crm_claim_rma.picking_form + stock.picking + + + form + + + + + + + + + + diff --git a/crm_claim_rma/wizard/picking_from_returned_lines.py b/crm_claim_rma/wizard/picking_from_returned_lines.py index d977c0e0..494aa8f0 100644 --- a/crm_claim_rma/wizard/picking_from_returned_lines.py +++ b/crm_claim_rma/wizard/picking_from_returned_lines.py @@ -66,6 +66,7 @@ class picking_in_from_returned_lines(osv.osv_memory): # If "Create" button pressed def action_create_picking(self, cr, uid, ids, context=None): partner_id = 0 + wf_service = netsvc.LocalService("workflow") for picking in self.browse(cr, uid,ids): claim_id = self.pool.get('crm.claim').browse(cr, uid, context['active_id']) partner_id = claim_id.partner_id.id @@ -77,7 +78,7 @@ class picking_in_from_returned_lines(osv.osv_memory): location = claim_id.partner_id.property_stock_supplier.id # create picking picking_id = self.pool.get('stock.picking').create(cr, uid, { - 'origin': claim_id.sequence, + 'origin': "RMA/"+`claim_id.sequence`, 'type': 'in', 'move_type': 'one', # direct 'state': 'draft', @@ -88,6 +89,7 @@ class picking_in_from_returned_lines(osv.osv_memory): 'location_id': location, 'location_dest_id': picking.return_line_location.id, 'note' : 'RMA picking in', + 'claim_id': claim_id.id, }) # Create picking lines for picking_line in picking.return_line_ids: diff --git a/crm_claim_rma/wizard/refund_from_returned_lines.py b/crm_claim_rma/wizard/refund_from_returned_lines.py index 797e5e76..fc5a2918 100644 --- a/crm_claim_rma/wizard/refund_from_returned_lines.py +++ b/crm_claim_rma/wizard/refund_from_returned_lines.py @@ -77,7 +77,7 @@ class refund_from_returned_lines(osv.osv_memory): # create invoice invoice_id = self.pool.get('account.invoice').create(cr, uid, { 'claim_origine' : "none", - 'origin' : claim_id.id, + 'origin' : claim_id.sequence, 'type' : invoice_type, 'state' : 'draft', 'partner_id' : claim_id.partner_id.id, @@ -91,14 +91,15 @@ class refund_from_returned_lines(osv.osv_memory): 'currency_id' : claim_id.company_id.currency_id.id, # from invoice ??? 'journal_id' : refund.refund_journal.id, 'company_id' : claim_id.company_id.id, - 'comment' : 'RMA Refound', + 'comment' : 'RMA Refund', + 'claim_id': claim_id, }) # Create invoice lines for refund_line in refund.return_line_ids: if refund_line.invoice_id: invoice_line_id = self.pool.get('account.invoice.line').create(cr, uid, { 'name' : refund_line.product_id.name_template, - 'origin' : claim_id.id, + 'origin' : claim_id.sequence, 'invoice_id' : invoice_id, 'uos_id' : refund_line.product_id.uom_id.id, 'product_id':refund_line.product_id.id,