This is related to revision 73432ffe9f.
The inherited view adding
the purchase pricelist field on the partner form
no longer worked for user being in the purchase pricelist group
but not in the sale pricelist group, since the field was added
after the sale pricelist field, which was no longer in the view
for these users.
This revision partially revert the above revision, but
add the purchase pricelist group in the groups of the view,
so the view is loaded only if the user is part of one group
or the other.
opw-639685
If the whole view relates to a specific group,
apply the group on the view itself instead of
each view part (each fields, each page, each div,...),
so the view is loaded / added to the base view
only if the user is in the right group.
So the view is not loaded uselessly
and the fields are not read for nothing
(performances & security).
Indeed, when a group is applied on a field itself, the field content
is read, but hidden, therefore reading the content of the field
uselessly, and potentially leading to accesses issues
if the user hasn't the rights to read the field.
(e.g. reading a property when not having access to the model
of the proprty, pricelists on partners for instance)
opw-634402
When the product is a consumable, avoid to use real-time valuation, by adapting
the onchange in the views and making the valuation field invisible when the
product is a consumable / service.
Double list comprehension is a nice try but does not work in python.
prod_ids was a list containing only the first variant, so getting the
product-specific pricelists only for the first variant of the first template.
Fixes#2900
If a product as only one variant, using the product.product or the
product.template in the pricelist configuration should have the same effect.
This is particulary important for the ecommerce where template without variants
do not show the product. Having a pricelist for that product had no effect on
the price used in the e-commerce.
Fixes#2900, opw 615153
Before this rev.,
if you had two child categories with the same name, e.g.:
- Chocolates / Orange
- Fruits / Orange
In the product list, searching for category "Fruits / Orange"
also returned the products from category "Chocolates / Orange",
because it fetched all products which had "Orange" in the category.
This rev. corrects this (in the above example, it returns
only products from category "Fruits / Orange".
The code is particularly complex. A proper solution would be
to store the complete name field (but this cannot be done in
stable releases, such as 8.0).
Besides, it handles the fact a product category child can have
' / ' directly in its name (it's not only the category tree separator).
e.g., you could have a category name called 'Fruits / Orange' directly
not only in the complete name.
opw-628793
This rev. is related to 489a96c257
It wasn't possible anymore to perform an import of
a product.template field in a model
(e.g. mrp.bom), while it should be the case.
In the context of an import,
the operator of the name_search is '='.
Therefore, in this super call, the operator was '='
and the name was '' (empty).
In such a case, ('name', '=', '') is added
to the search domain by the base name_search method
(in models.py),
leading to the domain
[('id', 'in', template_ids), ('name', '=', '')]
which will lead to no results.
Forcing 'ilike' as domain is correct, as the actual
name_search, with the correct operator,
has already been performed in the lines above, the
point of this second name_search is to get
the right order along with the right name_get.
opw-632089
In the form view of a unit of measure,
if the unit of measure was of type
"Bigger than the reference unit"
The help in the tooltip of the ratio field was wrong
Besides, this help message was contradictory
with the formula written just below the field.
opw-631672
Improve commit bf31ab6718a8b9c8afdd29120e5056533b0a2ade:
- do not use the product.product name_search() when there is no
search term (it's only useful with a search term
- do not use the product.product name_search() when the extra
domain (args) has a criterion on IDs - these will be *template*
ids, not *variant* ids, so the results would be wrong
- Since templates and variants use a different natural `_order`,
perform an extra name_search() on templates after gathering the
ids to return, to apply the proper sort ordering. Increases the
penalty by doing 2 name_search() calls.
This issue could be seen e.g. in the breadcrumbs where the
display_name variable is displayed for templates, and indirectly
relies on name_search() due to an old hack in call_kw in order to
implement the "future_display_name".
When generating the list of all needed variants, the attributes are sorted based
on the order in field attribute_line_ids while, when comparing with existing
variants, the order of the attributes on the product.product is the order
on the field attribute_value_ids. As both order could be different (no direct
relation), variants could be wrongly recreated instead of keeping existing one.
Make sure the attribute lists are always sorted.
Fixes#4361
The natural order was discarded when merging results with a set,
and this was actually un-necessary as the second search()
excludes the previously found `ids`.
In the rare places with a m2o field to product.template
(e.g BoMs), it is necessary to be able to search on product
codes, EAN, etc, the way it works on product.product.
This is done by delegating the name_search to product.product
and then returning the corresponding templates.
This has a small penalty of executing name_get() twice,
but is simpler and more robust for future changes.
An alternative would have been to extract the name_search()
method into a mixin and mix it on both product.product and
product.template. However this would be more brittle and
only work as long as the name_search implementation strictly
uses fields that are present in both tables.
OPW 626662
The precision 'Product Unit of Measure' was defined after the declaration of kg.
Since fc85a7ee, the precision of kg is set in data to 0.001.
As the Product Unit of Measure was not defined yet, the rounding was stripped to
(16,2) precision, so getting a rounding of 0.0 for the kg unit of measure.
[FIX] product: the declaration of decimal precision was done after
the declaration of uom precision, preventing uom precision from going above
the default decimal precision. + made the Kg unit precise up to grams by default.
Not passing the context should be exceptional, in almost all cases you should pass it.
In this specific case, not passing it will, for instance,
prevent the use of the key 'active_test' in the context,
and there is therefore no way to count all variants, including disabled ones.
For companies not working with variants,
it is important to be able to search in the
Products menu (product.template) using
product codes.
It is useful as well to see the codes
in the default kanban view too, even if
it is only the code of the first variant.
Takes care of resetting it from older versions
e.g. rev d97e7a6a4e
and c0076916f3, as
the old `variants` field that was used does not
exist anymore, crashing at opening.
When adding an extra price for a variant (through the button variant prices in the product template form) with a digits precision greater than 2 (4 for instance), the computed public price did not keep the digits precision of the extra price
Granting read-only access to Sales/Accounting Users is useless
as all employees already have it - removed. On the other hand
Sales Managers need write access to it in order to create
products, and they need it even when `sale` is not installed,
e.g. with `account` only.
Moved this access right to `product` module. The Sales
Manager group is defined in `base`, so that works.