Commit Graph
33 Commits
Author SHA1 Message Date
Wolfgang Taferner 62770ae9b8 [FIX] stock: test should actually fail, but did not for months
Commit dc1681b1 did change the name of the inventory creation from
direct qty update, but test still tries to compare the product.name

closes odoo/odoo#25948
2018-07-24 14:17:38 +00:00
Nicolas Lempereur 07cdd24f30 [FIX] product: is_product_variant true if variant
In 11.0 7e724f96c5 is_product_variant has been introduced back (it was
removed in 10.0 b747b05fa). But related of _inherits are computed on the
related model so is_product_variant would always be false.

Without fix, added test fails with:

 AssertionError:
  Items in the first set but not the second: True, Items in the second
  set but not the first: False, Product variants are variants

fixes #26961
related to opw-1814973
closes #27163
2018-09-24 09:45:52 +00:00
Christophe Simonis e3658d6f56 [MERGE] forward port branch saas-15 up to d44cd77884 2018-06-12 16:31:54 +02:00
Martin Trigaux c5946d6c5e [IMP] product: add test
To make sure the changes made at #24905 are tested
2018-06-11 17:47:39 +02:00
Nicolas Martinelli 79bbd1dcb8 [FIX] product: name search not ilike
- Create a product named 'toto'
- Perform a call to `name_search`:
  `self.env['product.product'].name_search('pouet', [], 'not ilike')`

Product 'toto' doesn't show up in the result list.

The domain should take into account that `default_code` can be `False`.

Note: the bug also occurs if the product is called 'trululu'.

opw-1837957
2018-05-02 12:58:52 +02:00
Nicolas Martinelli d88c3706df [FIX] product: name search not ilike
- Create a product named 'toto'
- Perform a call to `name_search`:
  `self.env['product.product'].name_search('pouet', [], 'not ilike')`

Product 'toto' doesn't show up in the result list.

The domain should take into account that `default_code` can be `False`.

Note: the bug also occurs if the product is called 'trululu'.

opw-1837957
2018-04-26 15:07:01 +02:00
Nicolas Lempereur 60974227cf [FIX] product: create_variant forward-port 5c2380e
In 5c2380e9f an issue when modifying variants values was solved when an
attribute on the product variant had "create_variant" unset.

This commit forward-port what was lost of it in 11.0, that part was
probably lost because the code was previously changed when adapting to
python3.

Without the change, the added test failed creating a new variant keeping
the existing one. With this change, 'nocreate' value are ignored when
computing new variants to create.

opw-1815226
closes #23332
2018-02-27 12:06:49 +01:00
Christophe Simonis 72508cc241 [MERGE] forward port branch saas-16 up to 7792755946 2018-02-14 18:26:57 +01:00
Raphael Collet e9d944f960 [FIX] product: product with single value for a "nocreate" attribute
The use-case is: update a product template by setting an attribute with
create_variant=False and a single value.
2018-02-14 15:29:43 +01:00
Raphael Collet 90bfad0e34 [FIX] product: unshadow test 2018-02-14 15:29:43 +01:00
Christophe Simonis 2dbc1edef9 [MERGE] forward port branch saas-16 up to b503e79722 2018-02-05 13:42:10 +01:00
Christophe Simonis e5f2e6d390 [MERGE] forward port branch 9.0 up to b08185fc66 2018-02-05 11:30:42 +01:00
Nicolas Lempereur b08185fc66 [FIX] product: can't search attribute value
A name_search on attribute line would possibly ends up with a domain like:

 ['|', ('attribute_id', '=', 'm'), ('value_ids', '=', 'm'),
  ('attribute_id', '=', 'm')]

which would just search the attribute.

This is caused by calling the default name_search. This commit forgo
the default name_search when we are in this attribute line special case.

courtesy-of: @fmdl

opw-813505
closes #22619
closes #22760
2018-02-02 17:13:14 +01:00
Christophe Simonis dd43071638 [MERGE] forward port branch saas-16 up to 278e478d55 2017-06-27 14:19:31 +02:00
Goffin Simon 2bf5d1ab0c [FIX] mrp: Test recursive BOM
Test that detects a recursion in BOM when exploding.

opw:745453
2017-06-20 21:12:39 +02:00
Parth Patel 1afe6dc725 [IMP] Sale: remove sequence field on pricelist item
PURPOSE
=======

It's confusing as it's not used. We had a customer with two exact same rules; he complained to the
support today because Odoo decided to use the other rule. (he was confused because he thought
priorities were based on sequences as there is a sequence field that allow drag & drop)

Order is based on "applied_on, min_quantity desc, categ_id desc", not on sequences. (since v9
and it's better that way; but we forgot to remove the sequence field)

SPECIFICATION
=============

Remove field
2017-06-07 15:14:24 +02:00
mdi-odoo f771ed2ca2 [REF] product: migrate yml test cases to unit test cases. 2016-08-01 15:05:33 +02:00
Thibault Delavallée 77c9e76e82 [REF] product_pricelist, *: clean the price and rule computation methods
A new API is introduced for price computing using pricelists. It is simplier
to use in most use cases, which is computing the product price in a given
pricelist. Old methods return dictionnaries and tuples, which are rarely
used in the code.
2016-08-01 15:05:32 +02:00
Thibault Delavallée 0f0ca1c133 [REF] product_uom, *: clean quantity computation methods
product_uom._compute_quantity is an ensure one multi method taking a browse
record as second paramter. It replaces _compute_qty and _compute_qty_obj
to have a single and standard computation method.
2016-08-01 15:05:32 +02:00
Thibault Delavallée f3d6a54e36 [REF] product_uom, *: clean price computation method
product_uom._compute_price() is now an ensure_one multi methods, taking
a browse record as second unit. This helps simplifying and unifying the
various calls and price computation methods.
2016-08-01 15:05:32 +02:00
Thibault Delavallée 429cd5970e [REF] product, *: clean price computation methods
Old price_get method is now replaced by price_compute and ready for migration.
Explicit parameters for unit of measure and currency have been added to ease
code understanding.
2016-08-01 15:05:32 +02:00
Thibault Delavallée f8fc7edeb7 [ADD][TESTS] product: add some product variant tests 2016-08-01 12:17:23 +02:00
Thibault Delavallée 53fe7e9fa6 [TESTS] mrp and various: updating tests 2016-07-04 16:22:37 +02:00
Thibault Delavallée bdd2080d04 [TESTS] stocl: Some new tests and yml to py
Including

 - unit tests for test/inventory.yml
 - unit tests for test/move.yml
 - unit tests for test/shipment.yml
 - integration of test_reuspply.py
 - integration of test_owner_available into test_product.py

New tests are temporarily deactivated. Indeed they rely on onchange methods
that will change during migration. Tests will be reactivated after migration
and updated.
2016-04-29 12:18:29 +02:00
Yannick Tivisse e03943a8df [IMP] Remove and clean product demo data
Remaining products :
- product_product_0 becomes service_order_01
- product_product_1b becomes service_cost_01
- product_product_43 becomes product_order_01
- product_product_47 becomes product_delivery_01
- prodcut_product becomes product_delivery_02
- Replace product_product_56 by service_delivery
- Replace product_product_59 by consu_delivery_01
- Replace product_product_58 by consu_delivery_02
- Replace product_product_57 by consu_delivery_03

Removed products :
- product_product_53, product_product_57, product_product_55, product_product_54, product_product_52,
  product_product_51, product_product_50, product_product_48, product_product_46, product_product_32,
  product_product_33, product_product_28, product_product_38, product_product_39, product_product_40,
  product_product_41, product_product_34, product_product_29, product_product_30, product_product_44,
  product_product_31, product_product_35, product_product_36, product_product_37, product_product_42,
  product_product_45, product_product_49, product_product_26, product_product_14, product_product_15,
  product_product_18, product_product_19, product_product_21, product_product_23

Removed corresponding binaries.

Removed all Bill of Materials demo data, that were ridiculous and replace them by 2 bom: A complete
computer, and a kit computer. Rewritten the tests accordingly.

Fixed tests :
- sale_mrp/test/cancellation_propagated.yml : The yaml ref function return a id, not a dictionnary
- sale_stock/tests/test_sale_stock.py : The service product invoiced on the delivered quantity was
  in fact not invoiced on delivery on the test. As we are in sale_stock, Without timesheet, we
  manually set the delivered qty for the product serv_del. If we don't do this, the invoice will
  never be fully invoiced.
- The pricelist rules choice is not based on the sequence anymore (Seems to be a bug, reported to
  online). By the way, I changed the product to avoid the overlap.
- sale_mrp/test/sale_mrp.yml: The yaml ref function return a id, not a dictionnary
- mrp : Rewritten the tests to be coherent with the new bom data
2016-01-07 16:07:28 +01:00
qdp-odoo e4dc50bf58 [IMP] pricelists improvements. Was PR #8228 2015-08-31 16:57:32 +02:00
Nicolas Martinelli d152106b1b [IMP] product*: adaptation due to the new Sale module
Major changes:
- No use of UoS anymore
- Partial migration to new api

Reason: complete rewrite of the Sale module.

Responsible: fp, dbo, nim
2015-08-27 18:10:19 +02:00
Xavier Morel 65cd4a2a33 [FIX] remove deprecated checks/fast_suite test attributes from standard modules 2015-01-15 14:31:40 +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
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
Martin Trigaux 8abd003ef0 [FIX] product: reference in test 2014-10-27 11:41:23 +01:00
Martin Trigaux 79ebe1060d [FIX] product: pricelist, uom and price_surcharge
The price_surcharge attribute must be computed based on the reference unit of measure (divided by the factor).
This is to make sure than 12 units and 1 dozen have the same price after pricelist computation (opw 599727).

Added test checking the correctness of pricelist computation based on unit of measures.
2014-10-24 17:21:42 +02:00
Martin Trigaux 378dbbfaae [IMP] product: add python tests
bzr revid: mat@openerp.com-20140306133456-cnqjcwmo73ioqxxf
2014-03-06 14:34:56 +01:00