Commit Graph

699 Commits

Author SHA1 Message Date
Harald Welte faa3ff46e2 HACK: extend product.product name_search() for x_sysmo_barcode
This should be properly done in an extension, but was easier to add to
the core product.product code right now :/
2017-11-30 08:32:31 +01:00
Alexis de Lattre 4203360528 [FIX] product: correct forwardport
Introduced at f772303 during forward port
2016-12-20 13:24:16 +01:00
Jeremy Kersten 78f00700e3 [FIX] product: keep precision in historized cost field.
Now we use the same decimal precision for cost in table 'Historization cost'
and 'product'.

It is one fix, but that will not fix the case where decimal precision has been
updated between 2 historizations.

This commit closes #12861
2016-07-26 10:07:20 +02:00
Goffin Simon d7f1270050 [FIX] product: default name in copy on product.product
When duplicating a variant, it's not necessary to append (copy) to
the name of the variant as it changes the name of the template too.

opw:683522
2016-07-19 15:48:49 +02:00
Stefan Rijnhart 606eab8ef8
[FIX] product: make copy friendlier to overrides
Do not force to use "<name> (copy)" when duplicating

Closes #12397
2016-06-15 12:07:14 +02:00
Nicolas Lempereur 48a35ca8f9 [IMP] product: order attribute by name
closes #11951
fixes #11602
opw-673857
2016-05-06 16:38:47 +02:00
Christophe Matthieu 231e026936 [FIX] product: write active value on all product variants from product template
Issue: When writing active on many products, only change the active value for the last product variants
2016-01-07 17:12:07 +01:00
Alexis de Lattre a4e48d4c28 [FIX] product, purchase: pricelist of PO issued from procurements
When a purchase order is created through a procurement order,
the purchase order pricelist is taken from
the partner `property_product_pricelist_purchase`,
which is a property, which therefore can be different
according to the company. This is therefore
important to force the company to the procurement company
when browsing the partner, to get the correct pricelist,
from the right company. Otherwise, it take the pricelist
from the `SUPERUSER` company (when running the schedulers/cron),
which can be different than the procurement company.

The same as to be applied when browsing the product,
as the `standard_price` field (Cost Price) is a property
as well, and can be different according to the company,
in order to get the correct price unit on the purchase
order line, from the correct company.

Fixes #5329
Closes #5330
2016-01-04 11:35:23 +01:00
Denis Ledoux eb5d95b135 [FIX] product: _get_image_variant is used for the field `image`
This revision is related to 93d4db9d1e.

Usually, for models with an image, the original `image` is stored
in the field `image`, and then the resized value are in the fields
`image_medium` & `image_small`.

In the specific case of the product variant, this is not the case,
the original image is stored in the field `image_variant`,
and the `image` field uses as well the method `_get_image_variant`.

The `image_get_resized_images` must therefore return the "big image"
as well, which is returned with the key `image`, by default.
This is done using the method argument `return_big`.
2015-11-30 13:51:25 +01:00
Denis Ledoux 93d4db9d1e [FIX] product: resized variant images
This is possible to set an image for a specific variant
When this was the case, the image displayed was always the
image within its original size, it wasn't resized
to small and medium sizes.

opw-657055
2015-11-30 13:06:16 +01:00
Goffin Simon 856b31719c [FIX] product: _check_valid_attribute
To check if the values set for the attribute are valid.

opw:653945
2015-11-16 13:50:19 +01:00
bramsi 979d23ad8c [FIX] mrp: name_search where args is not defined
In case of name_search with no args (default None, see #8492 for example of
valid scenario, during import)
Construct the domain correcty.

Fixes #8492
2015-10-07 12:50:32 +02:00
Stefan Rijnhart 0333e4da02 [FIX] product: default category on UoM quick creation
This revision adds the possibility to use the key
`default_category_id` in the context to set
the UoM category when quick creating a new UoM,
like it's the case everywhere else with the
`default_*` keys passed in the context.

Closes #4407
2015-09-29 16:24:22 +02:00
Goffin Simon 4b6309f5de [FIX] product: name_search result
The function "name_search" defined on "product.template" made a search on
"product.product" name to give the "product.template" which matched with the
search. The number of results given by the name_search on "product.product" is
generally limited to 8. The problem was when for example there were 8 variants ("product.product")
with a name begining by "AA" for the same "product.template" T1 and another "product.product"
with a name begining by "AB" linked to T2. In this situation, if a name_search was made on "product.template" with a name="A",
the result got was just the the name of T1 linked to the 8 variants instead of the name of the
two templates (T1 and T2) due to the limitation.

opw:647066
2015-08-26 14:33:20 +02:00
Temur Vibliani 99b7a6e7a1 [FIX] product: fake error log from product.template
Disabled fake error log from product.template.create_variant_ids() function.

Closes #7182
2015-06-30 14:07:30 +02:00
Xavier Morel 443c38dbc0 [IMP] product: fnct_inv of image variant
Doesn't seem to have much effect, but it's probably still better to not
have 3 UPDATE run every time we create a new product.product.
2015-06-25 10:39:31 +02:00
Raphael Collet dca1894b5d [IMP] product: optimize `name_get()` of `product.category`
Using the new API takes better advantage of the cache than calling `read()`.
In the list of products, `name_get()` now generates 2 queries instead of 144!
2015-06-17 10:48:29 +02:00
Josse Colpaert cf6d7479d5 [IMP] Stock valuation: Avoid consumables with real-time valuation
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.
2015-05-12 09:53:20 +02:00
Denis Ledoux 23ffff7a6f [FIX] product: recursive category name search
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
2015-04-13 17:30:16 +02:00
Denis Ledoux 83e8c54637 [FIX] product: import product.template fields using default_code
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
2015-04-03 11:06:49 +02:00
Olivier Dony d8c4e4fa76 [FIX] product: unused import as of 489a96c257 2015-03-18 14:10:18 +01:00
Olivier Dony 489a96c257 [FIX] product.template: name_search order + mismatch on IDs
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".
2015-03-18 11:40:51 +01:00
Anton Chepurov 47ca07ba19 [FIX] product: sort attributes before checking existing variants
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
2015-03-03 15:40:19 +01:00
Olivier Dony 05bbe78d87 [FIX] product.product: name_search() must preserve natural order
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`.
2015-02-26 14:03:05 +01:00
Olivier Dony bf31ab6718 [FIX] product.template: name_search compatibility with product.product
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
2015-02-26 14:03:05 +01:00
Christophe Matthieu 8518a963e0 [FIX] product: if the product has no attribute and you add one without any value, the product is deleted. 2015-02-16 13:22:50 +01:00
moylop260 88ab3db5f2 [FIX] product: missing default init before using it as dict
This revision bring back the possibility to use the copy method
of product.product without passing parameters

Closes #5236
2015-02-13 15:03:13 +01:00
Denis Ledoux 0c1d73b1be [FIX] sale: missing context in browse call.
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.
2015-02-02 16:10:27 +01:00
Denis Ledoux cc2a406b4f [FIX] product: uom category name 2015-01-27 11:37:30 +01:00
Commandant Custo a2a3cffa29 [IMP] product: Improved tooltip for standard_price
Closes #4561
2015-01-08 15:09:55 +01:00
Martin Trigaux 25c3348a1f [FIX] product: avoid name_get with empty ()
Products with a seller name but no attributes (only one variant) got their name
in the format 'seller name ()'
Fixes #4523
2015-01-06 18:24:13 +01:00
Denis Ledoux 1ff4d0c9a1 [FIX] product: variants prices (extra price) digits precision
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
2014-12-19 11:53:51 +01:00
Olivier Dony da12f2b809 [FIX] product: pricelist: multiple corrections in UoM-related conversions
Pricelist computations need to consider 2 different Units
of Measure:
 - The default product UoM (product.uom_id), used as reference
   for the various quantities and amounts specified in each
   pricelist rules.
 - The `context UoM` is the UoM in which the result is requested,
   that is the list price UoM.

For example the 'price_min_margin' amount is meant for the unit
price of 1 x default UoM. When the context UoM is not the default
product UoM, it can be any UoM of the same UoM Category, and the
various quantities and amounts specified on the rule need to
be adapted accordingly:
  - min_quantity (expressed in terms of the default UoM)
  - price_surcharge (specified for 1 x default UoM)
  - price_min_margin (specified for 1 x default UoM)
  - price_max_margin (specified for 1 x default UoM)

The UoM corrections were not done consistently and resulted in
wrong prices when computing the price using a non-default UoM.
The cases were a conversion was needed or not were not properly
identified within the _price_rule_get_multi().

After this commit, the various code branches in _price_rule_get_multi
always ensures that:
 - price requested for: `qty` of `qty_uom_id`
 - `qty_in_product_uom` is the requested `qty` converted to default UoM
 - current (intermediary) price: `price` for  `price_uom_id`

Therefore `price` and `price_uom_id` are always in sync, and `price_uom_id`
can always be compared with `qty_uom_id' in order to know whether
a conversion is still needed.

This patch also corrects and extends the regression tests
introduced at revision 79ebe10.
2014-12-09 17:30:47 +01:00
Christophe Simonis 5ca7fa18fc [MERGE] forward port of branch 8.0 up to 31a01ea 2014-12-03 19:24:57 +01:00
Christophe Simonis 2ed212dcbf [MERGE] forward port of branch 7.0 up to d6daf5f 2014-12-03 17:51:06 +01:00
Cedric Snauwaert d6daf5fa2f [FIX] product: add store=dict to field name_template
Recompute the name_template field if the template changes.

backport of 41628fc + f25c5d8 to 7.0 plus some optimisations in triggers
Fixes #3277
2014-12-03 16:39:14 +01:00
Josse Colpaert c255fe3384 [IMP] Add a method half-up for uom conversion in case we want to convert from default UoM to something else + remaining_qty round + default factor on UoM 2014-12-02 15:51:58 +01:00
Josse Colpaert 910376a157 [IMP] Rounding of the UoM should have an unlimited precision 2014-12-02 15:51:58 +01:00
Christophe Simonis d37dd37059 [MERGE] forward port of branch saas-3 up to e1e7dc0 2014-12-01 15:42:51 +01:00
Christophe Simonis ec30b21336 [MERGE] forward port of branch 7.0 up to de07c64 2014-11-28 15:16:38 +01:00
Olivier Dony fc85a7ee5c [FIX] product: remove unnecessary UoM rounding step, add missing test
Remove the intermediate rounding inside _compute_qty(), as it
is not necessary after rev. fa2f7b86 and has undesired side-effects.

An extra float_round() operation inside _compute_qty()
had been added at rev. 311c77bb to avoid a float representation
error in UoM factors that could bias the ceiling() operation
done as the last conversion step.

Example 1:
Dozen has a factor of 1/12, which was previously stored in the
database with a decimal accuracy of 12 significant decimal digits.
This meant the factor was exactly stored as 0.08333333333333.
When reading this back into a Python float, the precision was not
sufficient, and the UoM conversion of 1 Dozen to Units gave a
result of 12.00000000000047961...
After the final ceiling() operation to Unit's rounding, the
converted value ended up as 13.

This problem was initially solved using an extra rounding.

However at revision fa2f7b86 the decimal precision used to store
UoM factors was increased to preserve all significant digits.
This added the extra precision necessary to read the Dozen factor
back into an accurate float value of 1/12, and the conversion of
1 Dozen now gives 12.0 Units, even without the intermediate
rounding operation. (Works for other factor values too)

At the same time that extra rounding operation has undesired
side-effects, as it requires a fixed precision derived from
the rounding precisions of the UoMs. But there is no given precision
that would work in all cases for this intermediate value. It is
always possible to find a valid combination of UoM roundings
that breaks that intermediate step, e.g. by forcing integer
roundings.

Example 2:
Let Grams have a rounding precision set to 1 because no smaller
quantities are allowed, and Kilograms a rounding of 0.001 to allow
representing 1 Gram. (gram factor = 1000 and kilogram rounding = .001
by default)
If we try to convert 1234 Grams into Kilograms, the extra rounding
introduced in 311c77bb will cause a rounding of 1234.0/1000.0 at
the precision of Grams (1), which gives 1.0 as a result.
The net result of this conversion gives 1234.0 Gram = 1.0 Kilogram,
while the correct result (1.234 Kilogram) is perfectly compatible
with the UoM settings.

Similar errors could be triggered with various rounding settings, as
long as the intermediate rounding needs a finite precision.

Two extra tests have been added to cover Example 1 and Example 2.

--
Related to #2072, #1125, #1126, #2672
Closes #2495, #2498
2014-11-27 16:44:34 +01:00
Olivier Dony 9bc712b075 [REV] product: rev. 42f5114 needs further review
Incorrect use of stock.move in product module + needs review.

This reverts commit 42f511405a4efe88e3903a4b4040ec9d83e462e2:
"[IMP] When no stock moves, change whatever you want, otherwise no change at all for UoM.  #3440 Enhancement request richard-willowit"
2014-11-26 18:20:28 +01:00
Josse Colpaert 42f511405a [IMP] When no stock moves, change whatever you want, otherwise no change at all for UoM. #3440 Enhancement request richard-willowit
The default UoM can only be changed when there are no stock moves (or only cancelled ones), but to any category.
The purchase UoM can be changed whenever you want, but has to be in the same category as the default UoM.

Closes #3440

[IMP] When no stock moves, change whatever you want, otherwise no change at all for UoM.  #3440 Enhancement request richard-willowit

[FIX] Remove line

[FIX] Constraint should be applied when UoM or PO UoM is changed
2014-11-26 18:01:00 +01:00
Christophe Matthieu d3c562d4e8 [FIX] product: keep attribute on a variant with only one attribute
When adding informational attribute, with only one possible value, it used to be skipped.
Instead keep it and add it on every variant.

To avoid dropping and recreating product (and lose eventual customisations), the attributes with only one possible value are set on every product.
This makes sure that in following test, these are not considered in variants_inactive variable.

Fixes #3204
2014-11-26 14:35:08 +01:00
Denis Ledoux 02f4f9a572 [MERGE] forward port of branch 7.0 up to e2dd18f 2014-11-26 12:35:36 +01:00
Martin Trigaux 7dca12ee08 [FIX] product: comparison of currency rounding
Setting 0.0001 as precision used to be converted to 9.999999999999999e-05
precision_digits of 6 is the precision of the field 'rounding' on res.currency
Fixes #3875
2014-11-25 18:41:00 +01:00
Martin Trigaux 4ce7af3573 [FIX] product: creation of reference uom
Set a default value for factor when creating a new uom.
Could not create a new UoM with type reference (if creates a reference uom, no need to pass a factor).

Change the readonly filter to (type = bigger) to make the field writable for reference uom.
This is needed to force the reset of the factor when switching of type (onchange_type).
As the field was readonly, kept the old value for factor.
2014-11-24 11:04:50 +01:00
Denis Ledoux d9e48bae42 [MERGE] forward port of branch saas-3 up to 7ab4137 2014-11-14 16:58:24 +01:00
Denis Ledoux 7ab413724a [MERGE] forward port of branch 7.0 up to da15c9d 2014-11-14 15:59:33 +01:00
Denis Ledoux 5b2f13abdf [FIX] product: more accurate name_search
First, name_search searches on default_code, then, if the limit is not reached, it searches on the product name
The results found from the default code search must be removed from the search domain when doing the search on the product name, to avoid having results already found by the search on the default_code

opw-618015
2014-11-14 13:42:52 +01:00