unknown
12 years ago
7 changed files with 140 additions and 7 deletions
-
2partner_do_merge/__openerp__.py
-
4partner_do_merge/model/partner.py
-
21partner_do_merge/view/res_partner_view.xml
-
1partner_do_merge/wizard/__init__.py
-
18partner_do_merge/wizard/base_partner_merge.py
-
65partner_do_merge/wizard/merge_by_partner.py
-
36partner_do_merge/wizard/merge_by_partner.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> |
@ -1 +1,2 @@ |
|||||
import base_partner_merge |
import base_partner_merge |
||||
|
import merge_by_partner |
@ -0,0 +1,65 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
########################################################################### |
||||
|
# Module Writen to OpenERP, Open Source Management Solution |
||||
|
# |
||||
|
# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/ |
||||
|
# All Rights Reserved. |
||||
|
# info Vauxoo (info@vauxoo.com) |
||||
|
############################################################################ |
||||
|
# Coded by: Luis Torres (luis_t@vauxoo.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 osv, fields |
||||
|
from openerp import SUPERUSER_ID |
||||
|
|
||||
|
class wizard_merge_partner_by_partner(osv.osv_memory): |
||||
|
_name = 'wizard.merge.partner.by.partner' |
||||
|
|
||||
|
def default_get(self, cr, uid, fields, context=None): |
||||
|
partner_obj = self.pool.get('res.partner') |
||||
|
partner = partner_obj.browse(cr, uid, context.get('active_id'),\ |
||||
|
context=context) |
||||
|
res = {'partner_id' : partner.id , 'partner_ids' : [partner.id]} |
||||
|
return res |
||||
|
|
||||
|
_columns = { |
||||
|
'partner_id' : fields.many2one('res.partner', 'Partner', readonly=True, |
||||
|
required=True, help='Correct partner to complete data'), |
||||
|
'partner_ids': fields.many2many('res.partner', 'partners_to_merge', |
||||
|
'partner_id', 'wizard_id', 'Partner to merge', help='Partners to '\ |
||||
|
'merge'), |
||||
|
} |
||||
|
|
||||
|
def merge_cb(self, cr, uid, ids, context=None): |
||||
|
base_partner_obj = self.pool.get('base.partner.merge.automatic.wizard') |
||||
|
partner_obj = self.pool.get('res.partner') |
||||
|
for data in self.browse(cr, uid, ids, context=context): |
||||
|
dst_partner = data.partner_id |
||||
|
partner_ids = set(map(int, data.partner_ids)) |
||||
|
if len(partner_ids) >= 2: |
||||
|
base_partner_obj.merge_pbp(cr, SUPERUSER_ID, partner_ids,\ |
||||
|
dst_partner, context=context) |
||||
|
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 |
||||
|
|
||||
|
|
@ -0,0 +1,36 @@ |
|||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record model="ir.ui.view" id="view_merge_parter_by_partner_wizard"> |
||||
|
<field name="name">view.merge.partner.by.partner.wizard</field> |
||||
|
<field name="model">wizard.merge.partner.by.partner</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="Merge Parners" version="7.0"> |
||||
|
<group> |
||||
|
<field name='partner_id'/> |
||||
|
<field name='partner_ids'> |
||||
|
<tree string="Partners to Merge"> |
||||
|
<field name="name"/> |
||||
|
</tree> |
||||
|
</field> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button name="merge_cb" type="object" string="Merge" class="oe_highlight"/> |
||||
|
or |
||||
|
<button name="action_skip" type="object" special="cancel" string="Cancel" class="oe_link"/> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<act_window id="merge_parter_by_partner_wizard" |
||||
|
name="Merge Partners" |
||||
|
src_model="res.partner" |
||||
|
res_model="wizard.merge.partner.by.partner" |
||||
|
view_mode="form" |
||||
|
target="new" |
||||
|
key2="client_action_multi" |
||||
|
/> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue