From 9cb4451f6f2a923a955b4f52adade0eb0cfb015c Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Mon, 28 Sep 2015 15:47:14 +0200 Subject: [PATCH] replace copy_data override with copy=False the code for code is already in copy_data of crm_claim_code. added test --- crm_claim_rma/models/crm_claim_rma.py | 35 +++++--------------- crm_claim_rma/tests/test_picking_creation.py | 11 ++++++ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/crm_claim_rma/models/crm_claim_rma.py b/crm_claim_rma/models/crm_claim_rma.py index 812a06dc..cc8bed76 100644 --- a/crm_claim_rma/models/crm_claim_rma.py +++ b/crm_claim_rma/models/crm_claim_rma.py @@ -72,19 +72,6 @@ class ClaimLine(models.Model): self.return_value = (self.unit_sale_price * self.product_returned_quantity) - @api.multi - def copy_data(self, default=None): - if default is None: - default = {} - - std_default = { - 'move_in_id': False, - 'move_out_id': False, - 'refund_line_id': False, - } - std_default.update(default) - return super(ClaimLine, self).copy_data(default=std_default) - def get_warranty_return_partner(self): return self.env['product.supplierinfo'].get_warranty_return_partner() @@ -178,14 +165,17 @@ class ClaimLine(models.Model): refund_line_id = fields.Many2one( 'account.invoice.line', string='Refund Line', + copy=False, help='The refund line related to the returned product') move_in_id = fields.Many2one( 'stock.move', string='Move Line from picking in', + copy=False, help='The move line related to the returned product') move_out_id = fields.Many2one( 'stock.move', string='Move Line from picking out', + copy=False, help='The move line related to the returned product') location_dest_id = fields.Many2one( 'stock.location', @@ -420,18 +410,6 @@ class CrmClaim(models.Model): def name_get(self): return (self.id, u'[{}] {}'.format(self.code or '', self.name)) - @api.multi - def copy_data(self, default=None): - if default is None: - default = {} - std_default = { - 'invoice_ids': False, - 'picking_ids': False, - 'code': self.env['ir.sequence'].get('crm.claim'), - } - std_default.update(default) - return super(CrmClaim, self).copy_data(std_default) - claim_line_ids = fields.One2many('claim.line', 'claim_id', string='Claim lines') planned_revenue = fields.Float(string='Expected revenue') @@ -439,8 +417,11 @@ class CrmClaim(models.Model): real_revenue = fields.Float(string='Real revenue') real_cost = fields.Float(string='Real cost') invoice_ids = fields.One2many('account.invoice', 'claim_id', - string='Refunds') - picking_ids = fields.One2many('stock.picking', 'claim_id', string='RMA') + string='Refunds', + copy=False) + picking_ids = fields.One2many('stock.picking', 'claim_id', + string='RMA', + copy=False) invoice_id = fields.Many2one( 'account.invoice', string='Invoice', diff --git a/crm_claim_rma/tests/test_picking_creation.py b/crm_claim_rma/tests/test_picking_creation.py index ce09c56e..fecdc1c4 100644 --- a/crm_claim_rma/tests/test_picking_creation.py +++ b/crm_claim_rma/tests/test_picking_creation.py @@ -142,3 +142,14 @@ class TestPickingCreation(common.TransactionCase): self.assertEquals(picking.location_dest_id, self.warehouse_id.lot_stock_id, "Incorrect destination location") + + def test_copy(self): + new_claim = self.claim_id.copy() + self.assertNotEqual(new_claim.code, self.claim_id.code) + + def test_mail_thread_recipient(self): + recipients = self.claim_id.message_get_suggested_recipients() + recipients = recipients[self.claim_id.id] + recipient_ids = [r[0] for r in recipients] + self.assertEqual(recipient_ids, + [self.claim_id.partner_id.id])