Commit Graph
26 Commits
Author SHA1 Message Date
Nasreddin Boulif (bon) 866c90926b [FIX] base_address_extended: split 'correctly' street name
Issue

	- Install "Contacts" & 'base_address_extended' modules
	- Go to contacts and create a contact with value:
	  - street name : Chaussee de Namur
	  - House : 40
	- Save and edit again
	- Set country to 'Netherlands' then save.

	Address not splited well (wrong values for street name and house).
	The issue is not present in UI but is in tests.
	(Issue in UI from odoo 14.0+)

Cause

	There is 2 '_split_street_with_params'
	(inverse function that set street fields):
	- partner_autocomplete_address_extended (removed in 14.0)
	- base_address_extended

	The 'spliting' logic is not the same in both function.

	In UI, looks like it does not call '_split_street_with_params'
	from 'base_address_extended' since no super(Partner, self)...

	However in testing, it does call it from module
	'base_address_extended' and therefore trigger the issue.

Solution

	Adapt _split_street_with_params function
	(in 'base_address_extended' module):
	If previous field (from 'street_format') to parse
	in 'street_raw' is 'street_name', then:
	- set `tmp` to: splitted (max 1 split) street_raw
	  with current field seperator
	- set `append_previous, sep, tmp[0]` to:
	  splitted tmp[0] (first part of splited street_raw) with `rpartition(' ')`
	- add 'append_previous' to 'street_name' value
	- join 'tmp' values and set it to street
	  (should equal to what left from `rpartition(' ')` split
	  + seconf part of first normal split)
	- continue normal parsing flow

opw-2476096

closes odoo/odoo#70886

X-original-commit: 74116c982a5ddef65a05ef90017ac4ce63bdf58f
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2021-05-17 14:28:24 +00:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
Thibault Delavallée 69081a244a [REF] base_address_extended: rename compute / inverse methods
Purpose is to make code follow guidelines so that we understand that
some methods are used for computed stored inverse fields.

Task ID 2158302
PR odoo/odoo#42678
2020-01-07 14:53:42 +00:00
Thibault Delavallée d160997c95 [MOV] base_address_extended: reorganize python code
Purpose is to reorganize code according to guidelines and split the main
badly named python file, to understand that 3 models are impacted: res.company,
res.country and res.partner.

Task ID 2158302
PR odoo/odoo#42678
2020-01-07 14:53:28 +00:00
Thibault Delavallée 7943b71af3 [FIX] base(_address_extended): correctly update company street information at write
Currently when writing on street field of company model, its sub-fields
(notably street_name, street_number and street_number2) are not correctly
computed again in cache.

Indeed address sub fields have no direct trigger as it depends on its
partner_id and its partner_id children (see ``res_partner.address_get()`` and
``res_company._compute_address()``).

When writing on address fields from the company record, we then invalidate
all address fields cache in order to force their computation.

This commit adds a new tool method giving the list of fields coming from the
address partner to copy upon the company.

Task ID 2158302
PR #42678
2020-01-07 14:45:48 +00:00
Thibault DelavalléeandAurélien Warnon 8a1010ba48 [REV] base(_address_extended): revert 44221cffac
This commit reverts commit 44221cffac called "[FIX] base_address_extended:
Fix cache miss bug" .

Indeed it fixes the cache miss bug but introduces another one which completely
breaks address encoding.

How to reproduce
  * create a company with address bits (street_name, street_number,
    street_number2);
  * update one of those fields, e.g. street_number2;
  * other fields are emptied once saved, e.g. street_name and street_number are
    False;
  * both company and its partner records are now incorrect;

This is probably due to the unique inverse method introduced by the reverted
patch that sends only the updated value to the inverse method, leading to
other values being reset.

Original task ID 2068145
PR odoo/odoo#42701

X-original-commit: 3f4862ee8c9193719abd8e6dd647e6584f232103
Co-authored-by: Thibault Delavallée <tde@odoo.com>
Co-authored-by: Aurélien Warnon <awa@odoo.com>
2020-01-03 17:29:10 +00:00
Jigar Vaghela 44221cffac [FIX] base_address_extended: Fix cache miss bug
Before this commit:
-The company have 3 street fields have separate inverse method this all method is update same partner fields
-Partner also has same 3 street fields but have the same inverse method for all street fields
-Now the problem is when user company street inverse call then partner inverse also call at that time partner inverse try to access other street fields that not available in a cache so an error occurred.

After this commit:
-Company 3 street fields have the same inverse method so no cache problem when accessing all street fields in partner inverse method

task-2068145
Closes #36568

Signed-off-by: Josse Colpaert <jco@openerp.com>
2019-09-09 13:41:00 +00:00
Raphael Collet 9920f20e4c [IMP] models: ORM speedup
This branch is the combination of several optimizations in the ORM:

* store field values once in the cache: the cache reflects more
faithfully the database, only fields that explicitly depend on the
context have an extra indirection in the cache;

* delay recomputations by default: use method `recompute` to explicitly
flush out pending recomputations;

* delay updates in method `write`: updates are stored in a data
structure that can be flushed efficiently to the database with method
`flush` (which also flush out recomputations);

* make method `modified` take advantage of inverse fields to inverse
dependencies;

* filter records by evaluating a domain on records in Python;

* a computed field with `readonly=False` behaves like a normal field
with an onchange method;

* computed fields are computed in superuser mode by default.

Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien
Pinckaers.

closes odoo/odoo#35659

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-08-20 12:43:59 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Nicolas Lempereur 04a8194284 [FIX] base{,_address_extended}: extended fields in address format
In 6c2b54ff there was an optimization that removed extended addresses
fields syncing on parent_id, or concerning field update or creation.

But the list of fields was also used partly for formatting address which
had been supporting extended addresses fields and now does not.

With this changeset, we have the extended fields back but only for
formatting in a new "_formatting_address_fields".

opw-1984608
closes #33144

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-05-03 14:10:42 +00:00
Xavier Morel 6c2b54ff9c [IMP] base_address_partner: optimise transfer betwen parent and child
Mostly a concern during bulk import of partners with parents.

First remove syncing extended fields, that seems completely
unnecessary since the street gets sync'd and will get split through the
normal process (updating the sub-fields), by also syncing the split
fields we're redundantly calling _set_steet and rewriting the address
we just sync'd.

Second if write()ing both the country and street, the override would
then go and re-write the street based on what had *just* been split
into sub-street fields, which could waste a lot of time during the
import post-process as address fields get moved back and forth between
parents and children leading to *lots* of writing both country and
address together, we're talking:

 ncalls  tottime  percall  cumtime  percall filename:lineno(function)
10002/2    0.111    0.000  344.390  172.195 res_partner.py:181(write)
[...]
      2    0.455    0.228  165.264   82.632 base_address_extended.py:41(_set_street)

My initial instinct was to just add the country_id to _set_street and
remove the write override but it would break
88ff6beb01: if the country alone is
updated on a partner, we do want to re-format the "unified" address
based on individual fields and the new country's format.

Note: it might be that the logic would be more sensible by inversing
the entire thing, such that the split fields are the proper
source (regular stored fields) and street is converted to a computed
field instead, but that'd be a larger model change. Seems like it'd
make more sense though, at least given what the modules attempts to
do (OTOH the module probably fails
https://www.mjt.me.uk/posts/falsehoods-programmers-believe-about-addresses/
in just about all the ways).
2019-04-02 09:57:49 +00:00
Christophe Simonis babfca1cf4 [MERGE] forward port branch 11.0 up to 5a1f874602 2018-09-11 14:57:25 +02:00
Goffin Simon 5a1f874602 [FIX] base_address_extended: contact address is not updated
When the module "base_address_extended" was installed, the contact addresses
of a company were not updated when the company address was updated.

opw:1879968
2018-09-11 11:30:44 +02:00
Christophe Simonis 3c521f6d05 [MERGE] forward port branch 11.0 up to c51488c2f4 2018-07-24 16:43:26 +02:00
Goffin Simon ca14f232e0 [FIX] base_vat_autocomplete: Create contact using VAT number
Let's install base_vat_autocomplete and  base_address_extended
When creating a contact with a VAT number, the street was not
formated by the autocomplete in a correct way because the function checkVat all the time
returns the street with the following format: '%(street_name)s, %(street_number)s/%(street_number2)s'
and this function doesn't take the street format of the country into account.

So the function _split_street tried to split the street into street_name, street_number, street_number2 with the
street_format of the partner but the street was  not well formated by checkVat.

opw:1867491
2018-07-24 09:54:29 +02:00
Christophe Simonis 4e76173a43 [MERGE] forward port branch 11.0 up to 219d2296d6 2018-07-23 16:03:25 +02:00
Goffin Simon 88ff6beb01 [FIX] base_address_extended: Changing country on a partner
Steps to reproduce the bug:

1. Create a Vendor with these address settings

- Name: Vendor123
- Streer" Street:
- Housnumber: 123

>> DO NOT ADD A COUNTRY => by default street_format = street_number street_number2 street_name

2. Create a purchase order for Vendor123
3. print the RFQ

>> ADDRESS FORMAT "123 Street" => OK

4. Go to vendor123 and set "Netherlands" as a country
5. Print RFQ again

Bug:

>> The address was still in format "123 Street"  => NOT OK

When changing the country on a partner, the field street must be recomputed
because the street_format depends on the country.

opw:1865677
2018-07-23 09:27:05 +02:00
Raphael Collet 6f30f0af9c [FIX] models: behavior with multiple inverse/compute mixed on same fields 2018-01-23 16:41:45 +01:00
Martin Trigaux 98580ed730 [IMP] base_address_extended: more room for numbers
The space available for the house and room number is specified by the label size

House Number<field>Door Number<field>
takes max one column of size (about 147px) so makes the field very small for input

Rename the labels to make it smaller

Fixes #21927
2018-01-09 15:16:11 +01:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Moises Lopez - https://www.vauxoo.com/ ce44ad2440 [FIX] base_address_extended: default to Null instead of empty string
for computed street fields.

Qweb reports delete the node if the value is Null but won't if the value is an empty string. And then, l10n_mx_edi module has errors because there are nodes with empty string and the minimum value is one char.

Courtesy of Vauxoo. Was PR #17169
2017-05-29 09:31:53 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Moisés López c132d4b33d [IMP] base_address_extended: Add new partner fields to company model
This module adds some extra fields to the partner model, in order to be able
to manage extended addresses. However, those extra fields were not present
into the company model, thus making partner's addresses and company's
addresses displaying somewhat inconsistent.

This change takes those fields that were already present into the partner
model, and adds corresponding fields into the company model and view, so
addresses from both models are now shown the same way.

Closes #16547
2017-04-24 11:44:35 +02:00
qdp-odoo 9553970b40 [IMP] base_address_extended: improve inheritancy.
In case we extend this module by adding new field, the reset of street by an empty value will now reset all fields defined in street_fields.
2017-01-04 10:36:30 +01:00
qdp-odoo 0dc4e13f14 [ADD] base_address_extended: add module to take care of multiple fields inside the 'street' fields defined in base 2016-12-28 11:26:06 +01:00