Code review comment for lp:~openerp-dev/openobject-addons/7.0-fix-contact-company-handling

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

On 2013-04-16, Nhomar wrote:
> 2 Main points here:
> 1.- The view on create a contact is broken.

Thanks for the tests and feedback!
In your video you mention 2 issues regarding contact creation. They're not bugs but they certainly deserve an explanation:

A) The fact that 'use parent address' and 'address type' fields are hidden after installing Sales

This is the expected behavior, although I agree it needs to be improved in the future. The idea is: both the "use company address" flag and the "address type" are advanced features that are not needed by all users, and are meant to be hidden by default. The "contact/address type" only makes sense in combination with multiple partner fields on Sales Orders. The "use company address" makes the address fields readonly on contacts so it is more complicated to edit addresses, and only useful when users require strict synchronization of the addresses.

In 7.0 these features are currently enabled by checking the "Allow a different address for delivery and invoicing" option in the Sales Settings (under Quotations and Sales Orders / Customer Features), which also makes the extra partner fields visible on Sales Orders. For various reasons these features are in `base` but the option to hide/show them is in the sale (actually sale_stock) module, and it was chosen to keep them visible until `sale` is installed.

So just enable this settings and you will see what you expect when editing contacts.

B) The fact that when you create the first contact for a company, the address is copied to the company.

This is done on purpose but only when the company has *no other contact* and *no address* yet. No copy will happen later or in other cases. The goal is to be able to create a new Customer with a parent Company on-the-fly while creating a Sales Order in B2B mode. When you use the "Create and Edit..." option in the Customer field of the Sales Order you are likely to type the name of the contact's company without taking the time to fill in the whole company details, and then you'll enter the company address in the contact's details. This is OK but in most cases the address you type is also a valid address for the company, you just don't take the time to fill in all details.
So in this case (new contact with address created for a new company without address) we do 2 things:
  - set "is_company" on the company record (via context defaults)
  - copy the address fields from contact to company
because that's very likely to be what the user meant.

This avoids having a new company without address and will also mean that new contacts created later for this company will receive the same address via on_change, easing the task of filling in details (remember that the "use company address" feature is advanced and not enabled by default)

> 2.- One improve in term of the meaning of the is_company == True field by
> default and the Customer and Supplier menu.

Really we can't make the "is_company" field default to True because the meaning of "is_company" is meant to be strict: when checked it really means that this partner is a company, not an individual. For B2C the value must *not* be checked on customers, so we must not make it the default! Some localizations or legal reports may need to make a distinction between B2C customers and companies.
The only case where we set it by default is when you create a new company on-the-fly via the Company field (parent_id) on a Contact, because in that case we know it's correct.

I hope this answers your questions...

« Back to merge proposal