From c6403acabf198d89cc45fac5fcf8be299496ac9e Mon Sep 17 00:00:00 2001 From: Maxime Chambreuil Date: Tue, 24 Oct 2017 15:44:09 -0400 Subject: [PATCH] [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,