Merge lp:~vrt-openerp/openobject-addons/6.1-trunk-bug-923440 into lp:openobject-addons/6.1

Proposed by Stuart Longland
Status: Needs review
Proposed branch: lp:~vrt-openerp/openobject-addons/6.1-trunk-bug-923440
Merge into: lp:openobject-addons/6.1
Diff against target: 548 lines (+284/-56)
3 files modified
base_contact/base_contact.py (+161/-25)
base_contact/base_contact_view.xml (+121/-30)
base_contact/security/ir.model.access.csv (+2/-1)
To merge this branch: bzr merge lp:~vrt-openerp/openobject-addons/6.1-trunk-bug-923440
Reviewer Review Type Date Requested Status
Amit Parik (community) Disapprove
OpenERP Core Team Pending
Review via email: mp+96493@code.launchpad.net

This proposal supersedes a proposal from 2012-03-07.

Description of the change

This branch contains the fixes presented in bug #923440 and bug #940264.

I'd like to thank Etienne Hirt for providing many of the patches which were used to construct this branch. All I did was tidy things up a bit, he did all the work. :-)

Note: I've updated the target branch and rebased off its head.

To post a comment you must log in.
6649. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6650. By Olivier Dony (Odoo)

[FIX] mail*: properly handle b64-encoding for attachments

When reading the datas property of an attachment,
a base64-encoded stream is expected.
The mail.message.schedule_with_attach() method OTOH
expects a binary file for attachments, so it should
be decoded if extracted from a binary field.

6651. By Olivier Dony (Odoo)

[FIX] crm: typo + duplicate line due to bad merge + bad hardcoded models

6652. By Olivier Dony (Odoo)

[FIX] crm_partner_assign: partial revert of recent commit, care for missing city/zip

6653. By Olivier Dony (Odoo)

[FIX] email_template: care for missing context

6654. By Olivier Dony (Odoo)

[FIX] marketing_campaign: correct search view, today should not be OR'ed with states

In 6.1 a group of filters in a search view are
OR'ed together if toggled when they are contained
within the same 'separator' group.

6655. By Olivier Dony (Odoo)

[FIX] crm_partner_assign: google map is confused by certain country names

6656. By Olivier Dony (Odoo)

[FIX] crm_partner_assign: geolocalization was bad for large countries e.g. US or Russia

Add one more step considering a slightly larger
range around the lead within the same country,
before considering the whole country at once.
Courtesy of Dhara Shah

6657. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6658. By Olivier Dony (Odoo)

[FIX] res.partner.bank: respect company restrictions when assign parent account for new bank GL account

6659. By Olivier Dony (Odoo)

[FIX] lunch: missing product description in list view

6660. By Olivier Dony (Odoo)

[FIX] portal: mark portal users as `share` to exclude from lists by default

6661. By Olivier Dony (Odoo)

[FIX] email.template: body_html should be translatable

6662. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6663. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6664. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6665. By Olivier Dony (Odoo)

[FIX] hr_holidays: Leaves calendar view should be filtered by users, not description

6666. By Olivier Dony (Odoo)

[FIX] project: project preference field must be editable

The user preferences screen is kind of a hack
because it lets the user modify fields on a
model that is normally read-only for her (res.users).
This is accomplished by a custom write() method
on res.users combined with a view on which some
fields are forced to be read-write using a
trick: @readonly=0.

6667. By Stephane Wirtel (OpenERP)

[FIX] In the case where the user has no signature, we set up a default value to avoid to have a body with 'False'.

6668. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6669. By Quentin (OpenERP) <email address hidden>

[FIX] account: qucik and dirty fix on the common wizard of reports to set the company_id by default in order to avoid having the name_search of fiscalyear processed before it is correctly set by the onchange of default value of chart account id. This bug is due to asynchronous calls of web client and will be solved asap, but in the meanwhile this little hack will localy solve the problem.

6670. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6671. By Olivier Dony (Odoo)

[FIX] project_issue: global CC fields contains email(s), not a URL

6672. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6673. By Olivier Dony (Odoo)

[FIX] email_template: attachments were not being sent due to programming error

6674. By Olivier Dony (Odoo)

[FIX] sale,sale_layout: avoid RML loop when printing SO with very long notes

Forward port of revision 5001 from the
6.0 branch. Apparently very long SO
notes (above 2200 characters) will cause
an endless loop while trying to render
inside a blockTable

6675. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6676. By Christophe Simonis (OpenERP)

[FIX] email_template: report_name must be rendered

6677. By Quentin (OpenERP) <email address hidden>

[MERGE] opw-381937. Stock: don't set an arbitrary value of 1 when valuating a stock move of a product with 0 as unit amount

6678. By Olivier Dony (Odoo)

[FIX] mail.message: when auto-deleting a message, only delete attachments it owns

There's a peculiar way to manage attachments on
mail messages, as there is an explicit many2many
on top of regular attachments like for any
record, so it is possible to link a mail
to attachments that are owned by other records.
Such attachments must not be deleted along with
the message when the auto-delete flag is set.

6679. By Olivier Dony (Odoo)

[MERGE] base.action.rule: better handle non-ASCII data

Also fixes the `regex_history` expression
that should search on the `subject` field
now (it was renamed in 6.1).

6680. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6681. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6682. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6683. By Quentin (OpenERP) <email address hidden>

[FIX] account: build_ctx_period must always return a list of ids

6684. By Olivier Dony (Odoo)

[FIX] mail.message: allow reading msg even if author belongs to another company

6685. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6686. By Raphael Collet (OpenERP)

[FIX] backport of branch trunk-bug-937194-nco (mail: remove character &#13; from message)

6687. By Olivier Dony (Odoo)

[FIX] edi: company logo appears truncated on EDI preview in Firefox

6688. By Olivier Dony (Odoo)

[FIX] edi: avoid disprupting EDI preview layout with wide notes

6689. By Olivier Dony (Odoo)

[FIX] edi: care for missing invoice fields in EDI preview (instead of displaying `false`)

6690. By Olivier Dony (Odoo)

[MERGE] procurement: Fix typo (bug 956234), courtesy of Guewen Baconnier @ Camptocamp

6691. By Olivier Dony (Odoo)

[MERGE] Update l10n_it account types, courtesy of Lorenzo Battistini (Agile BG - Domsense)

6692. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6693. By Xavier ALT

[MERGE] OPW 573035: fetchmail: UnboundLocalError: local variable imap_server referenced before assignment

6694. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6695. By Olivier Dony (Odoo)

[FIX] mail: default permissions should allow write for everyone

Mail messages are created in multiple steps that
usually involve calling write() at some point, so
giving all users write access is necessary.

6696. By Olivier Dony (Odoo)

[MERGE] Properly pass context when incrementing sequences, courtesy of Stefan Rijnhart (Therp)

6697. By Rucha Patel <email address hidden>

[FIX] email_template: don't re-encode attachments copied from template'

6698. By Rucha Patel <email address hidden>

[FIX] email_template: ensure non-empty context when rendering template'

6699. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6700. By Xavier ALT

[MERGE] OPW 573037: audittrail: force admin for subscribe/unsubscribe op - fix 'admin/access rights' members access

6701. By Olivier Dony (Odoo)

[FIX] email.template: properly propagate res_id over context reloads in composition wizard

6702. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6703. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6704. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6705. By Xavier ALT

[MERGE] OPW 381582: stock: on inventory, product qty should be computed up to 'inventory date', not after

6706. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6707. By Xavier ALT

[MERGE] OPW 573041: crm: for crm.lead, force orm 'default_get' to avoid misbehaviour when 'base_contact' is installed

6708. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6709. By Xavier ALT

[MERGE] OPW 381524: stock: on picking invoicing, do not invoice scrapped products

6710. By Xavier ALT

[MERGE] OPW 573244: account: manually unreconcilling move line doesn't switch invoice back to 'open' state

6711. By Xavier ALT

[MERGE] OPW 51189: account: on invoice 'refund', keep original salesman and fiscal position

6712. By Xavier ALT

[MERGE] OPW 16328: account.move.line: do not create writeoff entries when called from fy closing wizard

6713. By Xavier ALT

[MERGE] OPW 50804: stock: fix search_default_available on 'internal move' search view

6714. By Xavier ALT

[MERGE] OPW 381927: project: when copying the project, analytic lines of the related analytic account should not be copied

6715. By Xavier ALT

[MERGE] OPW 381848: purchase_requisition: fix action context as create_uid is not present in the search view

6716. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6717. By Xavier ALT

[MERGE] OWP 572921: account_voucher: fix computation of paid_amount_in_company_currency field

6718. By Olivier Dony (Odoo)

[FIX] Trunk backport: properly record UTC login date, courtesy of Ian Beardslee

6719. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6720. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6721. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6722. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6723. By Xavier ALT

[MERGE] project_issue: by default, convert issue to bug only if there is no provided category

6724. By Christophe Simonis (OpenERP)

[FIX] auth_openid: allow login from direct http request

6725. By Christophe Simonis (OpenERP)

[FIX] auth_openid: use correct api for login users

6726. By Antony Lesuisse (OpenERP)

[MERGE] point_of_sale barcode scanning (manual merge)

6727. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6728. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6729. By Xavier ALT

[MERGE] project_issue: issue analysis have to use 'AVG' group operator for AVG Working Hours fields

6730. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6731. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6732. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6733. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6734. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6735. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6736. By Xavier ALT

[MERGE] report_webkit: remove deprecated 'lib_path' field on company

6737. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6738. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6739. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6740. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6741. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6742. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

6743. By Xavier ALT

[MERGE] report_webkit: handle more gracefull remove of 'lib_path' + fix test in l10n_ch

6749. By Stuart Longland

base_contact: Add support for private addresses

This patch adds support for private contact addresses and allows for the UI to
pick out addresses of a given type by default based on the context.

Credit: Etienne Hirt

6750. By Stuart Longland

Rebase off upstream tree

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Stuart,

This is a big improvement for 6.1, Sorry to say this but we have consider only blocking point as well as small bug fixes for the 6.1 branch . So we can not consider this type of big improvement for 6.1

Thanks for the contribution!

review: Disapprove

Unmerged revisions

6750. By Stuart Longland

Rebase off upstream tree

6749. By Stuart Longland

base_contact: Add support for private addresses

This patch adds support for private contact addresses and allows for the UI to
pick out addresses of a given type by default based on the context.

Credit: Etienne Hirt

6748. By Stuart Longland

Rebase and merge with upstream

6747. By Stuart Longland

base_contact: Make contact_id OR partner_id required

Source and credit: Etienne Hirt
https://bugs.launchpad.net/openobject-addons/+bug/940264/comments/4

This patch mandates that at least one of contact_id OR partner_id (or both)
must be filled in for the object to be valid.

6746. By Stuart Longland

base_contact: Tweak order of address "names"

Tweak name_get so that it returns a string of the form:
 FirstName LastName, Partner, City, Country
rather than the default:
 Partner, FirstName, LastName, City, Country

IMO this should be locale dependent.

6745. By Stuart Longland

base_contact: Remove erronious security/base_contact_security.xml

Seems this is one of many rabbit droppings from the 6.0-branch of OpenERP.

6744. By Stuart Longland

Rebase and merge with upstream 6.1 branch

Credit goes to Etienne Hirt for putting the contributions together. Please see
https://code.launchpad.net/~openerp-community/openobject-addons/trunk-bug-923440-base_contact_finalise6.1

for the original commit log.

I tried to add these changes individually, but ran into numerous snags due to
the way the original branch was constructed (bzr merge won't work as the
branches do not share a common ancestor).

So all changes have been folded into one commit here, with the updates to .po
files filtered out as these seemed to be mostly noise.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'base_contact/base_contact.py'
--- base_contact/base_contact.py 2012-02-15 13:22:13 +0000
+++ base_contact/base_contact.py 2012-04-18 04:27:19 +0000
@@ -21,37 +21,80 @@
2121
22from osv import fields, osv22from osv import fields, osv
23import addons23import addons
24import pdb
2425
25class res_partner_contact(osv.osv):26class res_partner_contact(osv.osv):
26 """ Partner Contact """27 """ Partner Contact """
2728
28 _name = "res.partner.contact"29 _name = "res.partner.contact"
29 _description = "Contact"30 _description = "Contact"
31
32 _rec_name = 'last_name'
3033
34
31 def _name_get_full(self, cr, uid, ids, prop, unknow_none, context=None):35 def _name_get_full(self, cr, uid, ids, prop, unknow_none, context=None):
32 result = {}36 result = {}
33 for rec in self.browse(cr, uid, ids, context=context):37 for rec in self.browse(cr, uid, ids, context=context):
34 result[rec.id] = rec.last_name+' '+(rec.first_name or '')38 #use firstname lastname as in the demo data of base/res/res_partner_demo.xml
39 if(rec.first_name):
40 result[rec.id] = rec.first_name+' '+rec.last_name
41 else:
42 result[rec.id] = rec.last_name
43
35 return result44 return result
45
46 def _main_job(self, cr, uid, ids, fields, arg, context=None):
47 """
48 @summary: Returns id and function of job with the lowest 'sequence_contact'
49 @param self: The object pointer
50 @param cr: the current row, from the database cursor,
51 @param uid: the current user’s ID for security checks,
52 @param ids: List of partner contact’s IDs
53 @fields: Get Fields
54 @param context: A standard dictionary for contextual values
55 @param arg: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. """
56
57 res = dict.fromkeys(ids, False)
58
59 all_ids = self.pool.get('res.partner.address').search(cr, uid, [('contact_id','in',ids)], order='sequence_contact')
60 #pdb.set_trace()
61 addresses = self.pool.get('res.partner.address').browse(cr, uid, all_ids)
62 for addr in addresses:
63 if(res[addr.contact_id.id] == False):
64 res[addr.contact_id.id] = {'partner_id': addr.partner_id.id, 'function': addr.function}
65
66 for id in res:
67 if (res[id]==False):
68 res[id] = {'partner_id': False, 'function': False}
69
70 return res
71
72 def _get_contact_id_from_address(self, cr, uid, ids, context=None):
73 #@todo: remove obsolete function
74 result = {}
75 for addr in self.pool.get('res.partner.address').browse(cr, uid, ids, context=context):
76 result[addr.contact_id.id] = True
77 return result.keys()
78
79
3680
37 _columns = {81 _columns = {
38 'name': fields.function(_name_get_full, string='Name', size=64, type="char", store=True, select=True),82 'name': fields.function(_name_get_full, string='Name', size=64, type="char", store=False, select=True),
39 'last_name': fields.char('Last Name', size=64, required=True),83 'last_name': fields.char('Last Name', size=64, required=True),
40 'first_name': fields.char('First Name', size=64),84 'first_name': fields.char('First Name', size=64),
41 'mobile': fields.char('Mobile', size=64),85 'mobile': fields.char('Mobile', size=64),
42 'title': fields.many2one('res.partner.title','Title', domain=[('domain','=','contact')]),86 'title': fields.many2one('res.partner.title','Title', domain=[('domain','=','contact')]),
43 'website': fields.char('Website', size=120),87 'website': fields.char('Private Website', size=120),
44 'lang_id': fields.many2one('res.lang', 'Language'),88 'lang_id': fields.many2one('res.lang', 'Language'),
45 'job_ids': fields.one2many('res.partner.address', 'contact_id', 'Functions and Addresses'),89 'job_ids': fields.one2many('res.partner.address', 'contact_id', 'Functions and Addresses'),
46 'country_id': fields.many2one('res.country','Nationality'),90 'country_id': fields.many2one('res.country','Nationality'),
47 'birthdate': fields.char('Birthdate', size=64),91 'birthdate': fields.char('Birthdate', size=64),
48 'active': fields.boolean('Active', help="If the active field is set to False,\92 'active': fields.boolean('Active', help="If the active field is set to False,\
49 it will allow you to hide the partner contact without removing it."),93 it will allow you to hide the partner contact without removing it."),
50 'partner_id': fields.related('job_ids', 'partner_id', type='many2one',\94 #Storage for partner_id and function not fully worked and not required -> removed
51 relation='res.partner', string='Main Employer'),95 'partner_id': fields.function(_main_job, type='many2one', relation='res.partner', string='Main Employer', store = False, multi='mainjob'),
52 'function': fields.related('job_ids', 'function', type='char', \96 'function': fields.function(_main_job, type='char', size=128, string='Main Function', store = False, multi='mainjob'),
53 string='Main Function'),97 'email': fields.char('Private E-Mail', size=240),
54 'email': fields.char('E-Mail', size=240),
55 'comment': fields.text('Notes', translate=True),98 'comment': fields.text('Notes', translate=True),
56 'photo': fields.binary('Photo'),99 'photo': fields.binary('Photo'),
57 }100 }
@@ -65,7 +108,7 @@
65 'active' : lambda *a: True,108 'active' : lambda *a: True,
66 }109 }
67110
68 _order = "name"111 _order = "last_name, first_name"
69112
70 def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None):113 def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=None):
71 if not args:114 if not args:
@@ -73,7 +116,7 @@
73 if context is None:116 if context is None:
74 context = {}117 context = {}
75 if name:118 if name:
76 ids = self.search(cr, uid, ['|',('name', operator, name),('first_name', operator, name)] + args, limit=limit, context=context)119 ids = self.search(cr, uid, ['|',('last_name', operator, name),('first_name', operator, name)] + args, limit=limit, context=context)
77 else:120 else:
78 ids = self.search(cr, uid, args, limit=limit, context=context)121 ids = self.search(cr, uid, args, limit=limit, context=context)
79 return self.name_get(cr, uid, ids, context=context)122 return self.name_get(cr, uid, ids, context=context)
@@ -85,6 +128,22 @@
85 if obj.partner_id:128 if obj.partner_id:
86 result[obj.id] = result[obj.id] + ', ' + obj.partner_id.name129 result[obj.id] = result[obj.id] + ', ' + obj.partner_id.name
87 return result.items()130 return result.items()
131
132 def view_init(self, cr, uid, fields, context=None):
133 """
134 This function shall fill the first and last name if empty from context
135 """
136
137 if context is None:
138 context = {}
139 else:
140 default_name = context.get('default_name')
141 #if default_name:
142 #pdb.set_trace()
143 #The following does not work
144 #self._columns['last_name'] = default_name
145 pass
146
88147
89 def _auto_init(self, cr, context=None):148 def _auto_init(self, cr, context=None):
90 def table_exists(view_name):149 def table_exists(view_name):
@@ -99,7 +158,7 @@
99 cr.execute("""158 cr.execute("""
100 INSERT INTO159 INSERT INTO
101 res_partner_contact160 res_partner_contact
102 (id,name,last_name,title,active,email,mobile,birthdate)161 (id,last_name,first_name,title,active,email,mobile,birthdate)
103 SELECT162 SELECT
104 id,COALESCE(name, '/'),COALESCE(name, '/'),title,true,email,mobile,birthdate163 id,COALESCE(name, '/'),COALESCE(name, '/'),title,true,email,mobile,birthdate
105 FROM164 FROM
@@ -124,6 +183,8 @@
124 'job_ids': fields.one2many('res.partner.address', 'location_id', 'Contacts'),183 'job_ids': fields.one2many('res.partner.address', 'location_id', 'Contacts'),
125 'partner_id': fields.related('job_ids', 'partner_id', type='many2one',\184 'partner_id': fields.related('job_ids', 'partner_id', type='many2one',\
126 relation='res.partner', string='Main Partner'),185 relation='res.partner', string='Main Partner'),
186 'contact_id': fields.related('job_ids', 'contact_id', type='many2one',\
187 relation='res.partner.contact', string='First Contact'),
127 }188 }
128 _defaults = {189 _defaults = {
129 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner.address', context=c),190 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner.address', context=c),
@@ -166,6 +227,29 @@
166227
167class res_partner_address(osv.osv):228class res_partner_address(osv.osv):
168 _inherit = 'res.partner.address'229 _inherit = 'res.partner.address'
230
231 def _get_address_from_location_ids(self, cr, uid, ids, context=None):
232 result = {}
233 #if self._name=="res.partner.location":
234 for addr in self.pool.get('res.partner.address').search(cr, uid, [('location_id','in',ids)]):
235 result[addr] = True
236 #else:
237 #raise osv.except_osv(_('getAddressFromLocation'), self._name)
238
239 return result.keys()
240
241 def _get_address_from_contact_ids(self, cr, uid, ids, context=None):
242 result = {}
243 for addr in self.pool.get('res.partner.address').search(cr, uid, [('contact_id','in',ids)]):
244 result[addr] = True
245 return result.keys()
246
247 def _get_own_addresses(self, cr, uid, ids, context=None):
248 result = {}
249 for id in ids:
250 result[id] = True
251 return result.keys()
252
169253
170 def _default_location_id(self, cr, uid, context=None):254 def _default_location_id(self, cr, uid, context=None):
171 if context is None:255 if context is None:
@@ -175,6 +259,17 @@
175 ids = self.pool.get('res.partner.location').search(cr, uid, [('partner_id','=',context['default_partner_id'])], context=context)259 ids = self.pool.get('res.partner.location').search(cr, uid, [('partner_id','=',context['default_partner_id'])], context=context)
176 return ids and ids[0] or False260 return ids and ids[0] or False
177261
262 def onchange_contact_id(self,cr, uid, ids, contact_id=False, context={}):
263 if not contact_id:
264 return {}
265 contact = self.pool.get('res.partner.contact').browse(cr, uid, contact_id, context=context)
266 return {'value':{
267 'mobile': contact.mobile,
268 'name': contact.name,
269 'title': contact.title and contact.title.id or False,
270 }}
271
272
178 def onchange_location_id(self,cr, uid, ids, location_id=False, context={}):273 def onchange_location_id(self,cr, uid, ids, location_id=False, context={}):
179 if not location_id:274 if not location_id:
180 return {}275 return {}
@@ -191,23 +286,57 @@
191 _columns = {286 _columns = {
192 'location_id' : fields.many2one('res.partner.location', 'Location'),287 'location_id' : fields.many2one('res.partner.location', 'Location'),
193 'contact_id' : fields.many2one('res.partner.contact', 'Contact'),288 'contact_id' : fields.many2one('res.partner.contact', 'Contact'),
289
290 #add private type
291 'type': fields.selection( [ ('default','Default'),('invoice','Invoice'), ('delivery','Delivery'), ('contact','Contact'), ('other','Other'), ('private', 'Private') ],'Address Type', help="Used to select automatically the right address according to the context in sales and purchases documents."),
292
293
294 #field for administer functions
295 'sequence_contact': fields.integer('Contact Seq.',help='Order of\
296 importance of this address in the list of addresses of the linked contact'),
297 'sequence_partner': fields.integer('Partner Seq.',help='Order of importance\
298 of this job title in the list of job title of the linked partner'),
299 'date_start': fields.date('Date Start',help="Start date of job(Joining Date)"),
300 'date_stop': fields.date('Date Stop', help="Last date of job"),
301 'state': fields.selection([('past', 'Past'),('current', 'Current')], \
302 'State', required=True, help="Status of Address"),
303
304 #add private type
305 'type': fields.selection( [ ('default','Default'),('invoice','Invoice'), ('delivery','Delivery'), ('contact','Contact'), ('other','Other'), ('private', 'Private') ],'Address Type', help="Used to select automatically the right address according to the context in sales and purchases documents."),
194306
195 # fields from location307 # fields from location
196 'street': fields.related('location_id', 'street', string='Street', type="char", store=True, size=128),308 #Trigger for change of location id of self is not required because this is handled by onchange_location_id triggered in the only form!
197 'street2': fields.related('location_id', 'street2', string='Street2', type="char", store=True, size=128),309 'street': fields.related('location_id', 'street', string='Street', type="char", size=128,
198 'zip': fields.related('location_id', 'zip', string='Zip', type="char", store=True, change_default=True, size=24),310 store = {'res.partner.location': (_get_address_from_location_ids, ['street'], 10),}),
199 'city': fields.related('location_id', 'city', string='City', type="char", store=True, size=128),311 'street2': fields.related('location_id', 'street2', string='Street2', type="char", size=128,
200 'state_id': fields.related('location_id', 'state_id', relation="res.country.state", string='Fed. State', type="many2one", store=True, domain="[('country_id','=',country_id)]"),312 store = {'res.partner.location': (_get_address_from_location_ids, ['street2'], 10),}),
201 'country_id': fields.related('location_id', 'country_id', type='many2one', string='Country', store=True, relation='res.country'),313 'zip': fields.related('location_id', 'zip', string='Zip', type="char", change_default=True, size=24,
314 store = {'res.partner.location': (_get_address_from_location_ids, ['zip'], 10),}),
315 'city': fields.related('location_id', 'city', string='City', type="char", size=128,
316 store = {'res.partner.location': (_get_address_from_location_ids, ['city'], 10),}),
317 'state_id': fields.related('location_id', 'state_id', relation="res.country.state", string='Fed. State', type="many2one", domain="[('country_id','=',country_id)]",
318 store = {'res.partner.location': (_get_address_from_location_ids, ['state_id'], 10),}),
319 'country_id': fields.related('location_id', 'country_id', type='many2one', string='Country', relation='res.country',
320 store = {'res.partner.location': (_get_address_from_location_ids, ['country_id'], 10),}),
202321
203 'phone': fields.char('Phone', size=64),322 #These fields exists
204 'fax': fields.char('Fax', size=64),323 #'phone': fields.char('Phone', size=64),
205 'email': fields.char('E-Mail', size=240),324 #'fax': fields.char('Fax', size=64),
325 #'email': fields.char('E-Mail', size=240),
326 #this field is missing
327 'other': fields.char('Other Phone', size=64, help='Additional phone field'),
206328
207 # fields from contact329 # fields from contact
330
208 'mobile' : fields.related('contact_id', 'mobile', type='char', size=64, string='Mobile'),331 'mobile' : fields.related('contact_id', 'mobile', type='char', size=64, string='Mobile'),
209 'name' : fields.related('contact_id', 'name', type='char', size=64, string="Contact Name", store=True),332 #store = {'res.partner.contact': (_get_address_from_contact_ids, ['mobile'], 10),
210 'title' : fields.related('contact_id', 'title', type='many2one', relation='res.partner.title', string="Title", store=True),333 # 'res.partner.address': (_get_own_addresses,['contact_id'], 20)}), @bug: query wants to store in crm_lead!!!!
334 'name' : fields.related('contact_id', 'name', type='char', size=64, string="Contact Name",
335 store = {'res.partner.contact': (_get_address_from_contact_ids, ['last_name', 'first_name'], 10),
336 'res.partner.address': (_get_own_addresses,['contact_id'], 20)}),
337 'title' : fields.related('contact_id', 'title', type='many2one', relation='res.partner.title', string="Title"),
338 #store = {'res.partner.contact': (_get_address_from_contact_ids, ['title'], 10),
339 # 'res.partner.address': (_get_own_addresses,['contact_id'], 20)}),
211 }340 }
212 def create(self, cr, uid, data, context={}):341 def create(self, cr, uid, data, context={}):
213 if not data.get('location_id', False):342 if not data.get('location_id', False):
@@ -227,10 +356,10 @@
227 result = {}356 result = {}
228 for rec in self.browse(cr,uid, ids, context=context):357 for rec in self.browse(cr,uid, ids, context=context):
229 res = []358 res = []
359 if rec.contact_id and rec.contact_id.name:
360 res.append(rec.contact_id.name)
230 if rec.partner_id:361 if rec.partner_id:
231 res.append(rec.partner_id.name_get()[0][1])362 res.append(rec.partner_id.name_get()[0][1])
232 if rec.contact_id and rec.contact_id.name:
233 res.append(rec.contact_id.name)
234 if rec.location_id:363 if rec.location_id:
235 if rec.location_id.city: res.append(rec.location_id.city)364 if rec.location_id.city: res.append(rec.location_id.city)
236 if rec.location_id.country_id: res.append(rec.location_id.country_id.name_get()[0][1])365 if rec.location_id.country_id: res.append(rec.location_id.country_id.name_get()[0][1])
@@ -238,8 +367,15 @@
238 return result.items()367 return result.items()
239368
240 _defaults = {369 _defaults = {
241 'location_id': _default_location_id370 'location_id': _default_location_id,
371 'sequence_contact' : lambda *a: 0,
372 'sequence_partner' : lambda *a: 10,
373 'state': lambda *a: 'current',
242 }374 }
375
376 _order='sequence_partner, type, name'
377
378
243379
244 def default_get(self, cr, uid, fields=[], context=None):380 def default_get(self, cr, uid, fields=[], context=None):
245 if context is None:381 if context is None:
246382
=== modified file 'base_contact/base_contact_view.xml'
--- base_contact/base_contact_view.xml 2012-01-31 13:36:57 +0000
+++ base_contact/base_contact_view.xml 2012-04-18 04:27:19 +0000
@@ -1,6 +1,52 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3<data>3<data>
4
5 <!-- Address views -->
6
7 <!-- Address Tree view for Contact -->
8 <record id="view_partner_address_tree_contact" model="ir.ui.view">
9 <field name="name">res.partner.address.tree.contact</field>
10 <field name="model">res.partner.address</field>
11 <field name="type">tree</field>
12 <field eval="17" name="priority"/>
13 <field name="arch" type="xml">
14 <tree string="Functions and Addresses" colors="gray:state in ('past')">
15 <field name="location_id"/>
16 <field name="function"/>
17 <field name="email" widget="email"/>
18 <field name="phone"/>
19 <field name="other" />
20 <field name="fax"/>
21 <field name="type"/>
22 <field name="state" />
23 <field name="sequence_contact" string="Seq."/>
24 </tree>
25 </field>
26 </record>
27
28 <!-- Adress Tree view for Partner -->
29 <record id="view_partner_address_tree_partner" model="ir.ui.view">
30 <field name="name">res.partner.address.tree.partner</field>
31 <field name="model">res.partner.address</field>
32 <field name="type">tree</field>
33 <field eval="18" name="priority"/>
34 <field name="arch" type="xml">
35 <tree string="Partner Contacts" colors="gray:state in ('past')" >
36 <field name="name"/>
37 <field name="location_id"/>
38 <field name="function"/>
39 <field name="email" widget="email"/>
40 <field name="phone"/>
41 <field name="mobile"/>
42 <field name="other" />
43 <field name="fax"/>
44 <field name="type"/>
45 <field name="state" />
46 <field name="sequence_partner" string="Seq."/>
47 </tree>
48 </field>
49 </record>
450
5 <!-- Views for Contacts Tree View -->51 <!-- Views for Contacts Tree View -->
652
@@ -10,7 +56,7 @@
10 <field name="type">tree</field>56 <field name="type">tree</field>
11 <field name="arch" type="xml">57 <field name="arch" type="xml">
12 <tree string="Partner Contact">58 <tree string="Partner Contact">
13 <field name="name"/>59 <field name="last_name"/>
14 <field name="first_name"/>60 <field name="first_name"/>
15 <field name="mobile"/>61 <field name="mobile"/>
16 <field name="email"/>62 <field name="email"/>
@@ -48,22 +94,8 @@
48 <field name="photo" widget='image' nolabel="1"/>94 <field name="photo" widget='image' nolabel="1"/>
49 </group>95 </group>
50 </group>96 </group>
51 <field name="job_ids" colspan="4" nolabel="1" mode="tree,form">97 <!-- default_type is not followed! -->
52 <form string="Functions and Addresses">98 <field name="job_ids" colspan="4" nolabel="1" mode="tree,form" context="{'tree_view_ref' : 'base_contact.view_partner_address_tree_contact', 'default_contact_id': active_id, 'default_type': 'contact'}">
53 <field name="partner_id" />
54 <field name="location_id" domain="[('partner_id', '=', partner_id)]"/>
55 <field name="function" />
56 <separator string="Professional Info" colspan="4"/>
57 <field name="phone"/>
58 <field name="fax"/>
59 <field name="email" widget="email"/>
60 </form>
61 <tree string="Functions and Addresses">
62 <field name="location_id"/>
63 <field name="function"/>
64 <field name="phone"/>
65 <field name="email"/>
66 </tree>
67 </field>99 </field>
68 </page>100 </page>
69 <page string="Extra Information">101 <page string="Extra Information">
@@ -93,7 +125,7 @@
93 <search string="Partner Contact">125 <search string="Partner Contact">
94 <field name="name" string="First/Lastname"126 <field name="name" string="First/Lastname"
95 filter_domain="['|', ('first_name','ilike', self), ('last_name', 'ilike', self)]"/>127 filter_domain="['|', ('first_name','ilike', self), ('last_name', 'ilike', self)]"/>
96 <field name="partner_id" string="Partner"/>128 <field name="job_ids" string="Partner"/>
97 </search>129 </search>
98 </field>130 </field>
99 </record>131 </record>
@@ -127,6 +159,8 @@
127 <menuitem name="Contacts" id="menu_purchases_partner_contact_form" action="action_partner_contact_form"159 <menuitem name="Contacts" id="menu_purchases_partner_contact_form" action="action_partner_contact_form"
128 parent = "base.menu_procurement_management_supplier" sequence="2"/>160 parent = "base.menu_procurement_management_supplier" sequence="2"/>
129161
162 <!-- @todo: Menu addresses to be added in purchase module?! -->
163
130 <!-- Views for Partners Form View -->164 <!-- Views for Partners Form View -->
131165
132 <record model="ir.ui.view" id="view_partner_form_inherit">166 <record model="ir.ui.view" id="view_partner_form_inherit">
@@ -135,17 +169,15 @@
135 <field name="inherit_id" ref="base.view_partner_form"/>169 <field name="inherit_id" ref="base.view_partner_form"/>
136 <field name="type">form</field>170 <field name="type">form</field>
137 <field name="arch" type="xml">171 <field name="arch" type="xml">
138 <separator string="Postal Address" position="after">172 <field name="address" position="replace" >
139 <field name="location_id" on_change="onchange_location_id(location_id)" domain="[('partner_id', '=', parent.id)]"/>173 <field colspan="4" mode="tree,form" name="address" nolabel="1" select="1" height="260" context="{'tree_view_ref' : 'base_contact.view_partner_address_tree_partner', 'default_partner_id': active_id, 'default_type': 'contact'}">
140 </separator>174 </field>
141 <xpath expr="//field[@string='Contact Name']" position="replace">175 </field>
142 <field name="contact_id"/>
143 </xpath>
144 <field name="title" position="replace"/>
145 </field>176 </field>
146 </record>177 </record>
147178
148 <!-- Views for Addresses -->179
180 <!-- Views for Location -->
149181
150 <record model="ir.ui.view" id="view_partner_location_form">182 <record model="ir.ui.view" id="view_partner_location_form">
151 <field name="name">res.partner.location.form</field>183 <field name="name">res.partner.location.form</field>
@@ -153,12 +185,20 @@
153 <field name="type">form</field>185 <field name="type">form</field>
154 <field name="arch" type="xml">186 <field name="arch" type="xml">
155 <form string="Locations">187 <form string="Locations">
188 <field name="partner_id" readonly="1" />
156 <field name="street" colspan="4"/>189 <field name="street" colspan="4"/>
157 <field name="street2" colspan="4"/>190 <field name="street2" colspan="4"/>
158 <field name="zip"/>191 <field name="zip"/>
159 <field name="city"/>192 <field name="city"/>
160 <field name="country_id" />193 <field name="country_id" />
161 <field name="state_id"/>194 <field name="state_id"/>
195 <newline />
196 <separator string="Contacts" colspan="4" />
197 <field name="job_ids" nolabel="1" colspan="4" readonly="1" mode="tree">
198 <tree>
199 <field name = "contact_id" />
200 </tree>
201 </field>
162 </form>202 </form>
163 </field>203 </field>
164 </record>204 </record>
@@ -170,6 +210,9 @@
170 <field name="type">tree</field>210 <field name="type">tree</field>
171 <field name="arch" type="xml">211 <field name="arch" type="xml">
172 <tree string="Locations">212 <tree string="Locations">
213 <field name="partner_id" string="Partner" />
214 <field name="contact_id" />
215 <field name="street" />
173 <field name="city"/>216 <field name="city"/>
174 <field name="country_id" />217 <field name="country_id" />
175 <field name="state_id"/>218 <field name="state_id"/>
@@ -177,19 +220,67 @@
177 </field>220 </field>
178 </record>221 </record>
179222
223 <record model="ir.ui.view" id="view_partner_location_search">
224 <field name="name">res.partner.location.search</field>
225 <field name="model">res.partner.location</field>
226 <field name="type">search</field>
227 <field name="arch" type="xml">
228 <search string="Partner Location">
229 <field name="partner_id" string="Partner"/>
230 <field name="street" />
231 </search>
232 </field>
233 </record>
234
235
236 <record model="ir.actions.act_window" id="action_partner_location_form">
237 <field name="name">Locations</field>
238 <field name="res_model">res.partner.location</field>
239 <field name="view_type">form</field>
240 <field name="view_mode">tree,form</field>
241 <field name="view_id" ref="view_partner_location_tree"/>
242 <field name="search_view_id" ref="view_partner_location_search"/>
243 </record>
244 <!-- sequence=30 is because 11 is not enough for beeing below addresses to be checked further -->
245 <menuitem name="Locations" id="menu_partner_location_form" action="action_partner_location_form" parent = "base.menu_address_book" sequence="30"/>
246 <menuitem name="Locations" id="menu_purchase_partner_location_form" action="action_partner_location_form" parent = "base.menu_procurement_management_supplier" sequence="30"/>
247
248
249 <!-- Update default address view -->
250
180 <record model="ir.ui.view" id="view_partner_address_form_inherited0">251 <record model="ir.ui.view" id="view_partner_address_form_inherited0">
181 <field name='name'>res.partner.address.form.inherited0</field>252 <field name='name'>res.partner.address.form.inherited0</field>
182 <field name='model'>res.partner.address</field>253 <field name='model'>res.partner.address</field>
183 <field name="inherit_id" ref="base.view_partner_address_form1"/>254 <field name="inherit_id" ref="base.view_partner_address_form1"/>
184 <field name='type'>form</field>255 <field name='type'>form</field>
185 <field name='arch' type='xml'>256 <field name='arch' type='xml'>
257
258 <field name="partner_id" position="replace">
259 <field name="partner_id" colspan="2" attrs="{'required':[('contact_id','=', False)]}"/>
260 </field>
261
186 <field name="name" position="replace">262 <field name="name" position="replace">
187 <field name="contact_id"/>263 <field name="contact_id" on_change="onchange_contact_id(contact_id)" attrs="{'required':[('partner_id','=', False)]}"/>
188 </field>264 <!-- <field name="name" string="use this field for initial name only" /> would require adaption of create-->
265 </field>
266
267 <field name="type" position="replace">
268 <field name="type" required="1"/>
269 </field>
270
189 <separator string="Postal Address" position="after">271 <separator string="Postal Address" position="after">
190 <field name="location_id" on_change="onchange_location_id(location_id)"/>272 <field name="location_id" required="1" on_change="onchange_location_id(location_id)" domain="[('partner_id', '=', partner_id)]"/>
191 </separator>273 </separator>
192 <field name="title" position="replace"/>274 <field name="title" position="replace"/>
275 <field name="function" position="after">
276 <separator string="Status" colspan="6"/>
277 <field name="state" />
278 <field name="date_start" />
279 <field name="date_stop" />
280 <separator string="Sequence" colspan="6" col="4"/>
281 <field name="sequence_contact" string="Contact Seq."/>
282 <field name="sequence_partner" string="Partner Seq."/>
283 </field>
193 </field>284 </field>
194 </record>285 </record>
195286
196287
=== modified file 'base_contact/security/ir.model.access.csv'
--- base_contact/security/ir.model.access.csv 2012-01-31 13:36:57 +0000
+++ base_contact/security/ir.model.access.csv 2012-04-18 04:27:19 +0000
@@ -1,7 +1,8 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_res_partner_contact","res.partner.contact","model_res_partner_contact","base.group_partner_manager",1,1,1,12"access_res_partner_contact","res.partner.contact","model_res_partner_contact","base.group_partner_manager",1,1,1,1
3"access_res_partner_contact_all","res.partner.contact all","model_res_partner_contact","base.group_user",1,0,0,03"access_res_partner_contact_all","res.partner.contact all","model_res_partner_contact","base.group_user",1,0,0,0
4"access_res_partner_location","res.partner.location","model_res_partner_location","base.group_user",1,0,0,04"access_res_partner_location_manager","res.partner.location","model_res_partner_location","base.group_partner_manager",1,1,1,1
5"access_res_partner_location_all","res.partner.location","model_res_partner_location","base.group_user",1,0,0,0
5"access_res_partner_location_sale_salesman","res.partner.location","model_res_partner_location","base.group_sale_salesman",1,1,1,06"access_res_partner_location_sale_salesman","res.partner.location","model_res_partner_location","base.group_sale_salesman",1,1,1,0
6"access_res_partner_address_sale_salesman","res.partner.address.user","base.model_res_partner_address","base.group_sale_salesman",1,1,1,07"access_res_partner_address_sale_salesman","res.partner.address.user","base.model_res_partner_address","base.group_sale_salesman",1,1,1,0
7"access_group_sale_salesman","res.partner.contact.sale.salesman","model_res_partner_contact","base.group_sale_salesman",1,1,1,08"access_group_sale_salesman","res.partner.contact.sale.salesman","model_res_partner_contact","base.group_sale_salesman",1,1,1,0