Merge pull request #40 from vauxoo-dev/8.0-squash_crm_rma_claim_make_claim_module_between_oca_vauxoo

[ADD] new module to create supplier claim in customer claim.
This commit is contained in:
Pedro M. Baeza
2016-01-06 21:44:13 -05:00
15 changed files with 655 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
========================
CRM RMA Claim Make Claim
========================
This module allows to create Vendor claim lines from Customer claims grouping those customer claims lines by its supplier.
Installation
============
To install this module, you need to select it from available modules
Configuration
=============
No extra configuration is needed for this module
Usage
=====
* Go to **After-sale services** > **Claims**.
* Note that new button red-highlighted called **Create RMA Vendor** has taken place.
* Click on it and after lines are processed, it will show RMA Claim lines
ready to be processed.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/145/8.0
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
For further information, please visit:
* https://www.odoo.com/forum/help-1
Known issues / Roadmap
======================
* **Create RMA Vendor** button shows even if a claim is vendor-based
* Claims lines have no vendor claim associated, after-button process must be done
manually
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/rma/issues/new?body=module:%20crm_rma_claim_make_claim%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Yanina Aular <yanina.aular@vauxoo.com>
* Osval Reyes <osval@vauxoo.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author : Yanina Aular <yani@vauxoo.com>
# Osval Reyes <osval@vauxoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import models

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author : Yanina Aular <yani@vauxoo.com>
# Osval Reyes <osval@vauxoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'CRM RMA Claim Make Claim',
'version': '8.0.1.0.0',
'author': 'Vauxoo',
'website': 'http://www.vauxoo.com/',
'license': 'AGPL-3',
'category': '',
'depends': [
'stock',
'crm_claim_rma',
'crm_claim_product_supplier',
],
'data': [
'views/crm_claim.xml',
'views/claim_line.xml',
],
'installable': True,
}

View File

@@ -0,0 +1,72 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_claim_make_claim
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-03 15:33+0000\n"
"PO-Revision-Date: 2015-09-03 15:33+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: crm_rma_claim_make_claim
#: help:crm.claim,claim_ids:0
msgid " - For a Vendor Claim means the RMA-C that generates the current RMA-V.\n"
" - For a Customer Claim means the RMA-V generated to fulfill the current RMA-C."
msgstr ""
#. module: crm_rma_claim_make_claim
#: model:ir.model,name:crm_rma_claim_make_claim.model_crm_claim
msgid "Claim"
msgstr ""
#. module: crm_rma_claim_make_claim
#: view:crm.claim:crm_rma_claim_make_claim.crm_claim_workflow_view
msgid "Create RMA Vendor"
msgstr ""
#. module: crm_rma_claim_make_claim
#: code:addons/crm_rma_claim_make_claim/models/crm_claim.py:54
#: code:addons/crm_rma_claim_make_claim/models/crm_claim.py:99
#, python-format
msgid "Error"
msgstr ""
#. module: crm_rma_claim_make_claim
#: model:ir.model,name:crm_rma_claim_make_claim.model_claim_line
msgid "List of product to return"
msgstr ""
#. module: crm_rma_claim_make_claim
#: view:crm.claim:crm_rma_claim_make_claim.crm_claim_form_view_inherited
#: field:crm.claim,claim_ids:0
msgid "Related Claims"
msgstr ""
#. module: crm_rma_claim_make_claim
#: field:claim.line,claim_line_id:0
msgid "Related claim line"
msgstr ""
#. module: crm_rma_claim_make_claim
#: code:addons/crm_rma_claim_make_claim/models/crm_claim.py:100
#, python-format
msgid "The Supplier Claim Was Not Created."
msgstr ""
#. module: crm_rma_claim_make_claim
#: code:addons/crm_rma_claim_make_claim/models/crm_claim.py:55
#, python-format
msgid "The claim client have claim supplier created."
msgstr ""
#. module: crm_rma_claim_make_claim
#: help:claim.line,claim_line_id:0
msgid "To link to the claim line object"
msgstr ""

View File

@@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_claim_make_claim
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:38+0000\n"
"PO-Revision-Date: 2015-07-17 19:38+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: crm_rma_claim_make_claim
#: help:crm.claim,claim_ids:0
msgid " - For a Vendor Claim means the RMA-C that generate the current RMA-V.\n"
" - For a Custtomer Claim means the RMA-V generated to fullfill the current RMA-C."
msgstr " - Para un reclamo a proveedor corresponde a los reclamos a cliente relacionados con él.\n
- Para un reclamo a cliente, corresponde a los reclamos a proveedor que fueron generados a partir de él."
#. module: crm_rma_claim_make_claim
#: model:ir.model,name:crm_rma_claim_make_claim.model_crm_claim
msgid "Claim"
msgstr "Reclamo"
#. module: crm_rma_claim_make_claim
#: view:crm.claim:crm_rma_claim_make_claim.crm_claim_workflow_view
msgid "Create RMA Vendor"
msgstr "Crear RMA proveedor"
#. module: crm_rma_claim_make_claim
#: code:addons/crm_rma_claim_make_claim/model/crm_claim_rma.py:74
#: code:addons/crm_rma_claim_make_claim/model/crm_claim_rma.py:133
#, python-format
msgid "Error"
msgstr "Error"
#. module: crm_rma_claim_make_claim
#: model:ir.model,name:crm_rma_claim_make_claim.model_claim_line
msgid "List of product to return"
msgstr "Lista de productos a devolver"
#. module: crm_rma_claim_make_claim
#: view:crm.claim:crm_rma_claim_make_claim.crm_claim_form_view_inherited
#: field:crm.claim,claim_ids:0
msgid "Related Claims"
msgstr "Reclamos relacionados"
#. module: crm_rma_claim_make_claim
#: field:claim.line,claim_line_id:0
msgid "Related claim line"
msgstr "Línea de reclamo relacionada"
#. module: crm_rma_claim_make_claim
#: code:addons/crm_rma_claim_make_claim/model/crm_claim_rma.py:134
#, python-format
msgid "The Supplier Claim Was Not Created."
msgstr "El reclamo a proveedor no fue creado"
#. module: crm_rma_claim_make_claim
#: code:addons/crm_rma_claim_make_claim/model/crm_claim_rma.py:75
#, python-format
msgid "The claim client have claim supplier created."
msgstr "El reclamo de cliente tiene un reclamo a proveedor creado."
#. module: crm_rma_claim_make_claim
#: help:claim.line,claim_line_id:0
msgid "To link to the claim line object"
msgstr "Relacionar a la línea de reclamo"

View File

@@ -0,0 +1,16 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_claim_make_claim
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:38+0000\n"
"PO-Revision-Date: 2015-07-17 19:38+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View File

@@ -0,0 +1,16 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_claim_make_claim
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:38+0000\n"
"PO-Revision-Date: 2015-07-17 19:38+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View File

@@ -0,0 +1,16 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_rma_claim_make_claim
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-17 19:38+0000\n"
"PO-Revision-Date: 2015-07-17 19:38+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author : Yanina Aular <yani@vauxoo.com>
# Osval Reyes <osval@vauxoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import claim_line
from . import crm_claim

View File

@@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author : Yanina Aular <yani@vauxoo.com>
# Osval Reyes <osval@vauxoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import _, api, fields, models
from openerp.exceptions import Warning as UserError
class ClaimLine(models.Model):
_inherit = 'claim.line'
claim_line_id = fields.Many2one('claim.line',
string='Related claim line',
help="To link to the claim line object")
@api.multi
def button_create_line_rma_vendor(self):
"""
Create RMA Vendor.
"""
good_lines = []
claim_obj = self.env['crm.claim']
claim_line_obj = self.env['claim.line']
claim_type_supplier = self.env.\
ref('crm_claim_type.crm_claim_type_supplier')
stage_new = self.env.ref('crm_claim.stage_claim1')
for claim_line_parent in self:
# Search a claim line with this claim line
# like parent, if there is a line with
# this claim line like parent, then, the
# supplier claim line for this claim line
# was created
claim_line_supplier = \
claim_line_obj.search([('claim_line_id',
'=',
claim_line_parent.id)])
if claim_line_supplier:
raise UserError(
_('Error'),
_('The claim client have claim supplier created.'))
# Search a supplier claim with new stage and add it
# the new supplier claim line to that supplier claim
# and to can acumulate multiples lines in a supplier
# claim and to send to same supplier in a one travel.
claim_supplier = claim_obj.search([('claim_type', '=',
claim_type_supplier.id),
('stage_id', '=', stage_new.id),
('partner_id', '=',
claim_line_parent.
supplier_id.id)])
if not claim_supplier:
claim_supplier = claim_obj.create({
'name': 'Supplier Claim',
'code': '/',
'claim_type': claim_type_supplier.id,
'partner_id': claim_line_parent.supplier_id.id,
'categ_id': claim_line_parent.claim_id.categ_id.id,
'warehouse_id': claim_line_parent.claim_id.warehouse_id.id,
'email_from': claim_line_parent.supplier_id.email,
'partner_phone': claim_line_parent.supplier_id.phone,
'delivery_address_id': claim_line_parent.supplier_id.id,
})
elif len(claim_supplier) > 1:
# search the supplier claim with less lines
claims = [(claim, len(claim.claim_line_ids))
for claim in claim_supplier]
claims = dict(claims)
claim_supplier = min(claims, key=claims.get)
claim_line_supplier_new = \
claim_line_obj.create({
'name': claim_line_parent.name,
'claim_id': claim_supplier and claim_supplier.id or False,
'claim_type': claim_type_supplier.id,
'claim_line_id': claim_line_parent.id,
'number': '/',
'product_id': claim_line_parent.product_id.id,
'invoice_line_id': claim_line_parent.prodlot_id.
supplier_invoice_line_id.id,
'claim_origin': claim_line_parent.claim_origin,
'prodlot_id': claim_line_parent.prodlot_id.id,
'priority': claim_line_parent.priority,
})
good_lines += [claim_line_supplier_new.id]
if not good_lines:
raise UserError(
_('Error'),
_('The Supplier Claim Was Not Created.'))
good_lines = list(set(good_lines))
result = self.env.ref('crm_claim_rma.'
'act_crm_case_claim_lines')
result = result.read()
result[0]['domain'] = "[('id','in'," + str(good_lines) + ")]"
return result
@api.multi
def button_rma_vendor_render_view(self):
result = self.button_create_line_rma_vendor()
return result[0]

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author : Yanina Aular <yani@vauxoo.com>
# Osval Reyes <osval@vauxoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import fields, models
class CrmClaim(models.Model):
_inherit = 'crm.claim'
claim_ids = fields.Many2many('crm.claim',
'claim_rel',
'claim_parent',
'claim_child',
string="Related Claims",
help=" - For a Vendor Claim means"
" the RMA-C that generates the"
" current RMA-V.\n"
" - For a Customer Claim means"
" the RMA-V generated to"
" fulfill the current RMA-C.")

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author : Osval Reyes <osval@vauxoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import test_crm_rma_claim_make_claim

View File

@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2015 Vauxoo
# Author: Osval Reyes
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tests.common import TransactionCase
class TestCrmRmaClaimMakeClaim(TransactionCase):
def setUp(self):
super(TestCrmRmaClaimMakeClaim, self).setUp()
self.metasearch_wizard = self.env['returned.lines.from.serial.wizard']
res_partner = self.env['res.partner']
sale_order = self.env['sale.order']
self.supplier_id_1 = res_partner.browse(self.ref('base.res_partner_1'))
self.supplier_id_2 = res_partner.browse(self.ref('base.res_partner_3'))
self.supplier_id_3 = res_partner.browse(self.ref('base.res_partner_4'))
self.claim_type = self.ref('crm_claim_type.crm_claim_type_customer')
self.customer_id = res_partner.browse(self.ref('base.res_partner_13'))
self.product_id = self.ref(
'product.product_product_6_product_template')
self.sale_order_id = sale_order.browse(self.ref('sale.sale_order_7'))
self.sale_order_line_ids = self.sale_order_id.order_line
def create_customer_claim(self):
"""
Create a customer claim with or without claim lines based
on include_lines parameter
"""
return self.env['crm.claim'].\
create({
'name': 'Test Claim for %s' % (self.customer_id.name),
'claim_type': self.claim_type,
'partner_id': self.customer_id.id,
'pick': True,
'code': '/',
'claim_line_ids': [(0, 0, {
'supplier_id': self.supplier_id_1.id,
'claim_origin': u'damaged',
'name': self.supplier_id_1.name,
'product_id': self.sale_order_line_ids[1].id
}), (0, 0, {
'supplier_id': self.supplier_id_2.id,
'claim_origin': u'damaged',
'name': self.supplier_id_2.name,
'product_id': self.sale_order_line_ids[2].id
}), (0, 0, {
'supplier_id': self.supplier_id_3.id,
'claim_origin': u'damaged',
'name': self.supplier_id_3.name,
'product_id': self.sale_order_line_ids[3].id
}), ]
})
def test_01_claim_make_claim(self):
claim_id = self.create_customer_claim()
res = claim_id.claim_line_ids.button_create_line_rma_vendor()
lines_added = eval(res[0]['domain'])[0][2]
self.assertEquals(len(claim_id.claim_line_ids), len(lines_added))

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="crm_claim_line_form_view">
<field name="name">CRM - Claim product return line Form</field>
<field name="model">claim.line</field>
<field name="inherit_id" ref="crm_claim_rma.crm_claim_line_form_view"/>
<field name="arch" type="xml">
<xpath expr="//header/button[@name='set_warranty']" position="after">
<button name="button_rma_vendor_render_view"
string="Create Supplier RMA"
type="object"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="crm_claim_form_view_inherited" model="ir.ui.view">
<field name="name">crm.claim.form.view.inherited</field>
<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="//notebook" position="inside">
<page string="Related Claims">
<group colspan="2" col="2">
<field name="claim_ids" nolabel="1" readonly="True"/>
</group>
</page>
</xpath>
</field>
</record>
</data>
</openerp>