Commit Graph

254 Commits

Author SHA1 Message Date
Julien Legros b00122ad99 [FIX] res_partner: add parent_name related field
In some cases (e.g. with record rules), the name_get might not have access
to the parent name. Therefore a parent_name related field solves the
issue (as it read with as superuser).
2014-10-20 15:50:49 +02:00
Denis Ledoux 4a27880974 [FIX] res_partner: commercial partner sync
On child partner creation of a parent partner, the commercial_partner_id is not computed (and stored) in the create method.
Therefore, we should compute the commercial_partner_id before trying to sync his data
2014-08-04 14:34:08 +02:00
Martin Trigaux bf353998f2 [FIX] res_partner: backport of rev 37bf72a
Correctly take the 'use parent address' into account in the onchange. Slightly updated the view that was weird with this parameter. opw 609344
2014-07-03 12:30:48 +02:00
Jacques-Etienne Baudoux df40926d2a [IMP] res_partner: more fault tolerant name_create
In case of invalid format such as 'name email@server' (missing chevrons), the parsing would be failing due to a strict behaviour of getaddresses (returns nameemail@server).
With the patch this format is accepted.
opw 607312
2014-06-27 16:48:40 +02:00
Christophe Simonis 53d8055cd8 [FIX] res.partner: name_search: respect unaccent flag
bzr revid: chs@openerp.com-20140404141611-qi1yagltvkd9q8ji
2014-04-04 16:16:11 +02:00
Olivier Dony 27be515eab [FIX] res.partner: missing index on `parent_id` column
bzr revid: odo@openerp.com-20140403143717-dy2bszaevsyivryo
2014-04-03 16:37:17 +02:00
Martin Trigaux e6ee1947f8 [FIX] better test, add missing parentheses in query, return empty list in case of no idea (instead of triggering super)
bzr revid: mat@openerp.com-20140129123404-8hs786n64briqyta
2014-01-29 13:34:04 +01:00
Martin Trigaux f71a381b81 [ref] move up!
bzr revid: mat@openerp.com-20140129114102-tk4fotnb28mtaz9x
2014-01-29 12:41:02 +01:00
Martin Trigaux 5d38e40e6b [FIX] revert previous rev for better where and add test
bzr revid: mat@openerp.com-20140129113938-517gqfi1kzcf64fz
2014-01-29 12:39:38 +01:00
Martin Trigaux 7dedf4ec45 [IMP] remove useless variable, where_clause at least '' as created from a str.join()
bzr revid: mat@openerp.com-20140129111959-7y9su01ooneu0mco
2014-01-29 12:19:59 +01:00
Martin Trigaux 05ec12692f [FIX] res_partner: name_search search in one pass
The original query did two passes (SQL query and orm search). This was a problem due to the limit parameter where the second query could reduce the number of results to a smaller number than the asked limit.

This code reproduces the orm _search behaviour to execute only one SQL query mixing both the ACL clauses and the complexe name_search without degrading the performances (removing the limit in the first query would have).

lp bug: https://launchpad.net/bugs/1203727 fixed

bzr revid: mat@openerp.com-20140129105548-dd6zmy9uc2cuowpq
2014-01-29 11:55:48 +01:00
Martin Trigaux 744c48819d [MERGE] res.users: synchronise partner's company with the one of the user
bzr revid: mat@openerp.com-20130909135835-ifvra8l05soptwwt
2013-09-09 15:58:35 +02:00
Olivier Dony 95b7d5bcaf [FIX] res.partner: current name_search() implementation tends to skip a few valid results during early autocompletion - mitigation attempt
The main reason for the semi-random behavior
observed during auto-completion is the
missing ORDER BY clause in the pre-filtering
SQL query.

The ORDER BY clause is expensive but inevitable
if we want to apply a correct LIMIT, otherwise
we would return random `limit` results among
all the possible matches.

The current SQL query seems convoluted due
to the duplicated CASE clause but it
performs slightly better than the equivalent
CTE-based (WITH...) query, so it was preferred.


There is still a chance of returning too
few results due to double limit application,
as further discussed in bug 1203727

lp bug: https://launchpad.net/bugs/1203727 fixed

bzr revid: odo@openerp.com-20130905170251-x47w1zrm43d0k9wb
2013-09-05 19:02:51 +02:00
Holger Brunn 89851d6108 [IMP] improve readability
bzr revid: hbrunn@therp.nl-20130808181806-mdsrcltl8r526sr6
2013-08-08 20:18:06 +02:00
Holger Brunn 9af99b6000 [FIX] only descend to children when necessary
lp bug: https://launchpad.net/bugs/1210186 fixed

bzr revid: hbrunn@therp.nl-20130808161339-7y5dtwacb1ed7fcp
2013-08-08 18:13:39 +02:00
Rifakat 3ba9415e80 [IMP] removed unused user pool
bzr revid: rha@tinyerp.com-20130801063502-g2u9l8ave9sd7kim
2013-08-01 12:05:02 +05:30
Rifakat acd76079ba [FIX] fix demo data problem, now able to assign company to existing partner which does not have
any company. Did small variable name change

bzr revid: rha@tinyerp.com-20130801062706-imbu9ac2nimbd28f
2013-08-01 11:57:06 +05:30
Olivier Dony 8722e2a01e [FIX] res.partner: name_search() should match complete contact names in the format returned by name_get()
This was missed during the change of the name_get()
format at revision 4923.1.12
revid:odo@openerp.com-20130416093121-t5soophs2aui8rzq

lp bug: https://launchpad.net/bugs/1188300 fixed

bzr revid: odo@openerp.com-20130612095300-pcr3ly5g7bv656i1
2013-06-12 11:53:00 +02:00
Jigar Amin (OpenERP) 7dafd9d58e [IMP] res.partner must only allow to set the company_id of a partner if it is the same as the company of all users that inherit from this partner
bzr revid: jam@tinyerp.com-20130611055803-or29rx40278bqttt
2013-06-11 11:28:03 +05:30
Jigar Amin (OpenERP) d334814bf5 [merge] lp:openobject-server/7.0
bzr revid: jam@tinyerp.com-20130611051458-r4bg46apl7j6kfrf
2013-06-11 10:44:58 +05:30
Christophe Matthieu de9777bf56 [IMP] Improve typos in warning (Grammar mistake, Capitalize title, Typos)
bzr revid: chm@openerp.com-20130607090251-2ym7dx73jdigq93w
2013-06-07 11:02:51 +02:00
Cedric Snauwaert 3892a9fee4 [REF]res_partner: compact code to get tz info
bzr revid: csn@openerp.com-20130515101027-4nc06nr2u41jh1wr
2013-05-15 12:10:27 +02:00
Cedric Snauwaert 1e03e6df78 [FIX]res_partner: change fields selection of tz so that timezone starting with Etc/ are at the end of the selection, that way it's less confusing for the users.
bzr revid: csn@openerp.com-20130514113100-h2oihowcplaba10j
2013-05-14 13:31:00 +02:00
Jigar Amin (OpenERP) 6d4215c9bf - Allow setting the company_id of the partner to False in order to make the partner shared between all companies.
bzr revid: jam@tinyerp.com-20130513060734-niodo4rzs0m1v073
2013-05-13 11:37:34 +05:30
Olivier Dony 20020a7647 [FIX] res.partner: typo would prevent contact from using company address correctly if flag changed without changing/setting company + updated tests to cover this
bzr revid: odo@openerp.com-20130425171238-dhgpqbi9nio12vxk
2013-04-25 19:12:38 +02:00
Olivier Dony 0ee404c054 [FIX] res.partner: always call write() with a list of IDs, a single ID is not valid! (even if it works sometimes)
bzr revid: odo@openerp.com-20130424131625-aeljtyo5yuiyrlcz
2013-04-24 15:16:25 +02:00
Olivier Dony 9b9c3fa59c [FIX] res.partner.name_get: partners marked as "is_company" should appear as standalone
This is more consistent with the way we expect reporting
to work, and will also ensure that these companies
appear right above their contacts in search order
(which will match name_get)

bzr revid: odo@openerp.com-20130419164728-25312wtyzt9h6egw
2013-04-19 18:47:28 +02:00
Olivier Dony 83feb1c46f [REVERT] res.partner: undo change of ordering in name_search result, to be addressed via a stored display_name field (temporarily added by account_report_company module in 7.0)
bzr revid: odo@openerp.com-20130419164447-wrmfghxi44au3273
2013-04-19 18:44:47 +02:00
Olivier Dony cfb53f1aad [FIX] res.partner: search using 'child_of' should include inactive children
This is necessary for 2 reasons:
- when searching on Business documents the search domain will be
  [('partner_id', 'child_of', 'ACME')] in order to match all
  descendants, and it must match inactive children as well
- in other cases like for resolving IDs to update via store
  triggers, it is necessary that 'child_of' returns inactive
  children too.

The implementation is tricky because the ORM automatically 
transform 'child_of' domains into recursive searches with
[('parent_id', 'in', ids)], which is the same query that the
reverse one2many 'child_ids' will also use to find contacts.
The overridden search() therefore matches this domain pattern
only when there is one criterion (to avoid side-effects in
other cases) and a dummy extra 'domain' was added to the
definition of the 'child_ids' o2m so it won't match.
The net result is that child_ids will not return inactive
children while child_of will return all descendants when
it is the only criterion. This is the expected behavior
whenever child_of is used on res.partner, because
it's safer to always show business documents.
The only side-effects will be for custom/manual search
calls with a single criterion of the form ('parent_id','in', x)
and those can be fixed by adding an extra domain
component ('active','=',True), just like child_ids does.

bzr revid: odo@openerp.com-20130419135756-2kbhwr23lygqdoob
2013-04-19 15:57:56 +02:00
Olivier Dony 3c5559045c [FIX] res.partner: add onchange warning when changing an existing contact's company
bzr revid: odo@openerp.com-20130418153829-rmkd6xo1cajgfer5
2013-04-18 17:38:29 +02:00
Olivier Dony dfbe68e69d [IMP] res.partner: rename commercial_id to commercial_partner_id + make function field inheritable
The name `commercial_partner_id` better reflects its
purpose and the fact that it is a FK to a partner.


An extra indirection through a lambda function was
also added to the definition of the function field
to make it possible to override it in other modules
(otherwise the function is passed by copy directly
and cannot be inherited later)

bzr revid: odo@openerp.com-20130418144533-owupfwn6h83q432x
2013-04-18 16:45:33 +02:00
Olivier Dony d734bf58cc [FIX] res.partner: name_get: return "Company, Contact" rather than "Contact (Company)" to make it clearer that the company is selected as well
bzr revid: odo@openerp.com-20130416093121-t5soophs2aui8rzq
2013-04-16 11:31:21 +02:00
Olivier Dony f985391ba0 [MERGE] Sync with 7.0
bzr revid: odo@openerp.com-20130415181836-cmq936wu0w7alwky
2013-04-15 20:18:36 +02:00
Olivier Dony 8efd16f25a [FIX] res.partner, orm._check_recursion: prevent recursive partner structures + fix false positives in check_recursion()
- res.partner must prevent creating loops in partner
hierarchies, and this can be done easily with an
extra _constraint using the ORM's builtin _check_recursion

- _check_recursion's implementation incorrectly
assumed that the provided 'ids' were unrelated
(not part of a common hierarchy).

- add tests for _check_recursion via extra
tests on res.partner structure
(explains why both patches are in the same
commit)

bzr revid: odo@openerp.com-20130415171732-aj3j2e2mycvzf4kp
2013-04-15 19:17:32 +02:00
Olivier Dony c5e4faa7dc [FIX] res.partner: make the computed display_address use all address fields, including extra/custom ones
lp bug: https://launchpad.net/bugs/1122363 fixed

bzr revid: odo@openerp.com-20130411191110-5q7vd77m0e78dg8u
2013-04-11 21:11:10 +02:00
Olivier Dony e78ed60a5a [FIX] res.partner: make _address_fields method conform to its documented return type (detected by Nhomar Hernandez)
This will make overriddes more straightforward.

bzr revid: odo@openerp.com-20130411190050-8vhx9laialsyrm3r
2013-04-11 21:00:50 +02:00
Olivier Dony 8468af8606 [FIX] res.partner.name_search: make sure companies always come before contacts when both match
bzr revid: odo@openerp.com-20130410152309-u4dn8bxssvcwdc8c
2013-04-10 17:23:09 +02:00
Olivier Dony 9bec1595bd [FIX] res.partner address sync: `type` field should not be synced wih other address fields
It is valid to use the parent address but still set a different
type of address - the name, email, phone, etc. could be different.

bzr revid: odo@openerp.com-20130410123229-9l60sbcks3tpmy7x
2013-04-10 14:32:29 +02:00
Olivier Dony 9dbe29b2b5 [FIX] res.partner.address_get: default to partner being looked up rather than company when no match is found at all (and no "default" exists)
Using the commercial entity is not a very good default choice
in many cases. If a new contact is created on-the-fly for a
new document (e.g. sales order), his/her company may be an
empty shell and/or a large corporation that should not be
directly used for e.g. billing/invoicing purposed.
Once a contact/company is set to "invoicing" or "delivery"
we use it, but in other cases we stick to the provided
partner/contact as a saner default.
This should not change anything for cases where advanced
contact management is used and proper address types are
set.

bzr revid: odo@openerp.com-20130410121536-vm93o6vxhi3b8feu
2013-04-10 14:15:36 +02:00
Olivier Dony 2bf1034cd2 [FIX] res.partner: autosync of commercial fields and address fields + correct views accordingly + basic tests
* Commercial fields (bug 1160365)

Fix autosync of accounting/invoicing-related fields on contacts,
just as if they were actually modeled as fields.related to the
parent commercial entity.
This starts with the addition of the new functional field
`commercial_id`, to locate the commercial entity for any partner.
The commercial entity is defined as the first ancestor (starting
at the partner itself) that is either marked `is_company` or has
no parent. [This is Part A of the solution on bug 1160365].

Then, whenever a partner is created or modified:
- if it is a commercial entity, the commercial fields are synced
downstream to all its descendants, stopping at company boundaries.
- if is is not a commercial entity, the commercial fields are
synced from its parent commercial entity.
The list of fields to sync is determined by calling the new
res.partner method `_commercial_fields()` which can be easily
extended by any module that adds commercial fields on res.partner.
A utility method `open_commercial_entity()` was added to
res.partner to make it easy to include a button for editing the
parent commercial entity, to be displayed instead of now-hidden
commercial fields.
[This is part B of the solution on bug 1160365]

The res.partner.address_get() method (used to find child partners
of certain types, e.g. "invoice") was udpated to take the new
"commercial entity" notion into account: it will now look for
matches in children but also parents and siblings that are part
of the same "commercial entity". The default partner `type` is
now "contact" to reflect the new model ; "default" is
inappropriate because it is a wildcard and would stop the type
lookup early.
[This composes parts C and D of the solution on bug 1160365]

Note: This fix comes with a matching addons fix to implement
module-specific extensions of part B, as well as part E of the
solution.


* Address fields (bug 1160425)

Corrected autosync of address fields is also included in the
same branch, because those two mechanisms are closely related
and share some parts of the implementation.

The `use_parent_address` field now defaults to False (except
in the mini-kanban view of contacts on a partner form), and
the autosync of address fields has been modified to only work
downstream and never update a parent company if a child contact
is modified. Instead, the address fields are now displayed
readonly on contacts that use the parent address, with a button
to edit the parent address (new method open_parent(), similar
to open_commercial_entity() but opening the direct parent).

To make the initial creation of a contact + company pair,
a special case was added: when a new contact is created for
a company that has no other contact and no address, the
address of the contact is assumed to be that of the company
so it is moved to the company, then the `use_parent_address`
flag is enabled on the contact, and the `is_company` flag on
the company. This covers a use case where contact and
company are created on-the-fly when creating a new document.

Many logical flaws in the autosync of address fields have been
corrected and are now covered by unit tests.


* Misc related fixes

- checking `is_company` does not reset the parent_id field
anymore, to allow for multi-level structures. The field is
still hidden automatically because having an empty "Company"
field on the form view of a company is quite suprising), but
this UI behavior is easily customized;
- the `email`, `phone`, `fax`, `mobile`, `lang`, etc. that
were sometimes synced when changing parent company are now
properly left alone;
- the `use_parent_address` field is now always visible next
to the parent_id field when a parent is set

lp bug: https://launchpad.net/bugs/1160425 fixed
lp bug: https://launchpad.net/bugs/1160365 fixed

bzr revid: odo@openerp.com-20130408013742-tm8w0w0nmunanokk
2013-04-08 03:37:42 +02:00
Xavier ALT 43cc95ce2b [FIX] partner: fix update for company address
* when writing an empty value to ADDRESS_FIELDS, that value
    should also be propagated by update_address()

  * when creating a contact from a company form view, even with
    'use_company_address', company's contact address remains empty. We
    now force adding missing address fields uppon creation when default
    'use_company_address' is True.

bzr revid: xal@openerp.com-20130329112317-6lat4jx5x2yh18t6
2013-03-29 12:23:17 +01:00
Thibault Delavallée 910f7097ba [IMP] res_partner: use tools.email_split instead of custom regex when parsing partner_name to find an email.
bzr revid: tde@openerp.com-20130313105640-r53xueaz36zw3fjd
2013-03-13 11:56:40 +01:00
Niels Huylebroeck bc4e3d00ed [FIX] base: allow searching in multicompany environment on res_partner.
bzr revid: nh@agaplan.eu-20130225135753-ryf6y5e0nhxt8zux
2013-02-25 14:57:53 +01:00
niv-openerp 692cea3039 Removed default image on partners, use default one in the kanban view if false
bzr revid: nicolas.vanhoren@openerp.com-20121221120631-2uugaiexqanwbi00
2012-12-21 13:06:31 +01:00
Olivier Dony 0cd22d6d4b [IMP] res.partner: name_search nows searches email as well ; name_get now supports `show_email` context
+ various minor fixes to the way operators were
(mis)handled.

bzr revid: odo@openerp.com-20121220181604-61fxnjh35amdywwx
2012-12-20 19:16:04 +01:00
Cecile Tonglet ad8b76de53 [MERGE] From trunk (second time)
bzr revid: cto@openerp.com-20121217144753-1rboqdw01h8yrehj
2012-12-17 15:47:53 +01:00
Cecile Tonglet 5f0070dcb6 [FIX] Remove unused imports and fix some imports that doesn't use the new namespace
bzr revid: cto@openerp.com-20121217143029-e9ki4ftwihq7pdme
2012-12-17 15:30:29 +01:00
Cecile Tonglet 5179507e22 [MERGE] Branch updated with trunk
bzr revid: cto@openerp.com-20121217125902-idtlh4ztyah17bdn
2012-12-17 13:59:02 +01:00
Raphael Collet 3040114651 [MERGE] trunk-style-improvements-xmo (Python stylistic improvement)
bzr revid: rco@openerp.com-20121217110150-4ijt04ic17miktq7
2012-12-17 12:01:50 +01:00
Xavier Morel c6079dd6bb [REM] unnecessary parens
bzr revid: xmo@openerp.com-20121214123803-6xu2s1ndnoyj4i3e
2012-12-14 13:38:03 +01:00