From 0186d4513d8b9175d89607caaa3832ec40932fd4 Mon Sep 17 00:00:00 2001 From: Thomas Rehn Date: Wed, 13 Nov 2013 16:18:37 +0100 Subject: [PATCH] improve adherance to coding conventions --- base_partner_sequence/__init__.py | 7 +++--- base_partner_sequence/__openerp__.py | 25 +++++++++---------- .../{partner_sequence.py => partner.py} | 23 +++++++++-------- 3 files changed, 27 insertions(+), 28 deletions(-) rename base_partner_sequence/{partner_sequence.py => partner.py} (83%) diff --git a/base_partner_sequence/__init__.py b/base_partner_sequence/__init__.py index 9c107a729..40b7591a3 100644 --- a/base_partner_sequence/__init__.py +++ b/base_partner_sequence/__init__.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,9 +15,8 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## -import partner_sequence +import partner # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/base_partner_sequence/__openerp__.py b/base_partner_sequence/__openerp__.py index 65619fcd6..f7aec863e 100644 --- a/base_partner_sequence/__openerp__.py +++ b/base_partner_sequence/__openerp__.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # Copyright (C) 2013 initOS GmbH & Co. KG (). @@ -17,29 +17,28 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## { - "name" : "Add a sequence on customers' code", - "version" : "1.1", - "author" : "initOS GmbH & Co. KG", - "category" : "Generic Modules/Base", + "name": "Add a sequence on customers' code", + "version": "1.1", + "author": "initOS GmbH & Co. KG", + "category": "Generic Modules/Base", "website": "http://www.initos.com", - "depends" : ["base"], - "summary" : "Sets customer's code from a sequence", + "depends": ["base"], + "summary": "Sets customer's code from a sequence", "description": """ This module adds the possibility to define a sequence for the partner code. This code is then set as default when you - create a new customer, using the defined sequence. + create a new partner (not a contact), using the defined sequence. This module is a migration of the original base_partner_sequence addon to OpenERP version 7.0. """, - "demo_xml" : [], - "init_xml" : ['partner_sequence.xml'], - "update_xml" : [], + "demo_xml": [], + "init_xml": ['partner_sequence.xml'], + "update_xml": [], "active": False, "installable": True } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/base_partner_sequence/partner_sequence.py b/base_partner_sequence/partner.py similarity index 83% rename from base_partner_sequence/partner_sequence.py rename to base_partner_sequence/partner.py index b19d3afe0..36b715f09 100644 --- a/base_partner_sequence/partner_sequence.py +++ b/base_partner_sequence/partner.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # Copyright (C) 2013 initOS GmbH & Co. KG (). @@ -17,26 +17,27 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## -from osv import osv, fields -import logging -_logger = logging.getLogger(__name__) +from openerp.osv import orm, fields + + +class ResPartner(orm.Model): + """Assigns 'ref' from a sequence on creation""" -class partner_sequence(osv.osv): _inherit = 'res.partner' + def create(self, cr, uid, vals, context={}): # only assign a 'ref' if it is not a child object # (such as a shipping/invoice address) - if vals.get('parent_id', 0) > 0: + if not vals.get('parent_id'): vals['ref'] = self.pool.get('ir.sequence').get(cr, uid, 'res.partner') - res = super(partner_sequence, self).create(cr, uid, vals, context) - return res + return super(ResPartner, self).create(cr, uid, vals, context) + _columns = { 'ref': fields.char('Code', size=64, readonly=True), } -partner_sequence() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: