savoirfairelinux-openerp team mailing list archive
-
savoirfairelinux-openerp team
-
Mailing list archive
-
Message #00332
lp:~savoirfairelinux-openerp/partner-contact-management/partner_isp into lp:partner-contact-management
Joao Alfredo Gama Batista has proposed merging lp:~savoirfairelinux-openerp/partner-contact-management/partner_isp into lp:partner-contact-management.
Requested reviews:
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903)
For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/partner_isp/+merge/185095
Added the partner_isp module.
--
https://code.launchpad.net/~savoirfairelinux-openerp/partner-contact-management/partner_isp/+merge/185095
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/partner-contact-management/partner_isp.
=== added directory 'partner_isp'
=== added file 'partner_isp/__init__.py'
--- partner_isp/__init__.py 1970-01-01 00:00:00 +0000
+++ partner_isp/__init__.py 2013-09-11 16:19:34 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013 Savoir-faire Linux Inc. (<www.savoirfairelinux.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import partner
=== added file 'partner_isp/__openerp__.py'
--- partner_isp/__openerp__.py 1970-01-01 00:00:00 +0000
+++ partner_isp/__openerp__.py 2013-09-11 16:19:34 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013 Savoir-faire Linux Inc. (<www.savoirfairelinux.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'Partner for ISPs',
+ 'version': '1.0',
+ 'category': 'CRM',
+ 'description': """
+A partner suitable for ISP companies
+====================================
+
+This module provides some minor modifications to the res.partner model including:
+
+* A customer code based on the customers name,
+* Required ZIP code and e-mail fields,
+* A representative field,
+* A birtday field for contacts and representatives.
+ """,
+ 'author': 'Savoir-faire Linux Inc',
+ 'website': 'www.savoirfairelinux.com',
+ 'license': 'AGPL-3',
+ 'depends': ['base'],
+ 'data': ['partner_isp_data.xml'],
+ 'active': False,
+ 'installable': True,
+}
=== added directory 'partner_isp/i18n'
=== added file 'partner_isp/i18n/partner_isp.pot'
=== added file 'partner_isp/partner.py'
--- partner_isp/partner.py 1970-01-01 00:00:00 +0000
+++ partner_isp/partner.py 2013-09-11 16:19:34 +0000
@@ -0,0 +1,130 @@
+# -*- coding: utf-8 -*-
+
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013 Savoir-faire Linux Inc. (<www.savoirfairelinux.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+
+
+class res_partner(orm.Model):
+ _inherit = 'res.partner'
+
+ _columns = {
+ 'birthdate': fields.date('Birth date'),
+ 'representative': fields.char('Representative', size=64),
+ 'code': fields.char('Code', size=16),
+ 'representative_birthdate': fields.date('Representative birth date')
+ }
+
+ def onchange_name(self, cr, uid, ids, name, context=None):
+ words = name.split(u' ')
+ words_treated = []
+ code = u''
+ ret = {'value': None}
+ seq = 1
+ for w in words:
+ if w.find(u'-') != -1:
+ words_treated.append(w.split(u'-'))
+ else:
+ words_treated.append(w)
+
+ words = words_treated
+
+ if len(words) == 1:
+ if isinstance(words[-1], unicode):
+ code += words[0][0]
+ elif isinstance(words[0], list):
+ code += words[0][-1][0]
+ code += words[0][0][0]
+ elif len(words) == 2:
+ if isinstance(words[-1], unicode):
+ code += words[-1][0]
+ elif isinstance(words[-1], list):
+ code += words[-1][0][0]
+ code += words[-1][-1][0]
+ if isinstance(words[0], unicode):
+ code += words[0][0]
+ elif isinstance(words[0], list):
+ code += words[0][-1][0]
+ code += words[0][0][0]
+ elif len(words) == 3:
+ if isinstance(words[-1], unicode):
+ code += words[-1][0]
+ elif isinstance(words[-1], list):
+ code += words[-1][0][0]
+ code += words[-1][-1][0]
+ if isinstance(words[-2], unicode):
+ code += words[-2][0]
+ elif isinstance(words[-2], list):
+ code += words[-2][0][0]
+ code += words[-2][-1][0]
+ if isinstance(words[0], unicode):
+ code += words[0][0]
+ elif isinstance(words[0], list):
+ code += words[0][-1][0]
+ code += words[0][0][0]
+ code = code[:4]
+ elif len(words) >= 4:
+ if isinstance(words[-1], unicode):
+ code += words[-1][0]
+ elif isinstance(words[-1], list):
+ code += words[-1][-1][0]
+ code += words[-1][0][0]
+ if isinstance(words[-2], unicode):
+ code += words[-2][0]
+ elif isinstance(words[-2], list):
+ code += words[-2][0][0]
+ code += words[-2][-1][0]
+ if isinstance(words[0], unicode):
+ code += words[0][0]
+ elif isinstance(words[0], list):
+ code += words[0][0][0]
+ code += words[0][-1][0]
+ if isinstance(words[1], unicode):
+ code += words[1][0]
+ elif isinstance(words[1], list):
+ code += words[1][0][0]
+ code += words[1][-1][0]
+ code = code[:4]
+
+ code = code.upper()
+ while True:
+ query = [('code', '=', code + str(seq)), ('customer', '=', True)]
+ if not self.search(cr, uid, query, context=context):
+ code = code + str(seq)
+ break
+ seq += 1
+ ret['value'] = {'code': code.upper()}
+ return ret
+
+ def write(self, cr, uid, ids, values, context=None):
+ try:
+ values['code'] = self.onchange_name(cr, uid, ids,
+ name=values['name'],
+ context=context)['value']['code']
+ except:
+ pass
+ return super(res_partner, self).write(cr, uid, ids, values, context=context)
+
+ def create(self, cr, uid, values, context=None):
+ values['code'] = self.onchange_name(cr, uid, ids=None,
+ name=values['name'],
+ context=context)['value']['code']
+ return super(res_partner, self).create(cr, uid, values, context=context)
=== added file 'partner_isp/partner_isp_data.xml'
--- partner_isp/partner_isp_data.xml 1970-01-01 00:00:00 +0000
+++ partner_isp/partner_isp_data.xml 2013-09-11 16:19:34 +0000
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="view_partner_isp_form" model="ir.ui.view">
+ <field name="name">res.partner.isp.form</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="base.view_partner_form" />
+ <field name="arch" type="xml">
+ <field name="name" position="before">
+ <field name="code" readonly="1" />
+ </field>
+ <field name="name" position="attributes">
+ <attribute name="on_change">onchange_name(name)</attribute>
+ </field>
+ <field name="website" position="after">
+ <label for="representative" attrs="{'invisible': ['|', ('parent_id', '=', True), ('customer', '=', False)]}"/>
+ <div attrs="{'invisible': ['|', ('parent_id', '=', True), ('customer', '=', False)]}">
+ <field
+ name="representative"
+ placeholder="Representative name"
+ style="width: 63%%" />
+ <field
+ name="representative_birthdate"
+ placeholder="Birth date"
+ style="width: 33%%" />
+ </div>
+ </field>
+ <field name="image" position="replace" />
+ <field name="title" position="attributes">
+ <attribute name="attrs">{'invisible': ['|', ('is_company', '=', True), ('customer', '=', True)]}</attribute>
+ </field>
+ <field name="title" position="before">
+ <field name="birthdate" attrs="{'invisible': ['|', ('is_company', '=', True), ('customer', '=', False)]}" />
+ </field>
+ <field name="zip" position="attributes">
+ <attribute name="attrs">{'required': ['|', ('parent_id', '=', False), ('customer', '=', True)]}</attribute>
+ </field>
+ <field name="email" position="attributes">
+ <attribute name="attrs">{'required': ['|', ('parent_id', '=', False), ('customer', '=', True)]}</attribute>
+ </field>
+ </field>
+ </record>
+
+ <record id="view_res_partner_isp_filter" model="ir.ui.view">
+ <field name="name">res.partner.isp.select</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="base.view_res_partner_filter" />
+ <field name="arch" type="xml">
+ <field name="name" position="after">
+ <field name="zip" />
+ <field name="code" />
+ </field>
+ </field>
+ </record>
+ </data>
+</openerp>
Follow ups