Skip to content

Commit

Permalink
Merge pull request #128 from ursais/10.0_crm_claim
Browse files Browse the repository at this point in the history
[MIG] crm_claim_rma
  • Loading branch information
max3903 authored Jun 25, 2019
2 parents e0b02f6 + 6e17197 commit cee44c3
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 164 deletions.
9 changes: 4 additions & 5 deletions crm_claim_rma/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Vauxoo
# © 2015 Eezee-It
# © 2009-2013 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'RMA Claim (Product Return Management)',
'version': '9.0.1.0.0',
'version': '10.0.1.0.0',
'category': 'Generic Modules/CRM & SRM',
'author': "Akretion, Camptocamp, Eezee-it, MONK Software, Vauxoo, "
"Techspawn Solutions, "
"Odoo Community Association (OCA)",
'website': 'http://www.akretion.com, http://www.camptocamp.com, '
'http://www.eezee-it.com, http://www.wearemonk.com, '
Expand Down Expand Up @@ -36,9 +38,6 @@
'security/ir.model.access.csv',
],
'demo': [],
'test': [
'test/test_invoice_refund.yml'
],
'installable': False,
'installable': True,
'auto_install': False,
}
1 change: 0 additions & 1 deletion crm_claim_rma/data/crm_team.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<odoo noupdate="1">
<record id="team_after_sales_service" model="crm.team">
<field name="name">After Sales Service</field>
<field name="code">ASV</field>
</record>
</odoo>
13 changes: 6 additions & 7 deletions crm_claim_rma/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Eezee-It, MONK Software, Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, exceptions, fields, models
from odoo import _, api, exceptions, fields, models


class AccountInvoice(models.Model):

_inherit = "account.invoice"

claim_id = fields.Many2one('crm.claim', string='Claim')
Expand All @@ -33,14 +33,13 @@ def _refund_cleanup_lines(self, lines):
# For each lines replace quantity and add claim_line_id
inv_line = claim_line.invoice_line_id
clean_line = {}
for field_name, field in inv_line._all_columns.iteritems():
column_type = field.column._type
if column_type == 'many2one':
for field_name, field in inv_line._fields.iteritems():
if isinstance(field, fields.Many2one):
clean_line[field_name] = inv_line[field_name].id
elif column_type not in ('many2many', 'one2many'):
elif not isinstance(field, (fields.Many2many,
fields.One2many)):
clean_line[field_name] = inv_line[field_name]
elif field_name == 'invoice_line_tax_id':

tax_ids = inv_line[field_name].ids
clean_line[field_name] = [(6, 0, tax_ids)]
clean_line['quantity'] = claim_line.product_returned_quantity
Expand Down
3 changes: 2 additions & 1 deletion crm_claim_rma/models/account_invoice_line.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, models
from odoo import api, models


class AccountInvoiceLine(models.Model):
Expand Down
45 changes: 23 additions & 22 deletions crm_claim_rma/models/claim_line.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
Expand All @@ -10,9 +11,9 @@

from dateutil.relativedelta import relativedelta

from openerp import _, api, exceptions, fields, models
from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT)
from odoo import _, api, exceptions, fields, models
from odoo.tools import (DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT)

from .invoice_no_date import InvoiceNoDate
from .product_no_supplier import ProductNoSupplier
Expand All @@ -24,7 +25,6 @@ class ClaimLine(models.Model):

_inherit = 'mail.thread'
_description = "List of product to return"
_rec_name = "display_name"

SUBJECT_LIST = [('none', 'Not specified'),
('legal', 'Legal retractation'),
Expand All @@ -46,6 +46,11 @@ class ClaimLine(models.Model):
('expired', _("Expired")),
('not_define', _("Not Defined"))]

@api.model
def get_warranty_return_partner(self):
return self.env['product.supplierinfo'].fields_get(
'warranty_return_partner')['warranty_return_partner']['selection']

number = fields.Char(
readonly=True,
default='/',
Expand All @@ -56,16 +61,15 @@ class ClaimLine(models.Model):
default=lambda self: self.env['res.company']._company_default_get(
'claim.line'))
date = fields.Date('Claim Line Date',
select=True,
index=True,
default=fields.date.today())
name = fields.Char('Description', default='none', required=True,
name = fields.Char('Description', default='none', required=False,
help="More precise description of the problem")
priority = fields.Selection([('0_not_define', 'Not Define'),
('1_normal', 'Normal'),
('2_high', 'High'),
('3_very_high', 'Very High')],
'Priority', default='0_not_define',
compute='_compute_priority',
store=True,
readonly=False,
help="Priority attention of claim line")
Expand All @@ -77,7 +81,7 @@ class ClaimLine(models.Model):
],
help="To describe the line product diagnosis")
claim_origin = fields.Selection(SUBJECT_LIST, 'Claim Subject',
required=True, help="To describe the "
required=False, help="To describe the "
"line product problem")
product_id = fields.Many2one('product.product', string='Product',
help="Returned product")
Expand Down Expand Up @@ -111,30 +115,25 @@ class ClaimLine(models.Model):
warning = fields.Selection(WARRANT_COMMENT,
'Warranty', readonly=True,
help="If warranty has expired")
display_name = fields.Char('Name', compute='_get_display_name')

@api.model
def get_warranty_return_partner(self):
return self.env['product.supplierinfo']._columns[
'warranty_return_partner'
].selection
display_name = fields.Char('Name', compute='_compute_display_name')

warranty_type = fields.Selection(
get_warranty_return_partner, readonly=True,
get_warranty_return_partner,
help="Who is in charge of the warranty return treatment towards "
"the end customer. Company will use the current company "
"delivery or default address and so on for supplier and brand "
"manufacturer. Does not necessarily mean that the warranty "
"to be applied is the one of the return partner (ie: can be "
"returned to the company and be under the brand warranty")
warranty_return_partner = \
fields.Many2one('res.partner', string='Warranty Address',
help="Where the customer has to "
"send back the product(s)")
warranty_return_partner = fields.Many2one('res.partner',
string='Warranty Address',
help="Where the customer has to "
"send back the product(s)")
claim_id = fields.Many2one('crm.claim', string='Related claim',
ondelete='cascade',
help="To link to the case.claim object")
state = fields.Selection([('draft', 'Draft'), ('refused', 'Refused'),
state = fields.Selection([('draft', 'Draft'),
('refused', 'Refused'),
('confirmed', 'Confirmed, waiting for product'),
('in_to_control', 'Received, to control'),
('in_to_treate', 'Controlled, to treate'),
Expand Down Expand Up @@ -278,6 +277,7 @@ def _warranty_limit_values(self, invoice, claim_type, product, claim_date):
'warning': warning}

def set_warranty_limit(self):

self.ensure_one()

claim = self.claim_id
Expand Down Expand Up @@ -402,7 +402,8 @@ def create(self, vals):
return res

@api.multi
def _get_display_name(self):
@api.depends('claim_id.code', 'name')
def _compute_display_name(self):
for line_id in self:
line_id.display_name = "%s - %s" % (
line_id.claim_id.code, line_id.name)
3 changes: 2 additions & 1 deletion crm_claim_rma/models/crm_claim.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Eezee-It, MONK Software, Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, exceptions, fields, models
from odoo import _, api, exceptions, fields, models

from .invoice_no_date import InvoiceNoDate
from .product_no_supplier import ProductNoSupplier
Expand Down
1 change: 1 addition & 0 deletions crm_claim_rma/models/invoice_no_date.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Eezee-It, MONK Software, Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
Expand Down
3 changes: 2 additions & 1 deletion crm_claim_rma/models/procurement_group.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2016 Cyril Gaudin (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import fields, models
from odoo import fields, models


class ProcurementGroup(models.Model):
Expand Down
1 change: 1 addition & 0 deletions crm_claim_rma/models/product_no_supplier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Vauxoo
# © 2015 Eezee-It, MONK Software
# © 2013 Camptocamp
Expand Down
3 changes: 2 additions & 1 deletion crm_claim_rma/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Eezee-It, MONK Software, Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, models
from odoo import api, models


class StockMove(models.Model):
Expand Down
3 changes: 2 additions & 1 deletion crm_claim_rma/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Eezee-It, MONK Software, Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import fields, models
from odoo import fields, models


class StockPicking(models.Model):
Expand Down
3 changes: 2 additions & 1 deletion crm_claim_rma/models/substate_substate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# © 2017 Techspawn Solutions
# © 2015 Eezee-It, MONK Software, Vauxoo
# © 2013 Camptocamp
# © 2009-2013 Akretion,
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import fields, models
from odoo import fields, models


class SubstateSubstate(models.Model):
Expand Down
12 changes: 6 additions & 6 deletions crm_claim_rma/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_substate_user_all_leads,substate.substate.user,model_substate_substate,base.group_sale_salesman_all_leads,1,1,1,0
access_claim_line_user_all_leads,claim.line.user,model_claim_line,base.group_sale_salesman_all_leads,1,1,1,0
access_substate_manager,substate.substate.manager,model_substate_substate,base.group_sale_manager,1,1,1,1
access_claim_line_manager,claim.line.manager,model_claim_line,base.group_sale_manager,1,1,1,1
access_substate_user,substate.substate.user,model_substate_substate,base.group_sale_salesman,1,1,1,0
access_claim_line_user,claim.line.user,model_claim_line,base.group_sale_salesman,1,1,1,0
access_substate_user_all_leads,substate.substate.user,model_substate_substate,sales_team.group_sale_salesman,1,1,1,0
access_claim_line_user_all_leads,claim.line.user,model_claim_line,sales_team.group_sale_salesman,1,1,1,0
access_substate_manager,substate.substate.manager,model_substate_substate,sales_team.group_sale_manager,1,1,1,1
access_claim_line_manager,claim.line.manager,model_claim_line,sales_team.group_sale_manager,1,1,1,1
access_substate_user,substate.substate.user,model_substate_substate,sales_team.group_sale_salesman,1,1,1,0
access_claim_line_user,claim.line.user,model_claim_line,sales_team.group_sale_salesman,1,1,1,0
55 changes: 0 additions & 55 deletions crm_claim_rma/test/test_invoice_refund.yml

This file was deleted.

2 changes: 1 addition & 1 deletion crm_claim_rma/tests/test_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# © 2016 Cyril Gaudin (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests import TransactionCase
from odoo.tests import TransactionCase


class TestClaim(TransactionCase):
Expand Down
9 changes: 5 additions & 4 deletions crm_claim_rma/tests/test_picking_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# © 2014 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests import common
from odoo.tests import common


class TestPickingCreation(common.TransactionCase):
Expand Down Expand Up @@ -41,9 +41,9 @@ def setUp(self):
'price_unit': product.list_price

}) for product, qty in [
(self.env.ref('product.product_product_24'), 5),
(self.env.ref('product.product_product_25'), 3),
(self.env.ref('product.product_product_30'), 5),
(self.env.ref('product.product_product_33'), 2),
(self.env.ref('product.product_product_27'), 2),
]
]
})
Expand Down Expand Up @@ -161,7 +161,8 @@ def test_03_invoice_refund(self):
claim_id = self.env['crm.claim'].browse(
self.ref('crm_claim.crm_claim_6')
)
self.invoice.confirm_paid()
self.invoice.action_invoice_open()
# self.invoice.action_invoice_paid()
claim_id.write({
'invoice_id': self.invoice.id
})
Expand Down
Loading

0 comments on commit cee44c3

Please sign in to comment.