Commit Graph

559 Commits

Author SHA1 Message Date
Christophe Simonis 24bcdb75fb [MERGE] forward port of branch 7.0 up to c2aff47 2015-09-22 15:30:22 +02:00
Valencia Rodrigues Sah c2aff4772e [FIX] product: default value on required field
The qty fields has become computed in 6.1, and the value set by the user is on
min_qty. Set default value as it is required.

Closes #8561
2015-09-17 17:45:20 +02: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
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
Denis Ledoux 02f4f9a572 [MERGE] forward port of branch 7.0 up to e2dd18f 2014-11-26 12:35:36 +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 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
Denis Ledoux 8c4a7cb371 [MERGE] forward port of branch 7.0 up to 5035c76 2014-11-04 12:19:58 +01:00
Denis Ledoux 5035c76f42 [FIX] product: product prices can be company dependent
Some prices, as standard_price, being a property, are company dependent. Therefore, when browsing as superuser, force_company is mandatory to get the property of the user company
2014-11-04 11:54:03 +01:00
Christophe Simonis 21b1203ee0 [MERGE] forward port of branch 7.0 up to 43db726 2014-10-29 19:05:43 +01:00
Mohammad Alhashash 43db7267c5 [FIX] stock: UoS quantity in stock.picking
Implements the UoS TODO items on stock.picking.do_partial() to fix #1432.
Add a new method _compute_uos_qty() on product.product to computes
product's invoicing quantity in UoS from quantity in UoM.

The created invoice will use the product_uos of the stock.move, meaning keeping
the quantity specified on the partial picking and the unit of measure of the
original stock.move (e.g. recieving 1 dozen from a 12 unit picking should either
get uos=dozen, uos_qty=1 or uos=unit, uos_qty=12, not a mix of both)

Fixes #1432, opw 611479
2014-10-29 10:10:50 +01:00
Denis Ledoux 0e4216361b [MERGE] forward port of branch 7.0 up to 3a0af6a 2014-10-22 19:26:27 +02:00
Cedric Snauwaert fa2f7b86bf [FIX] product: remove digits_precision from uom factor fields
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.
2014-10-22 14:28:34 +02:00
Denis Ledoux 77500e54ec [MERGE] forward port of branch 7.0 up to eb9113c 2014-10-02 15:34:02 +02:00
Martin Trigaux 78144410a4 [IMP] product: name_get matching on commercial_partner_id for suppliers
The name_get of a product will use some information (e.g. default_code) based on the supplier.
The matching of the supplier should use the commercial_partner_id in case the supplier info are on the company and the partner_id in the context belongs to the company (e.g. creates quotation with a contact of the company).
Fixes #1219
2014-10-02 10:59:18 +02:00
Denis Ledoux 3d4b82cd56 [MERGE] forward port of branch 7.0 up to 9cc54dc 2014-10-01 12:41:42 +02:00
Denis Ledoux 9cc54dcd2c [FIX] product: name_search handles negative operators 2014-10-01 12:39:59 +02:00
Denis Ledoux 76067367b2 [MERGE] forward port of branch 7.0 up to 5f6d324 2014-09-25 15:10:37 +02:00
Cedric Snauwaert 311c77bb88 [FIX] product: _compute_qty: first round before ceiling, to avoid pathological cases
Fixes problem when we try to sell 12 units of a product and change it to 1 dozen,
the algorithm was then trying to recompute the original amount and was getting
12,0000048 as a result which was then passed to the ceiling method, getting 13.0!

See also previous commit and issue #1125, PR #1126
2014-09-24 17:11:26 +02:00
Christophe Simonis 8f13e8320e [MERGE] forward port of branch 7.0 up to d0a0b7d 2014-08-20 17:45:05 +02:00
Thomas Groutars 397e83554b [FIX] product: make sure unlinked product still exists
When uninstalling/updating a module, we may execute unlink method on product.template before product.product. In such cases, the product is already removed after removeing the template (_inherits) and the chained unlink of the product would fail (traceback when browsing).
2014-08-18 10:37:03 +02:00
Martin Trigaux 8ea4f581ed Forward-port of latest 7.0, up to rev. 10046 (rev-id: launchpad_translations_on_behalf_of_openerp-20140514062049-vjclnuxlkbto0tsj) 2014-05-14 10:04:16 +02:00
Martin Trigaux 8f43b749f4 [FIX] product: when duplicating a product, keep the language in the context
At the time of the context_wo_lang patch (7.0 revision 6577), the orm did not keep the language in copy_data, this patch intended to be more consistent.
Since server revision 5146 7.0, the new behaviour is to use the translated version in copy_data. Removign this change will be more consistent with the orm.

The expected behaviour is now the following:
In user lang: translated product name + translated '(copy)'
In other lang: same as original product

lp bug: https://launchpad.net/bugs/1159913 fixed

bzr revid: mat@openerp.com-20140508134937-7cbja3vsv311z5j4
2014-05-08 15:49:37 +02:00
Denis Ledoux 2832d2ddc9 [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 10016 revid:dle@openerp.com-20140425125507-njfyl1r6wn11vqwx
bzr revid: dle@openerp.com-20140425125926-5nchz1tcq4fx18jx
2014-04-25 14:59:26 +02:00
Denis Ledoux 12eb157397 [FIX] product: price computation failed when for pricelists based on Cost price for non-employee users
bzr revid: dle@openerp.com-20140425125507-njfyl1r6wn11vqwx
2014-04-25 14:55:07 +02:00
Denis Ledoux d8d312768c [FIX] product: overwritten name_search of product.pricelist ignored lang translations. It worked prior to saas-3 because the pricelist filter in the searchview used a selection widget, which did not care about translations
bzr revid: dle@openerp.com-20140317120126-qx4wrkqfdu3nr3sp
2014-03-17 13:01:26 +01:00
Denis Ledoux 74af3ac0fe [MERGE] Forward-port of latest saas-2 bugfixes, up to rev. 9144 revid:dle@openerp.com-20140310133913-465x5t3n1bo7fu98
bzr revid: dle@openerp.com-20140310143600-kz7qjfe4p63s0a34
2014-03-10 15:36:00 +01:00
Denis Ledoux c2ba11e72e [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9885 revid:dle@openerp.com-20140310114026-r0ijm0m36su19wn7
bzr revid: dle@openerp.com-20140310122101-gicombyc5ii0yz6a
2014-03-10 13:21:01 +01:00
Martin Trigaux 1967b6ce19 [FIX] product: when converting unit of mesures, round above instead of mathematical rounding
bzr revid: mat@openerp.com-20140305171456-goo7on3ncfihu0wu
2014-03-05 18:14:56 +01:00
Denis Ledoux 70d3f251a3 [REVERT] rev 8788.1.1769: The exchange rate of the currency of the pricelist should not be applied as this price computation method does not depends of any pricelist
bzr revid: dle@openerp.com-20140226172300-z2okr3vpjuwxs4mz
2014-02-26 18:23:00 +01:00
Raphael Collet 17616e08ef [IMP] product: simplify further product_product.copy()
bzr revid: rco@openerp.com-20140127101957-1ywu40m081uo79nl
2014-01-27 11:19:57 +01:00
Raphael Collet 31d4a2cc6f [IMP] product: in product.name_search(), do no search on variants (too costly)
bzr revid: rco@openerp.com-20140127100037-t1hzbw0f4v8uys6f
2014-01-27 11:00:37 +01:00
Raphael Collet 3ce7ccd57e [IMP] product: Python fixes ('<>' -> '!=')
bzr revid: rco@openerp.com-20140127091856-1cvelz2tq16lfaml
2014-01-27 10:18:56 +01:00
Antony Lesuisse aa727b9a43 [FIX] product use osv _check_recursion helper
bzr revid: al@openerp.com-20140126210921-0dh2dghkcyymvron
2014-01-26 22:09:21 +01:00
Antony Lesuisse 232475e83a [FIX] product remove arbitrary size limits
bzr revid: al@openerp.com-20140126210506-3kjf53g9uxtvhn40
2014-01-26 22:05:06 +01:00
Christophe Simonis 2cf97c76d3 [IMP] product: correct copy() of products variants
bzr revid: chs@openerp.com-20140123183208-jg76zjt7tzd1fl75
2014-01-23 19:32:08 +01:00
Thibault Delavallée 86b9f997c8 [IMP] product: supplier_info: when renaming a field, please
use @oldname parameter.
Therefore added oldname on product_tmpl_id that was once known as product.id.

bzr revid: tde@openerp.com-20140123163243-ct1vde3luoypj5qx
2014-01-23 17:32:43 +01:00
Thibault Delavallée 46c55500ff [MERGE] Sync with website-al
bzr revid: tde@openerp.com-20140122171321-6r2q42p7ebfv3kb9
2014-01-22 18:13:21 +01:00
Thibault Delavallée 055932fc6a [IMP] product: cleaned form in create mode. Moreover generally
changing the template is not possible anymore; create a new tempalte or a new
variant instead. When creating a new product, you will always create a new
template.
Added the link to the template from the product form view.
Cleaned some code (code move).

bzr revid: tde@openerp.com-20140122170218-6j2sixoxvvbbxvhd
2014-01-22 18:02:18 +01:00
Thibault Delavallée d944a652dc [FIX] product: when computing lst_price, that is the public price
computed based on the template price + margin and extra, use the
pricelist currency if a pricelist has been given. This alows for
example to have 'promo' prices on the ecommerce that are in the
same currency.

bzr revid: tde@openerp.com-20140122120042-ovh2mi70q0beeqwq
2014-01-22 13:00:42 +01:00
Thibault Delavallée 38d64147d5 [IMP] product: only template child / multiple template childs form view improvements
- added a is_only_child field on product.product, telling whether the
product is the only child of the product.template
- improved the product form view, to set readonly all fields coming fgrom
the template when the product is not the only child. This way, the user
is more aware that changing a value in the template changes the value
for all child products. He will have to do those changes on the template
form. A link to the template has been added in the product form view.

bzr revid: tde@openerp.com-20140122095826-8k0wl7af57iiyify
2014-01-22 10:58:26 +01:00
Thibault Delavallée 14bdf21b17 [CLEAN] product: cleaned product template copy method improvements
bzr revid: tde@openerp.com-20140121122139-j4jmr3jfbaoaamyj
2014-01-21 13:21:39 +01:00
Thibault Delavallée 744810bbb4 [REV] product: unlink method back, no comment about why it has been
removed. It is therefore added back.

bzr revid: tde@openerp.com-20140121111421-x35gyqwo9jdpr3d7
2014-01-21 12:14:21 +01:00
Thibault Delavallée b3a4778f26 [IMP] product variant: removed override of fields_view_get and use a "one group or another"
behavior for product variant. Users are either in group_product_mono or
group_product_variant, allowing to tune the form view according to the
group the user belongs to.
product: added group_product_mono group
sale: added set_group_product_variant method that adds or remove the
group_product_mono according to the group_product_variant being unchecked
or checked.
product: updated form view accordingly

bzr revid: tde@openerp.com-20140121105046-zkbs778upjg0lpyr
2014-01-21 11:50:46 +01:00
Darshan Kalola (OpenERP) 82cdf9e4c0 [IMP]product: removed unnecessary code from onchange_product_tmpl_id and improved indentation in template form view.
bzr revid: dka@tinyerp.com-20140117110544-y7lc0t2xc0bb6403
2014-01-17 16:35:44 +05:30
Darshan Kalola (OpenERP) 132933f991 [IMP]revert margin calculation.
bzr revid: dka@tinyerp.com-20140117100627-s65f1jlv93h4w3p1
2014-01-17 15:36:27 +05:30
Darshan Kalola (OpenERP) 86ec8bd39a [IMP]removed unnecessary code.
bzr revid: dka@tinyerp.com-20140117082647-6aoiouidtl06r3vk
2014-01-17 13:56:47 +05:30