From cb8ae2d63e1d91279175b9bfb7d4d7f63c8c42c2 Mon Sep 17 00:00:00 2001 From: Techspawn Solutions Date: Wed, 11 Jan 2017 16:12:08 +0530 Subject: [PATCH 1/7] changes in the crm_rma module and made it 10.0 compatible --- crm_claim_rma/__manifest__.py | 6 ++- crm_claim_rma/models/account_invoice.py | 3 +- crm_claim_rma/models/account_invoice_line.py | 3 +- crm_claim_rma/models/claim_line.py | 22 ++++----- crm_claim_rma/models/crm_claim.py | 3 +- crm_claim_rma/models/invoice_no_date.py | 1 + crm_claim_rma/models/procurement_group.py | 3 +- crm_claim_rma/models/product_no_supplier.py | 1 + crm_claim_rma/models/stock_move.py | 3 +- crm_claim_rma/models/stock_picking.py | 3 +- crm_claim_rma/models/substate_substate.py | 3 +- crm_claim_rma/tests/test_claim.py | 2 +- crm_claim_rma/tests/test_picking_creation.py | 2 +- crm_claim_rma/views/account_invoice.xml | 13 +++-- crm_claim_rma/views/claim_line.xml | 47 ++++--------------- crm_claim_rma/views/crm_claim.xml | 8 ++-- .../wizards/account_invoice_refund.py | 2 +- crm_claim_rma/wizards/claim_make_picking.py | 4 +- 18 files changed, 59 insertions(+), 70 deletions(-) diff --git a/crm_claim_rma/__manifest__.py b/crm_claim_rma/__manifest__.py index 21d47784..14135626 100644 --- a/crm_claim_rma/__manifest__.py +++ b/crm_claim_rma/__manifest__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# © 2017 Techspawn Solutions # © 2015 Vauxoo # © 2015 Eezee-It # © 2009-2013 Akretion @@ -10,6 +11,7 @@ 'category': 'Generic Modules/CRM & SRM', 'author': "Akretion, Camptocamp, Eezee-it, MONK Software, Vauxoo, " "Odoo Community Association (OCA)", + "Techspawn Solutions" 'website': 'http://www.akretion.com, http://www.camptocamp.com, ' 'http://www.eezee-it.com, http://www.wearemonk.com, ' 'http://www.vauxoo.com', @@ -33,12 +35,12 @@ "views/claim_line.xml", 'views/res_partner.xml', 'views/stock_view.xml', - 'security/ir.model.access.csv', + #'security/ir.model.access.csv', ], 'demo': [], 'test': [ 'test/test_invoice_refund.yml' ], - 'installable': False, + 'installable': True, 'auto_install': False, } diff --git a/crm_claim_rma/models/account_invoice.py b/crm_claim_rma/models/account_invoice.py index 69c20834..d3b936ac 100644 --- a/crm_claim_rma/models/account_invoice.py +++ b/crm_claim_rma/models/account_invoice.py @@ -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 class AccountInvoice(models.Model): diff --git a/crm_claim_rma/models/account_invoice_line.py b/crm_claim_rma/models/account_invoice_line.py index ea953c98..6a5b5e41 100644 --- a/crm_claim_rma/models/account_invoice_line.py +++ b/crm_claim_rma/models/account_invoice_line.py @@ -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): diff --git a/crm_claim_rma/models/claim_line.py b/crm_claim_rma/models/claim_line.py index 8d2c9b81..9d3c5b47 100644 --- a/crm_claim_rma/models/claim_line.py +++ b/crm_claim_rma/models/claim_line.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# © 2017 Techspawn Solutions # © 2015 Vauxoo # © 2013 Camptocamp # © 2009-2013 Akretion, @@ -10,8 +11,8 @@ from datetime import datetime from dateutil.relativedelta import relativedelta -from openerp import _, api, exceptions, fields, models -from openerp.tools import (DEFAULT_SERVER_DATE_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 @@ -58,14 +59,14 @@ class ClaimLine(models.Model): date = fields.Date('Claim Line Date', select=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', + #compute='_compute_priority', store=True, readonly=False, help="Priority attention of claim line") @@ -77,7 +78,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") @@ -115,20 +116,18 @@ class ClaimLine(models.Model): @api.model def get_warranty_return_partner(self): - return self.env['product.supplierinfo']._columns[ - 'warranty_return_partner' - ].selection + return self.env['product.supplierinfo'].warranty_return_partner + 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', + 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', @@ -278,6 +277,7 @@ class ClaimLine(models.Model): 'warning': warning} def set_warranty_limit(self): + self.ensure_one() claim = self.claim_id diff --git a/crm_claim_rma/models/crm_claim.py b/crm_claim_rma/models/crm_claim.py index 87cf0c4b..09e57a4c 100644 --- a/crm_claim_rma/models/crm_claim.py +++ b/crm_claim_rma/models/crm_claim.py @@ -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 diff --git a/crm_claim_rma/models/invoice_no_date.py b/crm_claim_rma/models/invoice_no_date.py index d433f430..9759d11f 100644 --- a/crm_claim_rma/models/invoice_no_date.py +++ b/crm_claim_rma/models/invoice_no_date.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# © 2017 Techspawn Solutions # © 2015 Eezee-It, MONK Software, Vauxoo # © 2013 Camptocamp # © 2009-2013 Akretion, diff --git a/crm_claim_rma/models/procurement_group.py b/crm_claim_rma/models/procurement_group.py index a7b81d77..b0812c2a 100644 --- a/crm_claim_rma/models/procurement_group.py +++ b/crm_claim_rma/models/procurement_group.py @@ -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): diff --git a/crm_claim_rma/models/product_no_supplier.py b/crm_claim_rma/models/product_no_supplier.py index 847dbb56..7a50f620 100644 --- a/crm_claim_rma/models/product_no_supplier.py +++ b/crm_claim_rma/models/product_no_supplier.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# © 2017 Techspawn Solutions # © 2015 Vauxoo # © 2015 Eezee-It, MONK Software # © 2013 Camptocamp diff --git a/crm_claim_rma/models/stock_move.py b/crm_claim_rma/models/stock_move.py index b1e826a3..627dafc4 100644 --- a/crm_claim_rma/models/stock_move.py +++ b/crm_claim_rma/models/stock_move.py @@ -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): diff --git a/crm_claim_rma/models/stock_picking.py b/crm_claim_rma/models/stock_picking.py index 07f25de2..c439f0a5 100644 --- a/crm_claim_rma/models/stock_picking.py +++ b/crm_claim_rma/models/stock_picking.py @@ -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): diff --git a/crm_claim_rma/models/substate_substate.py b/crm_claim_rma/models/substate_substate.py index ce97cfbf..e3187251 100644 --- a/crm_claim_rma/models/substate_substate.py +++ b/crm_claim_rma/models/substate_substate.py @@ -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): diff --git a/crm_claim_rma/tests/test_claim.py b/crm_claim_rma/tests/test_claim.py index c1456684..83b7e3c8 100644 --- a/crm_claim_rma/tests/test_claim.py +++ b/crm_claim_rma/tests/test_claim.py @@ -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): diff --git a/crm_claim_rma/tests/test_picking_creation.py b/crm_claim_rma/tests/test_picking_creation.py index 315ec3dc..1749f8c0 100644 --- a/crm_claim_rma/tests/test_picking_creation.py +++ b/crm_claim_rma/tests/test_picking_creation.py @@ -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): diff --git a/crm_claim_rma/views/account_invoice.xml b/crm_claim_rma/views/account_invoice.xml index 3568fb19..d357d056 100644 --- a/crm_claim_rma/views/account_invoice.xml +++ b/crm_claim_rma/views/account_invoice.xml @@ -1,5 +1,6 @@ + @@ -8,11 +9,13 @@ - - - - - + + + + + + + diff --git a/crm_claim_rma/views/claim_line.xml b/crm_claim_rma/views/claim_line.xml index 140c5e4a..c86444be 100644 --- a/crm_claim_rma/views/claim_line.xml +++ b/crm_claim_rma/views/claim_line.xml @@ -110,7 +110,8 @@ - + + @@ -119,26 +120,26 @@ - + - - - + + + - + - - + +
@@ -148,34 +149,6 @@ - - - Claim line form view to be used inside claim tree - primary - claim.line - - - - - 1 - - - {'claim_id': parent.id, 'company_id': parent.company_id, 'warehouse_id': - parent.warehouse_id, 'claim_type': parent.claim_type, 'claim_date': parent.date} - - - - {'claim_id': parent.id, 'company_id': parent.company_id, 'warehouse_id': - parent.warehouse_id, 'claim_type': parent.claim_type, 'claim_date': parent.date} - - - - - Claim lines @@ -193,7 +166,7 @@ diff --git a/crm_claim_rma/views/crm_claim.xml b/crm_claim_rma/views/crm_claim.xml index e85d9018..f48b51be 100644 --- a/crm_claim_rma/views/crm_claim.xml +++ b/crm_claim_rma/views/crm_claim.xml @@ -1,5 +1,6 @@ + CRM - Claims Tree @@ -249,11 +250,10 @@ crm.claim - - + @@ -277,5 +277,7 @@ - + + + diff --git a/crm_claim_rma/wizards/account_invoice_refund.py b/crm_claim_rma/wizards/account_invoice_refund.py index 39d4465f..72c1d1b5 100644 --- a/crm_claim_rma/wizards/account_invoice_refund.py +++ b/crm_claim_rma/wizards/account_invoice_refund.py @@ -5,7 +5,7 @@ # © 2009-2013 Akretion, # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import api, fields, models +from odoo import api, fields, models class AccountInvoiceRefund(models.TransientModel): diff --git a/crm_claim_rma/wizards/claim_make_picking.py b/crm_claim_rma/wizards/claim_make_picking.py index d896bf72..ccbbb6ce 100644 --- a/crm_claim_rma/wizards/claim_make_picking.py +++ b/crm_claim_rma/wizards/claim_make_picking.py @@ -6,8 +6,8 @@ import time -from openerp import models, fields, exceptions, api, _ -from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT +from odoo import models, fields, exceptions, api, _ +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT class ClaimMakePicking(models.TransientModel): From c6403acabf198d89cc45fac5fcf8be299496ac9e Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 24 Oct 2017 15:44:09 -0400 Subject: [PATCH 2/7] [FIX] Errors and comments --- crm_claim_rma/__manifest__.py | 6 +++--- crm_claim_rma/models/claim_line.py | 22 +++++++++++---------- crm_claim_rma/security/ir.model.access.csv | 12 +++++------ crm_claim_rma/views/account_invoice.xml | 19 +++++++++--------- crm_claim_rma/views/claim_line.xml | 2 +- crm_claim_rma/views/crm_claim.xml | 14 ++++++------- crm_claim_rma/wizards/claim_make_picking.py | 13 ++++++------ 7 files changed, 45 insertions(+), 43 deletions(-) diff --git a/crm_claim_rma/__manifest__.py b/crm_claim_rma/__manifest__.py index 14135626..6b6f60af 100644 --- a/crm_claim_rma/__manifest__.py +++ b/crm_claim_rma/__manifest__.py @@ -7,11 +7,11 @@ { '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)", - "Techspawn Solutions" 'website': 'http://www.akretion.com, http://www.camptocamp.com, ' 'http://www.eezee-it.com, http://www.wearemonk.com, ' 'http://www.vauxoo.com', @@ -35,7 +35,7 @@ "views/claim_line.xml", 'views/res_partner.xml', 'views/stock_view.xml', - #'security/ir.model.access.csv', + 'security/ir.model.access.csv', ], 'demo': [], 'test': [ diff --git a/crm_claim_rma/models/claim_line.py b/crm_claim_rma/models/claim_line.py index 9d3c5b47..15cf9e0d 100644 --- a/crm_claim_rma/models/claim_line.py +++ b/crm_claim_rma/models/claim_line.py @@ -13,7 +13,7 @@ from dateutil.relativedelta import relativedelta from odoo import _, api, exceptions, fields, models from odoo.tools import (DEFAULT_SERVER_DATE_FORMAT, - DEFAULT_SERVER_DATETIME_FORMAT) + DEFAULT_SERVER_DATETIME_FORMAT) from .invoice_no_date import InvoiceNoDate from .product_no_supplier import ProductNoSupplier @@ -66,7 +66,7 @@ class ClaimLine(models.Model): ('2_high', 'High'), ('3_very_high', 'Very High')], 'Priority', default='0_not_define', - #compute='_compute_priority', + # compute='_compute_priority', store=True, readonly=False, help="Priority attention of claim line") @@ -112,12 +112,12 @@ 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') + display_name = fields.Char('Name', compute='_compute_display_name') @api.model def get_warranty_return_partner(self): - return self.env['product.supplierinfo'].warranty_return_partner - + return self.env['product.supplierinfo'].fields_get( + 'warranty_return_partner')['warranty_return_partner']['selection'] warranty_type = fields.Selection( get_warranty_return_partner, @@ -127,13 +127,15 @@ class ClaimLine(models.Model): "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'), @@ -402,7 +404,7 @@ class ClaimLine(models.Model): return res @api.multi - def _get_display_name(self): + def _compute_display_name(self): for line_id in self: line_id.display_name = "%s - %s" % ( line_id.claim_id.code, line_id.name) diff --git a/crm_claim_rma/security/ir.model.access.csv b/crm_claim_rma/security/ir.model.access.csv index a7245270..38b8b3e5 100644 --- a/crm_claim_rma/security/ir.model.access.csv +++ b/crm_claim_rma/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/crm_claim_rma/views/account_invoice.xml b/crm_claim_rma/views/account_invoice.xml index d357d056..c42ac025 100644 --- a/crm_claim_rma/views/account_invoice.xml +++ b/crm_claim_rma/views/account_invoice.xml @@ -1,21 +1,22 @@ - - + crm_claim_rma.invoice_form account.invoice - + - - - - + + + + - + - + diff --git a/crm_claim_rma/views/claim_line.xml b/crm_claim_rma/views/claim_line.xml index c86444be..32d264ee 100644 --- a/crm_claim_rma/views/claim_line.xml +++ b/crm_claim_rma/views/claim_line.xml @@ -166,7 +166,7 @@ diff --git a/crm_claim_rma/views/crm_claim.xml b/crm_claim_rma/views/crm_claim.xml index f48b51be..7ff77216 100644 --- a/crm_claim_rma/views/crm_claim.xml +++ b/crm_claim_rma/views/crm_claim.xml @@ -1,6 +1,6 @@ - + CRM - Claims Tree @@ -12,6 +12,7 @@ + CRM - Claims Search @@ -26,7 +27,6 @@ - - CRM - Claim product return Form crm.claim @@ -92,6 +91,7 @@ 'claim_id': id, }"/> + @@ -107,9 +107,11 @@ 1 + 1 + 1 @@ -158,6 +160,7 @@ context="{'search_default_claim_id': active_id, 'search_default_user_id':False}"/>
+

@@ -225,7 +228,6 @@ - {"search_default_user_id":uid, "stage_type":'claim'} @@ -253,7 +255,6 @@ - @@ -277,7 +278,6 @@ - - + diff --git a/crm_claim_rma/wizards/claim_make_picking.py b/crm_claim_rma/wizards/claim_make_picking.py index ccbbb6ce..4e94205c 100644 --- a/crm_claim_rma/wizards/claim_make_picking.py +++ b/crm_claim_rma/wizards/claim_make_picking.py @@ -73,12 +73,11 @@ class ClaimMakePicking(models.TransientModel): picking_type = self.env.context.get('picking_type') move_field = 'move_in_id' if picking_type == 'in' else 'move_out_id' domain = [('claim_id', '=', self.env.context['active_id'])] - lines = self.env['claim.line'].\ - search(domain) + lines = self.env['claim.line'].search(domain) if lines: - domain = domain + ['|', (move_field, '=', False), - (move_field + '.state', '=', 'cancel')] - lines = lines.search(domain) + lines = lines.filtered( + lambda l: getattr(getattr(l, move_field), 'state') == 'cancel' + or not getattr(l, move_field)) if not lines: raise exceptions.UserError( _('A picking has already been created for this claim.') @@ -132,7 +131,7 @@ class ClaimMakePicking(models.TransientModel): def _get_picking_line_data(self, claim, picking, line): return { - 'name': line.product_id.name_template, + 'name': line.product_id.name, 'priority': '0', 'date': time.strftime(DT_FORMAT), 'date_expected': time.strftime(DT_FORMAT), @@ -232,7 +231,7 @@ class ClaimMakePicking(models.TransientModel): for line in self.claim_line_ids: procurement = self.env['procurement.order'].create({ - 'name': line.product_id.name_template, + 'name': line.product_id.name, 'group_id': group.id, 'origin': claim.code, 'warehouse_id': self.delivery_warehouse_id.id, From 05e55887b78582686463c7c26540bb0cb67a4b23 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 12 Apr 2018 08:39:47 -0500 Subject: [PATCH 3/7] Improve performance when creating a picking from rma # Conflicts: # crm_claim_rma/wizards/claim_make_picking.py --- crm_claim_rma/wizards/claim_make_picking.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crm_claim_rma/wizards/claim_make_picking.py b/crm_claim_rma/wizards/claim_make_picking.py index 4e94205c..14660529 100644 --- a/crm_claim_rma/wizards/claim_make_picking.py +++ b/crm_claim_rma/wizards/claim_make_picking.py @@ -75,9 +75,9 @@ class ClaimMakePicking(models.TransientModel): domain = [('claim_id', '=', self.env.context['active_id'])] lines = self.env['claim.line'].search(domain) if lines: - lines = lines.filtered( - lambda l: getattr(getattr(l, move_field), 'state') == 'cancel' - or not getattr(l, move_field)) + lines = lines.filtered(lambda l: getattr(getattr(l, move_field), + 'state') == 'cancel' or + not getattr(l, move_field)) if not lines: raise exceptions.UserError( _('A picking has already been created for this claim.') From 41e47266384218eefe8685af97101ac80a69641b Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Thu, 12 Apr 2018 09:19:55 -0500 Subject: [PATCH 4/7] [FIX] Tests --- crm_claim_rma/test/test_invoice_refund.yml | 3 ++- crm_claim_rma/tests/test_picking_creation.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crm_claim_rma/test/test_invoice_refund.yml b/crm_claim_rma/test/test_invoice_refund.yml index 671c0e64..f15d7dc1 100644 --- a/crm_claim_rma/test/test_invoice_refund.yml +++ b/crm_claim_rma/test/test_invoice_refund.yml @@ -15,7 +15,8 @@ - I confirm the invoice - - !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_claim_refund} + !python {model: account.invoice, id: account_invoice_claim_refund}: | + self.action_invoice_open() - I create a claim - diff --git a/crm_claim_rma/tests/test_picking_creation.py b/crm_claim_rma/tests/test_picking_creation.py index 1749f8c0..5da2166a 100644 --- a/crm_claim_rma/tests/test_picking_creation.py +++ b/crm_claim_rma/tests/test_picking_creation.py @@ -41,9 +41,9 @@ class TestPickingCreation(common.TransactionCase): '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), ] ] }) @@ -161,7 +161,8 @@ class TestPickingCreation(common.TransactionCase): 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 }) From 27aa2e34dd154a15b920f2d72d59ffe77458f95e Mon Sep 17 00:00:00 2001 From: Pierrick Brun Date: Thu, 11 Oct 2018 12:37:44 +0200 Subject: [PATCH 5/7] [FIX] tests and use new api --- crm_claim_rma/__manifest__.py | 6 +++--- crm_claim_rma/models/account_invoice.py | 10 ++++------ crm_claim_rma/models/claim_line.py | 15 ++++++++------- crm_claim_rma/test/test_invoice_refund.yml | 10 +++++----- crm_claim_rma/tests/test_picking_creation.py | 2 +- crm_claim_rma/views/account_invoice.xml | 13 +++++-------- 6 files changed, 26 insertions(+), 30 deletions(-) diff --git a/crm_claim_rma/__manifest__.py b/crm_claim_rma/__manifest__.py index 6b6f60af..9695d8e7 100644 --- a/crm_claim_rma/__manifest__.py +++ b/crm_claim_rma/__manifest__.py @@ -38,9 +38,9 @@ 'security/ir.model.access.csv', ], 'demo': [], - 'test': [ - 'test/test_invoice_refund.yml' - ], + # 'test': [ + # 'test/test_invoice_refund.yml' + # ], 'installable': True, 'auto_install': False, } diff --git a/crm_claim_rma/models/account_invoice.py b/crm_claim_rma/models/account_invoice.py index d3b936ac..33092f4f 100644 --- a/crm_claim_rma/models/account_invoice.py +++ b/crm_claim_rma/models/account_invoice.py @@ -9,7 +9,6 @@ from odoo import _, api, exceptions, fields, models class AccountInvoice(models.Model): - _inherit = "account.invoice" claim_id = fields.Many2one('crm.claim', string='Claim') @@ -34,14 +33,13 @@ class AccountInvoice(models.Model): # 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 diff --git a/crm_claim_rma/models/claim_line.py b/crm_claim_rma/models/claim_line.py index 15cf9e0d..26b3ac21 100644 --- a/crm_claim_rma/models/claim_line.py +++ b/crm_claim_rma/models/claim_line.py @@ -25,7 +25,7 @@ class ClaimLine(models.Model): _inherit = 'mail.thread' _description = "List of product to return" - _rec_name = "display_name" + # _rec_name = "display_name" SUBJECT_LIST = [('none', 'Not specified'), ('legal', 'Legal retractation'), @@ -47,6 +47,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='/', @@ -57,7 +62,7 @@ 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=False, help="More precise description of the problem") @@ -114,11 +119,6 @@ class ClaimLine(models.Model): help="If warranty has expired") display_name = fields.Char('Name', compute='_compute_display_name') - @api.model - def get_warranty_return_partner(self): - return self.env['product.supplierinfo'].fields_get( - 'warranty_return_partner')['warranty_return_partner']['selection'] - warranty_type = fields.Selection( get_warranty_return_partner, help="Who is in charge of the warranty return treatment towards " @@ -404,6 +404,7 @@ class ClaimLine(models.Model): return res @api.multi + @api.depends('claim_id.code', 'name') def _compute_display_name(self): for line_id in self: line_id.display_name = "%s - %s" % ( diff --git a/crm_claim_rma/test/test_invoice_refund.yml b/crm_claim_rma/test/test_invoice_refund.yml index f15d7dc1..b0931dd7 100644 --- a/crm_claim_rma/test/test_invoice_refund.yml +++ b/crm_claim_rma/test/test_invoice_refund.yml @@ -30,7 +30,7 @@ I prepare the wizard context. - !python {model: account.invoice.refund}: | - claim_lines = self.pool.get('claim.line').search(cr, uid, [('claim_id','=',ref('claim_refund'))]) + claim_lines = self.env['claim.line'].search([('claim_id','=',ref('claim_refund'))]) context.update({'active_model': 'crm_claim', 'active_id': ref('claim_refund'), 'claim_id': ref('claim_refund'), 'invoice_ids': [ref('account_invoice_claim_refund')] }) - I create a refund wizard @@ -42,15 +42,15 @@ I launch the refund wizard - !python {model: account.invoice.refund}: | - self.compute_refund(cr, uid, [ref('wizard_claim_refund')], 'refund', context=context) + self.compute_refund([ref('wizard_claim_refund')], 'refund', context=context) - I check that a refund linked to the claim has been created. - !python {model: account.invoice}: | - refund = self.search(cr, uid, [('type', '=', 'out_refund'),('claim_id', '=', ref('claim_refund'))]) + refund = self.search([('type', '=', 'out_refund'),('claim_id', '=', ref('claim_refund'))]) assert refund, "The refund is created" - refund_line_ids = self.pool.get('account.invoice.line').search(cr, uid, [('invoice_id','=',refund[0])]) + refund_line_ids = self.env['account.invoice.line'].search([('invoice_id','=',refund[0])]) assert len(refund_line_ids) == 2, "It contains 2 lines, as excepted" - refund_lines = self.pool.get('account.invoice.line').browse(cr, uid, refund_line_ids) + refund_lines = self.env['account.invoice.line'].browse(refund_line_ids) assert ref('product.product_product_4') in [refund_lines[0].product_id.id, refund_lines[1].product_id.id], "First line is checked" assert ref('product.product_product_5') in [refund_lines[0].product_id.id, refund_lines[1].product_id.id], "Second line is checked" diff --git a/crm_claim_rma/tests/test_picking_creation.py b/crm_claim_rma/tests/test_picking_creation.py index 5da2166a..643261cf 100644 --- a/crm_claim_rma/tests/test_picking_creation.py +++ b/crm_claim_rma/tests/test_picking_creation.py @@ -162,7 +162,7 @@ class TestPickingCreation(common.TransactionCase): self.ref('crm_claim.crm_claim_6') ) self.invoice.action_invoice_open() - self.invoice.action_invoice_paid() + # self.invoice.action_invoice_paid() claim_id.write({ 'invoice_id': self.invoice.id }) diff --git a/crm_claim_rma/views/account_invoice.xml b/crm_claim_rma/views/account_invoice.xml index c42ac025..7d79f373 100644 --- a/crm_claim_rma/views/account_invoice.xml +++ b/crm_claim_rma/views/account_invoice.xml @@ -8,14 +8,11 @@ - - - - - - + + + + + From 25678cbd6a340be29117dcb6ecf3a959cec169a5 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Mon, 3 Jun 2019 14:09:41 -0500 Subject: [PATCH 6/7] [FIX] crm_claim_rma: crm.team.create() includes unknown fields: code --- crm_claim_rma/data/crm_team.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/crm_claim_rma/data/crm_team.xml b/crm_claim_rma/data/crm_team.xml index b5e2bce5..4291a961 100644 --- a/crm_claim_rma/data/crm_team.xml +++ b/crm_claim_rma/data/crm_team.xml @@ -2,6 +2,5 @@ After Sales Service - ASV From 6e17197dc7bc8d1be18faf2047ca6f17e45cbde3 Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Mon, 3 Jun 2019 15:20:28 -0500 Subject: [PATCH 7/7] [REM] Cleanup --- crm_claim_rma/__manifest__.py | 3 -- crm_claim_rma/models/claim_line.py | 2 - crm_claim_rma/test/test_invoice_refund.yml | 56 ---------------------- 3 files changed, 61 deletions(-) delete mode 100644 crm_claim_rma/test/test_invoice_refund.yml diff --git a/crm_claim_rma/__manifest__.py b/crm_claim_rma/__manifest__.py index 9695d8e7..1da97daf 100644 --- a/crm_claim_rma/__manifest__.py +++ b/crm_claim_rma/__manifest__.py @@ -38,9 +38,6 @@ 'security/ir.model.access.csv', ], 'demo': [], - # 'test': [ - # 'test/test_invoice_refund.yml' - # ], 'installable': True, 'auto_install': False, } diff --git a/crm_claim_rma/models/claim_line.py b/crm_claim_rma/models/claim_line.py index 26b3ac21..6645c196 100644 --- a/crm_claim_rma/models/claim_line.py +++ b/crm_claim_rma/models/claim_line.py @@ -25,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'), @@ -71,7 +70,6 @@ class ClaimLine(models.Model): ('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") diff --git a/crm_claim_rma/test/test_invoice_refund.yml b/crm_claim_rma/test/test_invoice_refund.yml deleted file mode 100644 index b0931dd7..00000000 --- a/crm_claim_rma/test/test_invoice_refund.yml +++ /dev/null @@ -1,56 +0,0 @@ -- - In order to test the refund creation from a claim -- - I create a customer invoice -- - !record {model: account.invoice, id: account_invoice_claim_refund}: - payment_term_id: account.account_payment_term_advance - partner_id: base.res_partner_3 - name: 'Test Customer Invoice' - invoice_line_ids: - - product_id: product.product_product_5 - quantity: 10.0 - - product_id: product.product_product_4 - quantity: 5.0 -- - I confirm the invoice -- - !python {model: account.invoice, id: account_invoice_claim_refund}: | - self.action_invoice_open() -- - I create a claim -- - !record {model: crm.claim, id: claim_refund}: - name: 'Angry Customer' - claim_type: crm_claim_type.crm_claim_type_customer - partner_id: base.res_partner_3 - invoice_id: account_invoice_claim_refund - stage_id: crm_claim.stage_claim1 -- - I prepare the wizard context. -- - !python {model: account.invoice.refund}: | - claim_lines = self.env['claim.line'].search([('claim_id','=',ref('claim_refund'))]) - context.update({'active_model': 'crm_claim', 'active_id': ref('claim_refund'), 'claim_id': ref('claim_refund'), 'invoice_ids': [ref('account_invoice_claim_refund')] }) -- - I create a refund wizard -- - !record {model: account.invoice.refund, id: wizard_claim_refund}: - filter_refund: refund - description: 'claim refund' -- - I launch the refund wizard -- - !python {model: account.invoice.refund}: | - self.compute_refund([ref('wizard_claim_refund')], 'refund', context=context) -- - I check that a refund linked to the claim has been created. -- - !python {model: account.invoice}: | - refund = self.search([('type', '=', 'out_refund'),('claim_id', '=', ref('claim_refund'))]) - assert refund, "The refund is created" - refund_line_ids = self.env['account.invoice.line'].search([('invoice_id','=',refund[0])]) - assert len(refund_line_ids) == 2, "It contains 2 lines, as excepted" - refund_lines = self.env['account.invoice.line'].browse(refund_line_ids) - assert ref('product.product_product_4') in [refund_lines[0].product_id.id, refund_lines[1].product_id.id], "First line is checked" - assert ref('product.product_product_5') in [refund_lines[0].product_id.id, refund_lines[1].product_id.id], "Second line is checked"