One can infer related=True on a non-stored related field if all fields on the
path are related. This cannot be done if the related field is stored: when you
create a record, the database row is created first, and the related field is
computed and stored afterwards. Making the field required in that case would
trigger a non-null constraint violation.
This is a memory optimization: it reduces the memory footprint of each
registry. We have observed a reduction of 10Mb on a database with modules crm,
sale, purchase, stock.
Remove the hardcoded precision of 12 on factor and factor_inv,
to use the complete natural precision of NUMERIC types,
preserving all significant digits.
e.g. a UoM with a factor_inv of 6.0 used to be computed as:
factor_inv: 6.0 -> factor: 0.166666666667 (1.0/6.0, rounded to 12 digits) -> factor_inv: 5.999999999988 (1.0/factor)
which could lead to errors such 12*0.166666666667 = 2.000000000004 instead of 2.0
Slightly changed the way the ORM handles float fields to allow setting `digits=0`
as a way to explicitly require a NUMERIC value but without enforcing/rounding
the values at the ORM level, i.e. a truly full-precision field.
NUMERIC type has unlimited precision but is less efficient so should not be
used as the default behaviour, which is why we keep float8 as an alternative.
Modified the view to display the product UOM factor with a 5 digits value by default.
This value is for usability purpose only, the field still accepts bigger precision, by
setting the `digits` option on the field in the form view.
This change is safe in a stable series, the `digits=0` alternative is
treated the same as the default `digits=None` everywhere in the framework,
except when creating the database field.
Add rounding_method parameter on float_round method to offer
HALF-UP (default, usual round) or UP (ceiling) rounding method.
Use the second method instead of math.ceil() for product
reservations.
For UP, the python math.ceil() method uses "torwards infinity"
rounding method while we want "away from zero".
Therefore we use the absolute value of normalized_value to make
sure than -1.8 is rounded to -2.0 and not -1.
Fixes#1125#2793
This is a cherry-pick of d4972ff which was reverted at 333852e due
to remaining issue with negative values.
Save the NumberedCanvas state before doing a page reset.
The order of execution when rendering an rml report is the following:
1. init canevas (_pageNumber = 1)
2. render the page element
3. if still pages to render, afterPage method
4. if still pages to render, showPage method (_pageNumber += 1)
5. back to step 2 for each page
6. draw the ResetPage element (setting flag _doPageReset=True)
7. end the document build with afterPage & showPage method
The PageReset element should be executed at the end of the rendering of a story (subdocument) to reinitialize the page numbers to 0 (for new story) and insert the pageCount element for that story with the total number of pages (needed if want to use tag <pageCount/> in rml).
In case of NumberedCanvas (e.g. used in Trial Balance report), the numbering is generated at the end of the build using the _saved_page_states dict in the canevas.
To have an accurate _saved_page_states content, it needs to be saved before the pageReset.
Fixes#2225
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).
The setup of relational fields may be problematic, as they may refer to unknown
models via custom relational fields. In a partial setup, do not try to skip
the field setup, but let it go and silently catch any exception if it crashes.
In the case of custom fields, the field's parameters were set up without the
field being present in the class hierarchy. Because of this, the parameter
inheritance mechanism was missing the field itself. As a consequence, custom
selection fields ended up without selection, for instance :-/
The ISO week-year notation can produce confusing values
when the first week of the year is so short that it
becomes week 0 and is considered the last week of the
previous year, depending on the locale.
For instance, using ISO notation:
'W53 2015' == dates.format_date(
date(2015,1,1), format="'W'w YYYY", locale='en_GB')
'W53 2005' == dates.format_date(
date(2006,1,1), format="'W'w YYYY", locale='de_DE')
This is surprising but actually valid.
However it definitely yields wrong output when combined with
months formats:
'January 2014' == dates.format_date(
date(2015,1,1), format="MMMM YYYY", locale='en_GB')
As a result we must always use `y` to denote the year in
any date format, *except* when it is combined with the
week number `w`, in which case we must use `Y`.
See the documentation at:
http://babel.pocoo.org/docs/dates/#date-fields
Compute methods could give results that should not be considered as default
values. For instance, a related field usually defaults to a null value, which
is then set to the field with its inverse method by create(). This may violate
a non-null constraint if the original field is required. Therefore, compute
methods are no longer used to determine default values.
The method _prefetch_field() was accidentally prefetching fields to recompute;
which was skipping the actual recomputation, since a value was put in cache.
But sometimes the field's value was fixed by an extra recomputation of the
field. Here we remove the extra recomputation and fix the cache corruption.
Rev f2cf6ced1 modified RFC2822 parsing in order to better support
unicode characters inside the Name part of an address header.
However the patch broke handling of multiple addresses (comma
separated) - silently discarding all recipients except the
first one, as soon as any non-ASCII character was present.
This patch restores the functionality while preserving the
fix from f2cf6ced1, and simplifies the code using email.utils
utility functions.
Fixes (again) lp:1272610, OPW 607683
An issue occurs when a constraint is checked before computed fields are marked
for recomputation: the constraint will read the field's current value, which
may be wrong. If the field is marked soon enough, the constraint will trigger
the recomputation and use a correct value.
Because of the parameter overriding mechanism implemented by fields, it is no
longer necessary to copy field objects. It is even better to no copy them in
the case of related fields.
If an email contains several text/html parts inside a multipart email, the previous code was only keeping the last content part.
The Content-Type: multipart/mixed allows several independent part (RFC1341 7.2.2), so two html is technically valid.
With this patch, the two parts are concatenated. (opw 614755)
Modify append_content_to_html regex to make sure the regex keeps the content of the html instead of removing it.
e.g.: "123 <html> 456 </html> 789" used to be stripped to "123 789" while we expect "123 456 789"
This solves a subtle issue: in the following case, the class Bar should
override the default value set by Foo. But in practice it was not working,
because _defaults is looked up before field.default.
class Foo(models.Model):
_name = 'foo'
_columns = {
'foo': fields.char('Foo'),
}
_defaults = {
'foo': "Foo",
}
class Bar(models.Model):
_inherit = 'foo'
foo = fields.Char(default="Bar")
The change makes field.default and the model's _defaults consistent with each
other.
also fix the corresponding text and add explicit sequence number because I
don't understand what the bloody hell it does without that, except that it's
not the right thing. At all.
Consider the following example:
class Foo(models.Model):
_name = 'foo'
_columns = {
'state': fields.selection([('a', 'A')]),
}
class Bar(models.Model):
_inherit = 'foo'
state = fields.Selection(selection_add=[('b', 'B')])
The attribute 'column' of the field does not have the full selection list,
therefore the column object cannot not be reused, even a copy of it. The
solution is to systematically recreate the column from the field's final
specification, except for function fields that have no sensible way for being
recreated.
* fix mapping handling to match JS impl: current value set as _value instead
of being lost
* add handling of integer parameter
* only set _size and _last if current iterable is sized
Changed render_att_att to return an iterable of pairs instead of a pair, and
dispatched t-att on whether its result is a Mapping.
Also changed qweb test runner so it uses ordereddict for JSON mapping in
params, otherwise iteration order (and thus order of attributes in output) is
unpredictable and results don't/can't match expectations (as both are
strings).
Note that this relies on JS implementation details wrt iteration order of
mappings. Tests would probably be somewhat less brittle if rendering output
was parsed to XML... if that's possible (?)
* document qweb based (mostly) on JS version
* convert JS qweb tests to (mostly) language-independent XML so they can be
used for JS and Python implementations
* add some more tests (e.g. precedence between t-value and body in t-set)
* remove ``t-import``
* fix parity in foreach(dict) (and rename some variables to make array and
object versions more similar)
When processing data files during a module installation/upgrade, not all fields
are set up yet, in particular relational custom fields. Make fields_get()
ignore those fields, so that views can be created/updated and validated,
provided they do not refer to those fields...
A security has been introduce in eb9113c04d to restrict access to orphan attachments to employees only
Assets need to be build and accessed as superuser, thus
This reverts commit d4972ffdb6.
Seems to break some cases, at least in _product_reserve from stock/stock.py
Actual use case:
SELECT product_uom, sum(product_qty) AS product_qty FROM stock_move WHERE location_dest_id=%s AND location_id<>%s AND product_id=3645 AND state='done' GROUP BY product_uom;
returning 1 | 6
SELECT product_uom,-sum(product_qty) AS product_qty FROM stock_move WHERE location_id=%s AND location_dest_id<>%s AND product_id=%s AND state in ('done', 'assigned') GROUP BY product_uom;
returning 1 | -6
results += cr.dictfetchall()
total = 0.0
results2 = 0.0
for r in results:
amount = uom_obj._compute_qty(cr, uid, r['product_uom'], r['product_qty'], context.get('uom', False))
results2 += amount
total += amount
Total = 1, amount = -5
It should actually be
Total = 0, amount = -6
The Edit button never appeared anymore for these users.
The idea was that they should see an edit button with
limited editing capabilities depending on their other
access rights.
For example, someone with only Sales Manager access and
'Display Editor Bar on Website'
would be able to edit online quotes from the website_quote
module, but not change the actual website pages or menus,
for instance.
Replace the query "SELECT min(id) FROM xxx" by "SELECT 1 FROM xxx LIMIT 1".
Both requests are as efficient, and the second one does not crash if column
'id' is missing.
Modified product ceiling() to use float_round() with special mode
for rounding UP (away from zero), avoiding pathological cases where
float representations errors were ceiling to the superior unit.
Also added correspding tests for rounding_method=UP
Fixes issue #1125, and replaces PR #1126.
When a users connects, a lock is taken on the res_user table to modify the last login date. If another running transaction uses a foreign key to res.users (e.g. write_uid column), postgres may detect the update as a concurrent update and rollback the transaction.
In pg 9.3, the lock_strength parameter 'NO KEY' allows a weaker lock which is less likely to break another transaction.
Fixes#552