From 6768f4c7745be59a501adb2c76aef1d037e05eac Mon Sep 17 00:00:00 2001 From: Aaron Henriquez Date: Tue, 30 Apr 2019 18:32:29 +0200 Subject: [PATCH] [FIX]do not duplicate related records. [FIX]button to related rmas [FIX]printout [IMP]add term and conditions field at rma level --- rma/models/procurement.py | 6 +++--- rma/models/rma_order_line.py | 16 +++++++++++----- rma/models/stock.py | 2 +- rma/report/rma_report_templates.xml | 4 ++++ rma/views/rma_order_line_view.xml | 2 ++ rma_account/models/invoice.py | 3 ++- rma_purchase/models/purchase_order_line.py | 2 +- rma_sale/models/sale_order_line.py | 3 ++- 8 files changed, 26 insertions(+), 12 deletions(-) diff --git a/rma/models/procurement.py b/rma/models/procurement.py index 18b73f17..4681d586 100644 --- a/rma/models/procurement.py +++ b/rma/models/procurement.py @@ -10,7 +10,7 @@ class ProcurementOrder(models.Model): rma_line_id = fields.Many2one( comodel_name='rma.order.line', string='RMA line', - ondelete="set null", + ondelete="set null", copy=False ) @api.multi @@ -35,9 +35,9 @@ class ProcurementGroup(models.Model): rma_id = fields.Many2one( comodel_name='rma.order', string='RMA', - ondelete="set null", + ondelete="set null", copy=False ) rma_line_id = fields.Many2one( comodel_name='rma.order.line', string='RMA line', - ondelete="set null", + ondelete="set null", copy=False, ) diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py index 7ffc346c..38c83112 100644 --- a/rma/models/rma_order_line.py +++ b/rma/models/rma_order_line.py @@ -13,6 +13,7 @@ ops = {'=': operator.eq, class RmaOrderLine(models.Model): _name = "rma.order.line" _inherit = ['mail.thread'] + _order = 'create_date desc, id desc' @api.model def _get_default_type(self): @@ -191,14 +192,17 @@ class RmaOrderLine(models.Model): rma_id = fields.Many2one( comodel_name='rma.order', string='RMA Group', track_visibility='onchange', readonly=True, + copy=False ) name = fields.Char( string='Reference', required=True, default='/', readonly=True, states={'draft': [('readonly', False)]}, + copy=False, help='Add here the supplier RMA #. Otherwise an internal code is' ' assigned.', ) description = fields.Text(string='Description') + conditions = fields.Html(string='Terms and conditions') origin = fields.Char( string='Source Document', readonly=True, states={'draft': [('readonly', False)]}, @@ -252,7 +256,7 @@ class RmaOrderLine(models.Model): required=True, readonly=True, states={'draft': [('readonly', False)]}, ) - price_unit = fields.Monetary( + price_unit = fields.Float( string='Price Unit', readonly=True, states={'draft': [('readonly', False)]}, ) @@ -335,7 +339,8 @@ class RmaOrderLine(models.Model): default=_default_location_id, ) customer_rma_id = fields.Many2one( - 'rma.order.line', string='Customer RMA line', ondelete='cascade') + 'rma.order.line', string='Customer RMA line', ondelete='cascade', + copy=False) supplier_rma_line_ids = fields.One2many( 'rma.order.line', 'customer_rma_id') rma_line_count = fields.Integer( @@ -642,18 +647,19 @@ class RmaOrderLine(models.Model): # from customer we link to supplier rma action = self.env.ref( 'rma.action_rma_supplier_lines') - rma_lines = self.supplier_rma_line_ids.ids + rma_lines = self.supplier_rma_line_ids res = self.env.ref('rma.view_rma_line_supplier_form', False) else: # from supplier we link to customer rma action = self.env.ref( 'rma.action_rma_customer_lines') - rma_lines = self.customer_rma_id.ids + rma_lines = self.customer_rma_id res = self.env.ref('rma.view_rma_line_form', False) result = action.read()[0] # choose the view_mode accordingly if rma_lines and len(rma_lines) != 1: - result['domain'] = rma_lines.ids + result['domain'] = "[('id', 'in', " + \ + str(rma_lines.ids) + ")]" elif len(rma_lines) == 1: result['views'] = [(res and res.id or False, 'form')] result['res_id'] = rma_lines[0] diff --git a/rma/models/stock.py b/rma/models/stock.py index 68ee56da..513adbf5 100644 --- a/rma/models/stock.py +++ b/rma/models/stock.py @@ -26,7 +26,7 @@ class StockMove(models.Model): _inherit = "stock.move" rma_line_id = fields.Many2one('rma.order.line', string='RMA line', - ondelete='restrict') + ondelete='restrict', copy=False) @api.model def create(self, vals): diff --git a/rma/report/rma_report_templates.xml b/rma/report/rma_report_templates.xml index 997dc28f..7a75cdcc 100644 --- a/rma/report/rma_report_templates.xml +++ b/rma/report/rma_report_templates.xml @@ -84,6 +84,10 @@

Description

+
+

Term and Conditions

+ +
diff --git a/rma/views/rma_order_line_view.xml b/rma/views/rma_order_line_view.xml index d9d98cfb..1e2c3101 100644 --- a/rma/views/rma_order_line_view.xml +++ b/rma/views/rma_order_line_view.xml @@ -198,6 +198,7 @@ + @@ -371,6 +372,7 @@ + diff --git a/rma_account/models/invoice.py b/rma_account/models/invoice.py index be086069..b8026884 100644 --- a/rma_account/models/invoice.py +++ b/rma_account/models/invoice.py @@ -156,11 +156,12 @@ class AccountInvoiceLine(models.Model): compute=_compute_rma_count, string='# of RMA') rma_line_ids = fields.One2many( comodel_name='rma.order.line', inverse_name='invoice_line_id', - string="RMA", readonly=True, + string="RMA", readonly=True, copy=False, help="This will contain the RMA lines for the invoice line") rma_line_id = fields.Many2one( comodel_name='rma.order.line', string="RMA line refund", + copy=False, ondelete="set null", help="This will contain the rma line that originated the refund line") diff --git a/rma_purchase/models/purchase_order_line.py b/rma_purchase/models/purchase_order_line.py index 53184ee6..ef795ce4 100644 --- a/rma_purchase/models/purchase_order_line.py +++ b/rma_purchase/models/purchase_order_line.py @@ -13,7 +13,7 @@ class PurchaseOrderLine(models.Model): state = fields.Selection(related='order_id.state', store=True) rma_line_id = fields.Many2one( - comodel_name='rma.order.line', string='RMA', + comodel_name='rma.order.line', string='RMA', copy=False ) @api.model diff --git a/rma_sale/models/sale_order_line.py b/rma_sale/models/sale_order_line.py index 2b8c1551..a6e5cdfe 100644 --- a/rma_sale/models/sale_order_line.py +++ b/rma_sale/models/sale_order_line.py @@ -47,7 +47,8 @@ class SaleOrderLine(models.Model): return super(SaleOrderLine, self).name_get() rma_line_id = fields.Many2one( - comodel_name='rma.order.line', string='RMA', ondelete='restrict') + comodel_name='rma.order.line', string='RMA', ondelete='restrict', + copy=False) @api.multi def _prepare_order_line_procurement(self, group_id=False):