[IMP]Base_setup,Product: config wiz product Terminology move in Base setup & remove from Product

bzr revid: aag@tinyerp.co.in-20110518123722-s0k6xap9w8qwd0lo
This commit is contained in:
aag (OpenERP) 2011-05-18 18:07:22 +05:30
parent e76f48e13b
commit e32610654a
5 changed files with 114 additions and 172 deletions

View File

@ -234,6 +234,56 @@
<field name="type">normal</field>
<field name="state">cancel</field>
</record>
<!-- Specify Your Terminology Config Wiz-->
<record id="view_partner_terminology_config_form" model="ir.ui.view">
<field name="name">Specify Your Terminology</field>
<field name="model">specify.partner.terminology</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml">
<data>
<form position="attributes">
<attribute name="string">Specify Your Terminology</attribute>
</form>
<xpath expr='//separator[@string="title"]' position='attributes'>
<attribute name='string'>Specify Your Terminology</attribute>
</xpath>
<xpath expr="//label[@string='description']"
position="attributes">
<attribute name="string">Based on the industry needs you can use this wizard to change the terminologies for Partners. </attribute>
</xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='string'></attribute>
<attribute name='rowspan'>12</attribute>
</xpath>
<group string="res_config_contents" position="replace">
<group colspan="4">
<field colspan="4" name="partner" />
</group>
</group>
</data>
</field>
</record>
<record id="action_partner_terminology_config_form" model="ir.actions.act_window">
<field name="name">Specify Your Terminology</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">specify.partner.terminology</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_partner_terminology_config_form"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- Register configuration wizard -->
<record id="config_action_partner_terminology_config_form" model="ir.actions.todo">
<field name="action_id" ref="action_partner_terminology_config_form"/>
<field name="type">normal</field>
<field name="state">skip</field>
</record>
</data>
</openerp>

View File

@ -241,4 +241,68 @@ class user_preferences_config(osv.osv_memory):
user_preferences_config()
# Specify Your Terminology
class specify_partner_terminology(osv.osv_memory):
_name = 'specify.partner.terminology'
_inherit = 'res.config'
_columns = {
'partner': fields.selection([('Customer','Customer'),
('Client','Client'),
('Member','Member'),
('Patient','Patient'),
('Partner','Partner'),
('Donor','Donor'),
('Guest','Guest'),
('Tenant','Tenant')
],
'Choose how to call a customer', required=True ),
}
_defaults={
'partner' :'Partner',
}
def translations_done(self, cr, uid, ids, name, type, src, value,res_id = 0, context=None):
trans_obj = self.pool.get('ir.translation')
user_obj = self.pool.get('res.users')
context_lang = user_obj.browse(cr ,uid ,uid , context=context).context_lang
already_id = trans_obj.search(cr,uid, [('name','=',name),('res_id','=',res_id)])
for un_id in already_id:
trans_obj.write(cr ,uid, un_id, {'name': name ,'lang': context_lang, 'type': type, 'src': src, 'value': value , 'res_id':res_id}, context=context)
if not already_id:
create_id = trans_obj.create(cr, uid, {'name': name ,'lang': context_lang, 'type': type, 'src': src, 'value': value , 'res_id':res_id}, context=context)
return {}
def execute(self, cr, uid, ids, context=None):
trans_obj = self.pool.get('ir.translation')
fields_obj = self.pool.get('ir.model.fields')
menu_obj= self.pool.get('ir.ui.menu')
for o in self.browse(cr, uid, ids, context=context):
model_partner_ids = fields_obj.search(cr,uid, [('field_description','ilike','Partner')])
menu_partner_ids = menu_obj.search(cr,uid, [('name','ilike','Partner')])
# For Partner Translation
for p_id in model_partner_ids:
brw_fields_obj = fields_obj.browse(cr ,uid ,p_id , context=context)
name1 = brw_fields_obj.field_description
name2 = name1.replace('Partner',o.partner)
obj2 = brw_fields_obj.model_id.model
field = brw_fields_obj.name
partner_name = obj2 +',' + field
self.translations_done(cr, uid, ids, partner_name, 'field', name1 ,name2 ,context=context )
for m_id in menu_partner_ids:
brw_menu_obj = menu_obj.browse(cr ,uid ,m_id , context=context)
menu_partner_name1 = brw_menu_obj.name
menu_partnr_name = 'ir.ui.menu' + ',' + 'name'
already_id = trans_obj.search(cr,uid, [('name','=',menu_partnr_name),('res_id','=',m_id)])
if already_id:
menu_partner_name1 = trans_obj.browse(cr, uid, already_id[0], context=context).src
menu_partner_name2 = menu_partner_name1.replace('Partner',o.partner)
self.translations_done(cr, uid, ids, menu_partnr_name, 'model', menu_partner_name1 , menu_partner_name2, m_id ,context=context )
return {}
specify_partner_terminology()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,7 +19,6 @@
#
##############################################################################
import product_price
import specify_product_terminology
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -20,56 +20,5 @@
<field name="state">skip</field>
</record>
<!-- Ptoduct Terminology-->
<record id="view_product_terminology_config_form" model="ir.ui.view">
<field name="name">Specify Your Terminology</field>
<field name="model">specify.product.terminology</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_view_base"/>
<field name="arch" type="xml">
<data>
<form position="attributes">
<attribute name="string">Specify Your Terminology</attribute>
</form>
<xpath expr='//separator[@string="title"]' position='attributes'>
<attribute name='string'>Specify Your Terminology</attribute>
</xpath>
<xpath expr="//label[@string='description']"
position="attributes">
<attribute name="string">Specify Your Terminology.</attribute>
</xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='string'></attribute>
<attribute name='rowspan'>12</attribute>
</xpath>
<group string="res_config_contents" position="replace">
<group colspan="4">
<field colspan="4" name="partner" />
<field colspan="4" name="products" />
</group>
</group>
</data>
</field>
</record>
<record id="action_product_terminology_config_form" model="ir.actions.act_window">
<field name="name">Specify Your Terminology</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">specify.product.terminology</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_product_terminology_config_form"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<!-- Register configuration wizard -->
<record id="config_action_product_terminology_config_form" model="ir.actions.todo">
<field name="action_id" ref="action_product_terminology_config_form"/>
<field name="type">normal</field>
<field name="state">skip</field>
</record>
</data>
</openerp>

View File

@ -1,120 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# 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 osv import fields, osv
import pooler
import pytz
class specify_product_terminology(osv.osv_memory):
_name = 'specify.product.terminology'
_inherit = 'res.config'
_columns = {
'partner': fields.selection([('Customer','Customer'),
('Client','Client'),
('Member','Member'),
('Patient','Patient'),
('Partner','Partner'),
('Donor','Donor'),
('Guest','Guest'),
('Tenant','Tenant')
],
'Choose how to call a customer', required=True ),
'products' : fields.char('Choose how to call a Product', size=64),
}
_defaults={
'partner' :'Partners',
'products' :'Product'
}
def trnslate_create(self, cr, uid, ids, name, type, src, value,res_id = False, context=None):
if context is None:
context = {}
trans_obj = self.pool.get('ir.translation')
user_obj = self.pool.get('res.users')
context_lang = user_obj.browse(cr ,uid ,uid , context=context).context_lang
if res_id == False :
res_id = 0
already_id = trans_obj.search(cr,uid, [('name','=',name),('res_id','=',res_id)])
if already_id:
for un_id in already_id:
trans_obj.unlink(cr ,uid, un_id, context=context )
create_id = trans_obj.create(cr, uid, {'name': name ,'lang': context_lang, 'type': type, 'src': src, 'value': value , 'res_id':res_id}, context=context)
return {}
def execute(self, cr, uid, ids, context=None):
if context is None:
context = {}
for o in self.browse(cr, uid, ids, context=context):
trans_obj = self.pool.get('ir.translation')
ir_model = self.pool.get('ir.model.fields')
ir_menu = self.pool.get('ir.ui.menu')
ir_model_prod_id = ir_model.search(cr,uid, [('field_description','like','Product')])
ir_model_partner_id = ir_model.search(cr,uid, [('field_description','like','Partner')])
ir_menu_product_id = ir_menu.search(cr,uid, [('name','like','Product')])
ir_menu_partner_id = ir_menu.search(cr,uid, [('name','like','Partner')])
# For Partner Translation
if ir_model_prod_id:
for p_id in ir_model_partner_id:
brw_ir_model = ir_model.browse(cr ,uid ,p_id , context=context)
name1 = brw_ir_model.field_description
name2 = name1.replace('Partner',o.partner)
obj2 = brw_ir_model.model_id.model
field = brw_ir_model.name
partner_name = obj2 +',' + field
self.trnslate_create(cr, uid, ids, partner_name, 'field', name1 ,name2 ,context=context )
if ir_menu_partner_id:
for m_id in ir_menu_partner_id:
brw_partner_menu = ir_menu.browse(cr ,uid ,m_id , context=context)
menu_partner_name1 = brw_partner_menu.name
menu_partner_name2 = menu_partner_name1.replace('Partner',o.partner)
res_id = m_id
menu_partnr_name = 'ir.ui.menu' + ',' + 'name'
self.trnslate_create(cr, uid, ids, menu_partnr_name, 'model', menu_partner_name1 , menu_partner_name2, res_id ,context=context )
# For Product Translation
if ir_model_prod_id:
for prd_id in ir_model_prod_id:
brw_prod_ir_model = ir_model.browse(cr ,uid ,prd_id , context=context)
name_prod1 = brw_prod_ir_model.field_description
name_prod2 = name_prod1.replace('Product',o.products)
obj_prod = brw_prod_ir_model.model_id.model
prod_field = brw_prod_ir_model.name
product_name = obj_prod +',' + prod_field
self.trnslate_create(cr, uid, ids, product_name, 'field', name_prod1 ,name_prod2 ,context=context )
if ir_menu_product_id:
for m_id in ir_menu_product_id:
brw_menu = ir_menu.browse(cr ,uid ,m_id , context=context)
menu_name1 = brw_menu.name
menu_name2 = menu_name1.replace('Product',o.products)
res_id = m_id
menu_name = 'ir.ui.menu' + ',' + 'name'
self.trnslate_create(cr, uid, ids, menu_name, 'model', menu_name1 , menu_name2, res_id ,context=context )
return {}
specify_product_terminology()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: