From fb13528ee945117326315c1e54c0eaf745e7b004 Mon Sep 17 00:00:00 2001 From: Aristobulo Meneses Date: Fri, 31 Jul 2015 14:46:05 +0200 Subject: [PATCH] Use crm_claim_code --- crm_claim_rma/__init__.py | 7 ----- crm_claim_rma/__openerp__.py | 2 +- crm_claim_rma/crm_claim_rma.py | 36 +++------------------- crm_claim_rma/crm_claim_rma_view.xml | 12 -------- crm_claim_rma/i18n/crm_claim_rma.pot | 16 ---------- crm_claim_rma/i18n/es.po | 16 ---------- crm_claim_rma/i18n/fr.po | 16 ---------- crm_claim_rma/i18n/pt_BR.po | 16 ---------- crm_claim_rma/tests/test_lp_1282584.py | 2 +- crm_claim_rma/wizard/claim_make_picking.py | 2 +- 10 files changed, 7 insertions(+), 118 deletions(-) diff --git a/crm_claim_rma/__init__.py b/crm_claim_rma/__init__.py index 5b7f9485..258c6d7c 100644 --- a/crm_claim_rma/__init__.py +++ b/crm_claim_rma/__init__.py @@ -26,10 +26,3 @@ from . import wizard from . import crm_claim_rma from . import account_invoice from . import stock - - -def fill_claim_number(cr): - cr.execute(""" - UPDATE crm_claim SET number=id::varchar - WHERE number is NULL OR number = '/'; - """) diff --git a/crm_claim_rma/__openerp__.py b/crm_claim_rma/__openerp__.py index 98bec9ba..1c8a63be 100644 --- a/crm_claim_rma/__openerp__.py +++ b/crm_claim_rma/__openerp__.py @@ -79,6 +79,7 @@ Contributors: 'depends': ['sale', 'stock', 'crm_claim', + 'crm_claim_code', 'product_warranty', ], 'data': ['wizard/claim_make_picking_view.xml', @@ -94,7 +95,6 @@ Contributors: 'images/return_line.png', 'images/exchange.png', ], - 'pre_init_hook': 'fill_claim_number', 'installable': True, 'auto_install': False, } diff --git a/crm_claim_rma/crm_claim_rma.py b/crm_claim_rma/crm_claim_rma.py index 5a152ee6..4c310d2c 100644 --- a/crm_claim_rma/crm_claim_rma.py +++ b/crm_claim_rma/crm_claim_rma.py @@ -402,12 +402,6 @@ class ClaimLine(Model): class CrmClaim(Model): _inherit = 'crm.claim' - @api.model - def _get_sequence_number(self): - seq_obj = self.env['ir.sequence'] - res = seq_obj.get('crm.claim.rma') or '/' - return res - def _get_default_warehouse(self): company_id = self.env.user.company_id.id wh_obj = self.env['stock.warehouse'] @@ -421,36 +415,23 @@ class CrmClaim(Model): def name_get(self): res = [] for claim in self: - number = claim.number and str(claim.number) or '' - res.append((claim.id, '[' + number + '] ' + claim.name)) + code = claim.code and str(claim.code) or '' + res.append((claim.id, '[' + code + '] ' + claim.name)) return res - @api.model - def create(self, vals): - if ('number' not in vals) or (vals.get('number') == '/'): - vals['number'] = self._get_sequence_number() - - claim = super(CrmClaim, self).create(vals) - return claim - def copy_data(self, cr, uid, id, default=None, context=None): if default is None: default = {} std_default = { 'invoice_ids': False, 'picking_ids': False, - 'number': self._get_sequence_number(cr, uid, context), + 'code': self.env['ir.sequence'].get('crm.claim'), } std_default.update(default) return super(CrmClaim, self).copy_data(cr, uid, id, std_default, context=context) - number = fields.Char( - string='Number', readonly=True, - required=True, - select=True, - default='/', - help="Company internal claim unique number") + claim_type = fields.Selection( [('customer', 'Customer'), ('supplier', 'Supplier'), @@ -484,15 +465,6 @@ class CrmClaim(Model): default=_get_default_warehouse, required=True) - @api.one - @api.constrains('number') - def _check_unq_number(self): - if self.search([ - ('company_id', '=', self.company_id.id), - ('number', '=', self.number), - ('id', '!=', self.id)]): - raise ValidationError(_('Claim number has to be unique!')) - @api.onchange('invoice_id', 'warehouse_id', 'claim_type', 'date') def _onchange_invoice_warehouse_type_date(self): context = self.env.context diff --git a/crm_claim_rma/crm_claim_rma_view.xml b/crm_claim_rma/crm_claim_rma_view.xml index 61d7e7b3..78786f16 100644 --- a/crm_claim_rma/crm_claim_rma_view.xml +++ b/crm_claim_rma/crm_claim_rma_view.xml @@ -138,9 +138,6 @@ - - - @@ -316,12 +313,6 @@ - -
-
-
@@ -389,9 +380,6 @@ crm.claim - - - diff --git a/crm_claim_rma/i18n/crm_claim_rma.pot b/crm_claim_rma/i18n/crm_claim_rma.pot index 2a2d31af..5967dd30 100644 --- a/crm_claim_rma/i18n/crm_claim_rma.pot +++ b/crm_claim_rma/i18n/crm_claim_rma.pot @@ -562,11 +562,6 @@ msgstr "" msgid "Unit sale price of the product. Auto filled if retrun done by invoice selection. Be careful and check the automatic value as don't take into account previous refunds, invoice discount, can be for 0 if product for free,..." msgstr "" -#. module: crm_claim_rma -#: sql_constraint:crm.claim:0 -msgid "Number/Reference must be unique per Company!" -msgstr "" - #. module: crm_claim_rma #: code:addons/crm_claim_rma/crm_claim_rma.py:313 #, python-format @@ -625,11 +620,6 @@ msgstr "" msgid "Merchandise Not Received" msgstr "" -#. module: crm_claim_rma -#: help:crm.claim,number:0 -msgid "Company internal claim unique number" -msgstr "" - #. module: crm_claim_rma #: model:ir.ui.menu,name:crm_claim_rma.menu_crm_case_claims_claim_line_substates msgid "Returned line substates" @@ -652,12 +642,6 @@ msgstr "" msgid "Source Location" msgstr "" -#. module: crm_claim_rma -#: field:crm.claim,number:0 -#: model:ir.model.fields,field_description:crm_claim_rma.field_crm_claim_number -msgid "Number" -msgstr "" - #. module: crm_claim_rma #: model:ir.actions.act_window,name:crm_claim_rma.act_crm_claim_rma_picking_out msgid "Deliveries" diff --git a/crm_claim_rma/i18n/es.po b/crm_claim_rma/i18n/es.po index 09e99cdf..80a235b9 100644 --- a/crm_claim_rma/i18n/es.po +++ b/crm_claim_rma/i18n/es.po @@ -599,11 +599,6 @@ msgstr "" "automático, ya que no tiene en cuenta facturas rectificativas previas, " "descuento de facturas, puede ser 0 si el producto es gratuito, etc..." -#. module: crm_claim_rma -#: sql_constraint:crm.claim:0 -msgid "Number/Reference must be unique per Company!" -msgstr "El número/referencia debe ser único por compañía" - #. module: crm_claim_rma #: code:addons/crm_claim_rma/crm_claim_rma.py:313 #, python-format @@ -662,11 +657,6 @@ msgstr "Tratado" msgid "Merchandise Not Received" msgstr "Mercancía no recibida" -#. module: crm_claim_rma -#: help:crm.claim,number:0 -msgid "Company internal claim unique number" -msgstr "Número único de reclamación interno en la compañia" - #. module: crm_claim_rma #: model:ir.ui.menu,name:crm_claim_rma.menu_crm_case_claims_claim_line_substates msgid "Returned line substates" @@ -689,12 +679,6 @@ msgstr "Facturas de cliente" msgid "Source Location" msgstr "Localización de origen" -#. module: crm_claim_rma -#: field:crm.claim,number:0 -#: model:ir.model.fields,field_description:crm_claim_rma.field_crm_claim_number -msgid "Number" -msgstr "Número" - #. module: crm_claim_rma #: model:ir.actions.act_window,name:crm_claim_rma.act_crm_claim_rma_picking_out msgid "Deliveries" diff --git a/crm_claim_rma/i18n/fr.po b/crm_claim_rma/i18n/fr.po index caf098b0..bb5a1c8f 100644 --- a/crm_claim_rma/i18n/fr.po +++ b/crm_claim_rma/i18n/fr.po @@ -592,11 +592,6 @@ msgstr "" "valeurs automatiques récupérée différentes des précédents avoir, réductions " "sur la facture,..." -#. module: crm_claim_rma -#: sql_constraint:crm.claim:0 -msgid "Number/Reference must be unique per Company!" -msgstr "La référence doit être unique par société !" - #. module: crm_claim_rma #: code:addons/crm_claim_rma/crm_claim_rma.py:313 #, python-format @@ -655,11 +650,6 @@ msgstr "Traité" msgid "Merchandise Not Received" msgstr "Marchandise non reçue" -#. module: crm_claim_rma -#: help:crm.claim,number:0 -msgid "Company internal claim unique number" -msgstr "Numéro unique de réclamation interne à la société" - #. module: crm_claim_rma #: model:ir.ui.menu,name:crm_claim_rma.menu_crm_case_claims_claim_line_substates msgid "Returned line substates" @@ -682,12 +672,6 @@ msgstr "Factures client" msgid "Source Location" msgstr "Emplacement source" -#. module: crm_claim_rma -#: field:crm.claim,number:0 -#: model:ir.model.fields,field_description:crm_claim_rma.field_crm_claim_number -msgid "Number" -msgstr "Numéro" - #. module: crm_claim_rma #: model:ir.actions.act_window,name:crm_claim_rma.act_crm_claim_rma_picking_out msgid "Deliveries" diff --git a/crm_claim_rma/i18n/pt_BR.po b/crm_claim_rma/i18n/pt_BR.po index a132a08d..98791d33 100644 --- a/crm_claim_rma/i18n/pt_BR.po +++ b/crm_claim_rma/i18n/pt_BR.po @@ -581,11 +581,6 @@ msgid "" "free,..." msgstr "" -#. module: crm_claim_rma -#: sql_constraint:crm.claim:0 -msgid "Number/Reference must be unique per Company!" -msgstr "" - #. module: crm_claim_rma #: code:addons/crm_claim_rma/crm_claim_rma.py:313 #, python-format @@ -644,11 +639,6 @@ msgstr "" msgid "Merchandise Not Received" msgstr "" -#. module: crm_claim_rma -#: help:crm.claim,number:0 -msgid "Company internal claim unique number" -msgstr "" - #. module: crm_claim_rma #: model:ir.ui.menu,name:crm_claim_rma.menu_crm_case_claims_claim_line_substates msgid "Returned line substates" @@ -671,12 +661,6 @@ msgstr "" msgid "Source Location" msgstr "" -#. module: crm_claim_rma -#: field:crm.claim,number:0 -#: model:ir.model.fields,field_description:crm_claim_rma.field_crm_claim_number -msgid "Number" -msgstr "" - #. module: crm_claim_rma #: model:ir.actions.act_window,name:crm_claim_rma.act_crm_claim_rma_picking_out msgid "Deliveries" diff --git a/crm_claim_rma/tests/test_lp_1282584.py b/crm_claim_rma/tests/test_lp_1282584.py index 64e5d2b1..9b641a7d 100644 --- a/crm_claim_rma/tests/test_lp_1282584.py +++ b/crm_claim_rma/tests/test_lp_1282584.py @@ -43,7 +43,7 @@ class test_lp_1282584(TransactionCase): self.claim = claim_obj.create( { 'name': 'TEST CLAIM', - 'number': 'TEST CLAIM', + 'code': 'TEST CLAIM', 'claim_type': 'customer', 'delivery_address_id': self.partner.id, } diff --git a/crm_claim_rma/wizard/claim_make_picking.py b/crm_claim_rma/wizard/claim_make_picking.py index 4048cf53..fa1bf9f4 100644 --- a/crm_claim_rma/wizard/claim_make_picking.py +++ b/crm_claim_rma/wizard/claim_make_picking.py @@ -222,7 +222,7 @@ class ClaimMakePicking(TransientModel): # create picking picking = picking_obj.create( - {'origin': claim.number, + {'origin': claim.code, 'picking_type_id': picking_type_id, 'move_type': 'one', # direct 'state': 'draft',