[IMP] add links between claim and invoice and picking

This commit is contained in:
Benoit Guillot
2012-06-11 12:23:57 +02:00
parent 2fc23fc956
commit c512f006ab
10 changed files with 137 additions and 4 deletions

View File

@@ -23,3 +23,5 @@
import wizard
import crm_claim_rma
import account_invoice
import stock

View File

@@ -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': [

View File

@@ -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 <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
class account_invoice(osv.osv):
_inherit = "account.invoice"
_columns = {
'claim_id': fields.many2one('crm.claim', 'Claim'),
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
crm_claim_rma for OpenERP
Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- INHERITED VIEW FOR THE OBJECT : account_invoice -->
<record id="crm_claim_rma.invoice_form" model="ir.ui.view">
<field name="name">crm_claim_rma.invoice_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field eval="16" name="priority"/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/notebook/page[@string='Other Info']/field[@name='origin']" position="after">
<field name="claim_id" attrs="{'invisible':[('type','!=','out_refund')]}"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

View File

@@ -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'),

View File

@@ -215,6 +215,10 @@
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/group/notebook/page[@string='Communication &amp; History']/field" position="after">
<field name="invoice_ids" colspan="4" nolabel="1" readonly="1"/>
<field name="picking_ids" colspan="4" nolabel="1" readonly="1"/>
</xpath>
<page string="Communication &amp; History" position="after">
<page string="Product return">
<field name="return_line_ids" nolabel="1" colspan="4"/>

33
crm_claim_rma/stock.py Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>. #
#########################################################################
from osv import fields, osv
class stock_picking(osv.osv):
_inherit = "stock.picking"
_columns = {
'claim_id': fields.many2one('crm.claim', 'Claim'),
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
crm_claim_rma for OpenERP
Copyright (C) 2011 Akretion Benoît Guillot <benoit.guillot@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- INHERITED VIEW FOR THE OBJECT : stock_picking -->
<record id="crm_claim_rma.picking_form" model="ir.ui.view">
<field name="name">crm_claim_rma.picking_form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_in_form" />
<field eval="16" name="priority"/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/notebook/page[@string='Additional Info']/field[@name='type']" position="after">
<field name="claim_id" attrs="{'invisible':[('type','!=','in')]}"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>

View File

@@ -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:

View File

@@ -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,