Browse Source

[IMP][partner_do_merge]Added function for save in a many2many the partners merged

pull/2/head
Luis Tores 12 years ago
parent
commit
7ac839d59f
  1. 1
      partner_do_merge/__openerp__.py
  2. 4
      partner_do_merge/model/partner.py
  3. 21
      partner_do_merge/view/res_partner_view.xml
  4. 7
      partner_do_merge/wizard/merge_by_partner.py

1
partner_do_merge/__openerp__.py

@ -51,6 +51,7 @@ created an action menu in the partner view
'data': [
'wizard/base_partner_merge_view.xml',
'wizard/merge_by_partner.xml',
'view/res_partner_view.xml',
],
'js': [
],

4
partner_do_merge/model/partner.py

@ -66,6 +66,10 @@ class res_partner(osv.Model):
store=_display_name_store_triggers),
'id': fields.integer('Id', readonly=True),
'create_date': fields.datetime('Create Date', readonly=True),
'partner_merged_ids' : fields.many2many('res.partner',\
'partners_mergeds', 'partner_active', 'partner_id', 'Relation '\
'with partner merged', domain=['|', ('active','=',True), (\
'active','=',False)], readonly=True)
}

21
partner_do_merge/view/res_partner_view.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_partner_form_inh_partner_merge_form">
<field name="name">view.partner.form.inh.partner.merge.form</field>
<field name="type">form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='page_history']" position="after">
<page string="Merged With" name="merged_with">
<field name='partner_merged_ids'/>
</page>
</xpath>
</field>
</record>
</data>
</openerp>

7
partner_do_merge/wizard/merge_by_partner.py

@ -62,6 +62,13 @@ class wizard_merge_partner_by_partner(osv.osv_memory):
'adminpaq_id' : 0})
partner_obj.write(cr, uid, data.partner_id.id, {
'adminpaq_id' : adminpac_ids.values()[0]})
list_partners = data.partner_ids
if dst_partner in data.partner_ids:
list_partners.remove(dst_partner)
partner_mergeds = []
for x in list_partners:
partner_mergeds.append(x.id)
partner_obj.write(cr, uid, dst_partner.id, {'partner_merged_ids' : [(6, 0, partner_mergeds)]}, context=context)
return True
Loading…
Cancel
Save