Open ERP Forum
   IndexIndex   SearchSearch     RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   RSSRSS   Mailing ListMailing List   Log inLog in 

Expanding Partner fields and views
 
Post new topic   Reply to topic    Open Object Forum Index -> General discussion
View previous topic :: View next topic  
Author Message
greno



Joined: 18 Aug 2007
Posts: 749

PostPosted: Sun Sep 09, 2007 5:23 pm    Post subject: Expanding Partner fields and views Reply with quote

I would like to expand the fields available in the Partner for use in a specific business domain as well as the Partner Contacts. I also would like the new fields displayed in the views. I read through this post http://tinyerp.org/forum/topic4540.html?highlight=inherit%20partner which was helpful but still need some clarification. My goal is to not affect the ability to upgrade TinyERP so I am thinking that the best way to do this may be to create a custom module that would inherit and override the partner and partner contact adding the new fields and also creating new view files. Is this possible? And if so what exactly would need to be modified? Or is it better to just modify the original partner files under addons/base/res/partner?

Gerry
Back to top
View user's profile Send private message
gegard



Joined: 21 Apr 2006
Posts: 1295
Location: Cambridge, UK

PostPosted: Sun Sep 09, 2007 8:24 pm    Post subject: Re: Expanding Partner fields and views Reply with quote

greno wrote:
... the best way to do this may be to create a custom module that would inherit and override the partner and partner contact adding the new fields and also creating new view files. Is this possible? And if so what exactly would need to be modified? ...

This is very much the best way. I've got some examples that I will look out and I'll post one here in the next day or so.

Regards,
Geoff
_________________
Regards,
Geoff
Seath Solutions Ltd
Back to top
View user's profile Send private message Visit poster's website
greno



Joined: 18 Aug 2007
Posts: 749

PostPosted: Sun Sep 09, 2007 11:24 pm    Post subject: Reply with quote

Hi Geoff,
Thanks, that would be great. I'm also debating whether to implement this using properties. Is there a way to group properties so that in a view you lookup one key and then all the related property fields get populated?

Gerry
Back to top
View user's profile Send private message
knerz



Joined: 24 Oct 2006
Posts: 590

PostPosted: Mon Sep 10, 2007 8:04 am    Post subject: Reply with quote

I agree with gegard. You can edit views using the inherit function and naming a position of the new view characteristics (e.g. "in", "after", "replace"). If you want to fully reset a view, the "replace" might be the right one. For a change in the partner_view.xml an possible custom_view.xml looks like this:
Code:

      <record model="ir.ui.view" id="view_partner_form_custom">
         <field name="name">res.partner.form.custom</field>
         <field name="model">res.partner</field>
         <field name="inherit_id" ref="base.view_partner_form" />
         <field name="type">form</field>
         <field name="arch" type="xml">
                  <form string="Partners" position="replace">
                     <form string="Partners">
                                             ======== your custom view tags ========
                      </form>
                  </form>
         </field>
      </record>


knerz
Back to top
View user's profile Send private message
gegard



Joined: 21 Apr 2006
Posts: 1295
Location: Cambridge, UK

PostPosted: Mon Sep 10, 2007 11:53 am    Post subject: Re: Expanding Partner fields and views Reply with quote

gegard wrote:
... I've got some examples that I will look out and I'll post one here in the next day or so. ...

A complete and very tiny example here: new module partner_extension in addons.

Regards,
Geoff

partner_extension/__init__.py
Code:
# <copyright and GPL license>
import partner_extension


partner_extension/__terp__.py
Code:
# <copyright>
{
   "name" : "Partner Extension",
   "depends" : ["partner"],
   "init_xml" : [],
   "demo_xml" : [],
   "update_xml" : ["partner_extension_view.xml"],
   "active": False,
   "installable": True,
# ... and so on
}


partner_extension/partner_extension_view.xml
Code:
<!-- <copyright> -->
<terp>
  <data>

    <!-- Partner form to add 'Alert' field -->
    <!-- res.partner.form -->
    <record model="ir.ui.view" id="view_partner_form1">
      <field name="name">res.partner.form</field>
      <field name="model">res.partner</field>
      <field name="inherit_id" ref="base.view_partner_form" />
      <field name="type">form</field>
      <field name="arch" type="xml">
        <separator string="Categories" position="before">
        <separator string="Important Alerts for this Partner" colspan="4" />
          <field name="alert" colspan="4" select="1" />
        </separator>
      </field>
    </record>
  </data>
</terp>


partner_extension/partner_extension.py
Code:
# <copyright>

from osv import fields, osv

##########
# Extend the partner to include an 'Alert' field
# The default view is also affected
#
class res_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _columns = {
        'alert' : fields.char('Alert', size=250),
    }
res_partner()

_________________
Regards,
Geoff
Seath Solutions Ltd
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Open Object Forum Index -> General discussion All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum