From f20d100511f7848e798a9cc972e537ed7fc85af7 Mon Sep 17 00:00:00 2001 From: aheficent Date: Wed, 16 Aug 2017 12:52:35 +0200 Subject: [PATCH] [IMP] default operation in product and product_categ for customer and supplier [IMP]Separate menus for customer and supplier operations * Add active field to rma operation * Added tests * Fix travis * Fix create supplier rma from customer rma --- rma_sale/models/rma_operation.py | 2 +- rma_sale/models/rma_order.py | 6 +++--- rma_sale/models/rma_order_line.py | 11 +---------- rma_sale/wizards/rma_add_sale.py | 10 +++++----- rma_sale/wizards/rma_refund.py | 2 +- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/rma_sale/models/rma_operation.py b/rma_sale/models/rma_operation.py index 08ad757c..500aadf5 100644 --- a/rma_sale/models/rma_operation.py +++ b/rma_sale/models/rma_operation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from openerp import _, api, fields, models +from openerp import fields, models class RmaOperation(models.Model): diff --git a/rma_sale/models/rma_order.py b/rma_sale/models/rma_order.py index bb167e96..ac99545e 100644 --- a/rma_sale/models/rma_order.py +++ b/rma_sale/models/rma_order.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from openerp import _, api, fields, models -from openerp.addons import decimal_precision as dp +from openerp import api, fields, models class RmaOrder(models.Model): _inherit = "rma.order" - @api.one + @api.multi def _compute_sales_count(self): + self.ensure_one() sales_list = [] for rma_line in self.rma_line_ids: if rma_line.sale_line_id and rma_line.sale_line_id.id: diff --git a/rma_sale/models/rma_order_line.py b/rma_sale/models/rma_order_line.py index b4088098..40444d71 100644 --- a/rma_sale/models/rma_order_line.py +++ b/rma_sale/models/rma_order_line.py @@ -1,22 +1,13 @@ # -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from openerp import _, api, fields, models +from openerp import api, fields, models from openerp.addons import decimal_precision as dp class RmaOrderLine(models.Model): _inherit = "rma.order.line" - @api.model - def _default_sale_type(self): - return self.sale_type or False - - sale_type = fields.Selection([ - ('no', 'Not required'), ('ordered', 'Based on Ordered Quantities'), - ('received', 'Based on Received Quantities')], - string="Sale Policy", default=_default_sale_type) - @api.one @api.depends('sale_line_ids', 'sale_type', 'sales_count', 'sale_line_ids.state') diff --git a/rma_sale/wizards/rma_add_sale.py b/rma_sale/wizards/rma_add_sale.py index 5b382646..959b79eb 100644 --- a/rma_sale/wizards/rma_add_sale.py +++ b/rma_sale/wizards/rma_add_sale.py @@ -2,7 +2,7 @@ # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from openerp import _, api, fields, models +from openerp import api, fields, models from openerp.exceptions import ValidationError @@ -43,10 +43,10 @@ class RmaAddSale(models.TransientModel): def _prepare_rma_line_from_sale_order_line(self, line): operation = line.product_id.rma_operation_id and \ - line.product_id.rma_operation_id.id or False + line.product_id.rma_operation_id.id or False if not operation: operation = line.product_id.categ_id.rma_operation_id and \ - line.product_id.categ_id.rma_operation_id.id or False + line.product_id.categ_id.rma_operation_id.id or False data = { 'sale_line_id': line.id, 'product_id': line.product_id.id, @@ -74,8 +74,8 @@ class RmaAddSale(models.TransientModel): {'in_route_id': operation.in_route_id.id or route, 'out_route_id': operation.out_route_id.id or route, 'receipt_policy': operation.receipt_policy, - 'location_id': operation.location_id.id or - self.env.ref('stock.stock_location_stock').id, + 'location_id': operation.location_id.id or self.env.ref( + 'stock.stock_location_stock').id, 'operation_id': operation.id, 'refund_policy': operation.refund_policy, 'delivery_policy': operation.delivery_policy diff --git a/rma_sale/wizards/rma_refund.py b/rma_sale/wizards/rma_refund.py index 7b0eb2b0..537dc226 100644 --- a/rma_sale/wizards/rma_refund.py +++ b/rma_sale/wizards/rma_refund.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from openerp import _, api, fields, models +from openerp import api, fields, models class RmaRefund(models.TransientModel):