Commit Graph
680 Commits
Author SHA1 Message Date
Guillaume (gdi)andqsm-odoo c2f394253e [IMP] website, *: improve the "edit in backend" button
*: base, mrp_account, product, mail, website_blog, website_event,
   website_forum

This commit improves the button that allows to go to the backend view of
an object when you are on its corresponding page on the website. The
button is more visible and the user can see which object he is going to
edit. Note that this commit also:

- Changes the access key to translate a website page to ALT + T.

- Adds a new access key to edit an object in backend with ALT + E.

- Removes the possibility to duplicate a blog post (but this feature
will be reintroduced later for all models, generically) **.

**: Note that the duplication of blog posts actually had a mistake:

The controller to create a new blog post has been added with [1] where
it has been decided to not be a follower of the blog posts at their
creation. A new controller has been added by [2] to be able to duplicate
a blog post, to be consistent with [1], here also the user does not
become a follower of the new blog post (the copy). So far, so good.
Finally, [3] has changed the blog post creation controller so that the
user who creates the blog post is a follower of the new blog post.
Unfortunately the same change was not made for the duplicate controller,
which is a mistake. There is no reason to be a follower of the newly
created blog posts when you go through the add blog post controller but
not when you go through the duplication controller. The behaviors should
be consistent and there is no reason for there to be a difference.

[1]: https://github.com/odoo/odoo/commit/4c3b516a7b988d758a67ff19242e8ed0837d756c
[2]: https://github.com/odoo/odoo/commit/fe40538aff2b65f7719840c8e2d6e51e858f560f
[3]: https://github.com/odoo/odoo/commit/4bf9dc4078a5ca413539a6fd16400fd5aad46907

task-2889929

closes odoo/odoo#97353

Related: odoo/enterprise#30075
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2022-09-04 18:29:37 +02:00
Jinjiu Liu 7130939bcd [FIX] product: a temporal variant copy for future convenience
Reproduction:
1. Create a dynamic attribute "dyn_att" with a couple of values
2. Create a product template "dyn_prod" with those attribute values
3. Create an order for "dyn_prod", this will trigger creating a variant
4. Make sure to check Variant Grid Entry in Sales Settings
5. Open variant form view of dyn_prod and edit it to allow duplication
6. Duplicating it leads to an error

Reason: copying the variant is not possible and disabled here:
https://github.com/odoo/odoo/pull/38303 For future convenience, maybe
it’s better to give a temporal working solution. The function
_create_first_product_variant is used in the product module but only
defined in its child module website_sale

Fix: copy the product template, create and return its first possible
variant. Added test for dynamic variant copy. change the definition
place of _create_first_product_variant to module product

opw-2790543

closes odoo/odoo#98809

X-original-commit: 34a2948d3d6e0f597c1b5d65f9f118e891c07cc4
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Liu Jinjiu (jili) <jili@odoo.com>
2022-08-27 03:33:39 +02:00
Yannick Tivisse d22bdc5828 [FIX] product: Prevent deleting Expenses product category
closes odoo/odoo#98048

Taskid: 2937400
X-original-commit: af30867f01a1e4e0a7a06c098d5833a60ddc73a4
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-08-12 22:18:17 +02:00
Fabien Pinckaers 34e94a3dc0 [FIX] product: template should be transaltable, introduced by rev 68e7c0de165c00
closes odoo/odoo#97707

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-08-09 07:47:43 +02:00
Rémy Voet (ryv) 9584f80a48 [IMP] product: merge and simplify api.contraints for performance
- Merge `_check_barcode_unique` and `_check_barcode_uniqueness`.
- Simplify the code and avoid costly read_group
- Add missing index on barcode of `product.product` (before there was an
unique constraint)

(Note that the constraints isn't transactional safe because it is not an
SQL contraints)

closes odoo/odoo#96043

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-08-08 14:16:52 +02:00
Fabien Pinckaers 3363e55cac [IMP] cleanup of help messages in all modules
This commit aims at removing unuseful help message to:
1/ reduce translators work, to focus on more useful translations
2/ not sending unuseful information in load_views
3/ reduce help message to useful messages, so that we can mark
   fields having a tooltip in the future UI.
4/ some cleanup of existing messages too

The main use cases:
- REMOVED: help redundant with the field name, providing no extra info
- MOVED TO COMMENT: technical help messages, that should not be in UX

closes odoo/odoo#97279

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-08-02 00:26:53 +02:00
Touati Djamel (otd) ab485e9318 [FIX] sale,sale_project: delete service tracking for non service product
Steps to reproduce the product:
- Create a new product:
- Select “Service” type
- Go to the Sales tab:
    - Select "Create a task in an existing project" in the `service
    tracking` field
     - the `project` field becomes visible
- Change the Type of the product to “Consumable”
- Try to save

Problem:
The field `project` remains visible and as it is a required field,
we have to fill it in before being able to save the product.
While it is a feature only for service-type products

Solution:
- The `project` field is based on the `service_tracking` field
to become invisible or not. So when the product is not of service type,
we must remove the tracking service so that the project field
becomes invisible.

- Prevent the user from changing the type of products already used in
a sale order

opw-2858064

closes odoo/odoo#93804

X-original-commit: 102951140e3f35ced8653d4bedb82b63bb2c963f
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-06-16 16:03:43 +02:00
Jordi Ballester aba7ffc38d [FIX] product: Only trigger unlink when there are records to unlink
closes odoo/odoo#92663

X-original-commit: 9039380f74984878f95a4dcf9cf425a855330a38
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-06-01 17:36:45 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Adrien Widart 5fdd2d178a [FIX] product: search on template's default code
When filtering on product templates with a negative operator, the
result

is incorrect

To reproduce the issue:
(Need mrp)
1. Create two products P_compo, P_finished:
    - Internal Reference:
        - P_compo: 123
        - P_finished: 456
2. Create a BoM:
    - Product: P_finished
    - Components:
        - 1 x P_compo
3. Manufacturing > Master Data > Bills Of Materials
4. Remove search filters and apply this custom one:
    - "Product doesn't contain 456"

Error: P_finished's BoM is still in the list, but '456' is the internal
reference of P_finished, so this BoM should not be displayed

The filter is applied on the field `product_tmpl_id` of the BoM, which
leads to the override of `_name_search` in `product.template`. In this
method, a call to the `_name_search` of `product.product` is executed:
https://github.com/odoo/odoo/blob/5ff4eb022757d7a522ccb975f8eb64053ef9780b/addons/product/models/product_template.py#L456
which is a good thing because the version of `product.product` handles
the case of the Internal Reference (`default_code`)
https://github.com/odoo/odoo/blob/1e8982e4cf6b604e4da2773f10bdf6cf94c7e683/addons/product/models/product.py#L532-L538
So, the call to this `_name_search` will not return P_finished. However,
later on in the `_name_search` of `product.template`, we call the
`_name_search` of `super` with the same domain (i.e., 'not 456 in name')
https://github.com/odoo/odoo/blob/5ff4eb022757d7a522ccb975f8eb64053ef9780b/addons/product/models/product_template.py#L474-L485
This is the issue: it leads to the `_name_search` of `BaseModel`, which
is the classic version: it does only consider the record's name. So,
this call will return P_finished.

In the `_name_search` of `product.template`, there are actually two
calls to `super`. Considering the commits [1] and [2], it seems that the
goal is the same in both cases: find the `product.template` that do have
any variant yet. However, in the first commit, the domain given to
`super` excludes the templates that have at least one variant, which is
not the case with the second commit (the "problematic" one).

Since both codes have the same goal, we should merge them by keeping the
best idea of each one. From [1], we keep the idea of restricting the
domain: we only look for templates that do not have any variant.
However, this domain needs to be improved: we need to include the
templates whose all variants are archived. From [2], we keep the idea of
looking for the templates outside the `while True` loop. This allows us
to do the search only if required.

[1] 21ae503
[2] 99bae2c

OPW-2791255

closes odoo/odoo#90248

X-original-commit: 942814844e982cbaec2329709c6ba9dd810d0c3f
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-05-02 10:37:04 +02:00
Touati Djamel (otd) 769230a80d [FIX] product: update attribute's related products
Steps to reproduce the bug:
- Create a product attribute “PA”:
    - Variants Creation Mode: Never
    - Value: “PA1”

- Create a storable product “test”:
    - Add the attribute “PA“ and the variant “PA1”
    - Save

- Archive the product and then remove the attribute from the product
- Unarchive the product

So the product has no longer the attribute line but if we check the
attribute itself, it is still having the product as a related one.

Problem:
When we remove the line attribute, the `_compute_products` is called,
but as the product “test” is archived, when we try to access the
related products of the product attribute, it returns an empty recordset
because the ORM only returns active records.
Since the attribute `product_tmpl_ids` seems empty and we try to update
it with an empty value, the ORM considers there is no change and so, it
does not update the field value in the DB.

Solution:
We must use `active_test=False` when accessing the related products, so
the ORM returns all records, active or archived.
And since there is indeed a linked product and we are trying to
overwrite it with an empty recordset, the change will be effective.

opw-2806316

closes odoo/odoo#90166

X-original-commit: 7d304078b4ed97d23ec84609e6aea137e8500a18
Signed-off-by: Steve Van Essche <svs@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-04-29 18:22:02 +02:00
Swapnesh Shah 03c697a17d [FIX] product: show barcode on archived templates
Before this commit, Barcode was not displayed on template
when related product variant is archived.

Here we are making sure that even when a product is
archived, its barcode is still visible in template.

closes odoo/odoo#89363

X-original-commit: f0c7cde3938c01df5fc10bb8dcd72fd3bb18afdb
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-04-22 12:04:38 +02:00
Thibault LibioulleandVictor Feyens a7f30ce917 [IMP] product,sale: factorize price methods to improve inheritability
This commit adds an higher flexibility to pass optional args through the
price computation methods.

Those optional kwargs offer the opportunity to tune the price
computation, especially to tune the price_compute method on
ProductProduct and ProductTemplate.

On sale order line models, one can define some fields that should be
passed to the price_compute method in order to tune it.

task-2382027

Co-authored-by: Victor Feyens <vfe@odoo.com>
2022-04-14 14:33:23 +02:00
Thibault Libioulle 7ac5ffa8aa [IMP] product: factorize contextual price
This commit factorizes contextual price in order to ease further
inheritance.

task-2382027
2022-04-14 14:33:22 +02:00
Nicolas Pierre 99b56ec706 [IMP] mrp_subcontracting: subcontracting portal
Creation of a subcontracting portal to let the subcontractor register himself
all the components that were used for the production. The portal is
reusing the backend view of the stock picking where components were
registered before.

closes odoo/odoo#83465

Task: 2645298
Community-pr:  https://github.com/odoo/odoo/pull/83465
Enterprise-pr: https://github.com/odoo/enterprise/pull/24647
Related: odoo/upgrade#3402
Related: odoo/enterprise#24647
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-04-11 11:01:50 +02:00
william 3155c3e425 [IMP] core,*: add helper for name_search
Most of the extensions of `_name_get` are very similar and only want to
search for the given string in multiple fields.
A lot of extensions also don't take into account the negative operators.
Some implementations were also really outdated and needlessly
complicated.

closes odoo/odoo#86588

Related: odoo/enterprise#25608
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-04-06 18:37:39 +02:00
William Braeckman 2a1928eef7 [IMP] website_sale: disable archived variants
Prior to this commit archived variants would not appear as disabled
 in the shop, the different options will now be greyd out if selecting
 them would result in an archived variant.

TaskId-2762122

closes odoo/odoo#84711

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-03-28 21:45:49 +02:00
boan-odoo 4a48d48364 [IMP] stock: show related products on duplicated barcode
Previously, product barcodes uniqueness was enforced
by a SQL constraint, resulting in a generic error message.

The SQL constraint has been replaced by a Python check,
which allows the listing of conflicting barcodes in the
error message, including those resulting from batch edits.

Task: 2654703-7
Part-of: odoo/odoo#84056
2022-03-21 11:12:00 +01:00
Audric Onockx (auon) 0910f071a7 [FIX] product : apply only active price rules
Steps :
Install Sale / E-commerce.
Create product P (price = 100).
Create price list L.
Create price rule R (product = P, price = 50).
Go to product P > Price Rules > archive R.
Create a quotation. / Website > click 'Go to website' > Shop.
Select price list L.
Create a SOL with product P. / Search for product P.

Issue :
Price is 50.

Cause :
Archived price rules are included in the 'search' of
_compute_price_rule_get_items().

Fix :
Exclude them.

opw-2752184

closes odoo/odoo#85811

X-original-commit: d5e8308492ac8955ad76fd8d9f3781266dee76f6
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-03-04 13:12:43 +00:00
Rémy Voet (ryv) 13bddabbe0 [FIX] product: fix performance bottleneck of populate
Since 4911a26d2c, `_check_barcode_uniqueness`
flush the default `_order` of `product.product` models (via many2one in the `_order`
of `product.packaging`). It creates a bottleneck (take > 10 minutes ) when we populate
(medium size) the `product.template` during `set_barcode_variant`.

Force the order to be trivial and simplify the domain with a 'in' instead of
multiple OR.

closes odoo/odoo#85687

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-03-03 11:04:13 +00:00
Florian Damhaut ab940a921e [FIX] product: packaging correctly chosen
Step to reproduce:
- create a unit of measurement (UoM) and set it's rounding to 1.000
- create a product that uses this UoM
- create two packaging for this product
- create a sales order and in the sales order line set the created product
- you can already see the packaging is set, but anyways set a quantity to near the defined in the package
- the quantity will be updated

Current behaviour:
- Packaging always update to bigger package even if it doesn't fit

Behaviour after PR:
- Packaging update to the biggest package which is a full divider of the qty
- If no package fit, then no package are applied

opw-2718146

closes odoo/odoo#85351

X-original-commit: ad047434a802abfc9f4203897aec9cda149dd43b
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Damhaut Florian (flda) <flda@odoo.com>
2022-03-01 07:15:18 +00:00
Thibault Libioulle 1d85cabb50 [FIX] product,website_sale: fix contextual price on eCommerce
Prior to this commit the price in the product dynamic filter was not
correctly computed since the pricelist was not available in the context.

This commit provides a fallback on request website pricelist in order to
display a non-zero price if it exists.

task-2765828

closes odoo/odoo#85507

X-original-commit: 88bfd8a60cefac45e73cd032204c9b90a862ee6c
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-02-28 13:53:32 +00:00
Victor Feyens 78776bf3de [MOV] product: split product.py (2)
Files split in two commits to keep lines ownership and git blames.

Part-of: odoo/odoo#84970
2022-02-21 11:24:16 +00:00
Victor Feyens 2e3c21941c [MOV] product: split product.py (1)
Part-of: odoo/odoo#84970
2022-02-21 11:24:16 +00:00
Victor Feyens dc8db07ba7 [IMP] product: do not fetch all categories/variants/templates data
Delegate to subqueries, reduce data fetched from database,
potentially reduce queries when computing prices.

Part-of: odoo/odoo#82374
2022-02-21 08:41:29 +00:00
Victor Feyens a73fb16da0 [IMP] product,website_sale: pricelist API cleanup
* query pricelist filters/domains directly for the correct company 
instead of relying on context/session/... content
* pass the record instead of the id to avoid useless browse calls
* also clearly highlight sudoed partner record

Part-of: odoo/odoo#82374
2022-02-21 08:41:29 +00:00
Victor Feyens 06f417012c [IMP] product: clean res_partner.py
Part-of: odoo/odoo#82374
2022-02-21 08:41:29 +00:00
Victor Feyens 5a58ba9d1a [IMP] product: clean product_pricelist.py
* rename default method according to guidelines
* reorder fields
* clean fields attributes & indentation

Part-of: odoo/odoo#82374
2022-02-21 08:41:28 +00:00
Victor Feyens 753ac6b30a [IMP] product: clean product_pricelist_item file
* order fields, methods according to guidelines
* fix some typos
* rename methods according to guidelines
* remove useless field attributes and class specifications in super()
calls

Part-of: odoo/odoo#82374
2022-02-21 08:41:28 +00:00
Victor Feyens 35bc99a77e [IMP] product: split python files by classes
Part-of: odoo/odoo#82374
2022-02-21 08:41:28 +00:00
Yolann Sabaux 61f429c274 [FIX] product: variant exclusion not taken into account
Steps to repoduce:
- Go to Sales - products
- Create a product
- Add variants (3 attributes and 2 values each) Total is 8 variants.
- onfigure variants: Select 1 attribute and exclude it for 1 variant (for example: exclude for size 12x12)
-> the number of variants remains at 8. The one that is excluded is still visible in the Product variants tab.

Solution:
When an exclusion is created, archive all the not-possible-combination.

OPW-2729329

closes odoo/odoo#84883

X-original-commit: 91642f4e29beb89d110084a20443fb300ee26530
Related: odoo/enterprise#24512
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-02-18 14:29:06 +00:00
Bruno-brsy 4b569dba98 [FIX] product: help for field standard_price
Step to reproduce:
1) create a product with, the "Product Type" as
"Storable Product" + A "Product Category" with a "Costing Method"
set in "FIFO" mode and the Inventory Valuation in "Automated".

2) create a Purchase Order for 1 unit of that product and set the unit
price to 10.00. Confirm Order -> Receive Products -> Validate
(the delivery) -> Apply

3) create a second Purchase Order for 1 unit of the same product but
set the unit price to a different price, like 20.00. Confirm Order ->
Receive Products -> Validate (the delivery) -> Apply

4) create a Sales Orders for 1 unit -> Confirm -> Smart button
Delivery -> Validate -> Apply

5) check the cost on the product form of that product.

On the V13 it will be $10, so its the last unit that left the stock
On V14 and upper, it will be $20, so the next product that will leave
the stock.

The help popup for the field "standard_price" doesn't reflect the
correct behavior. It's the standard price for the next unit instead
of the last one.

closes odoo/odoo#84289

X-original-commit: 9e0a529b603302653dac2a8fb692472fc500c147
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Bruno-brsy <brsy@odoo.com>
2022-02-10 11:41:55 +00:00
Yannick Tivisse ee3bf990d9 [IMP] sale_product_configurator: Make module auto_install
Part-of: odoo/odoo#82999
2022-02-08 14:53:37 +00:00
Victor Feyens e51537a430 [IMP] product: reduce forced cache invalidation & flushes
write call on product.template.attribute.line with an active value specified
will trigger cache invalidation & flush even if no record is specified in
the call.

_create_variant_ids is called on multiple places, including the unlink
of product.template.attribute.line records.  In this flow, self might
be an empty recordset, and there is no need to trigger early flushes and
cache invalidation if self is empty.

Part-of: odoo/odoo#84055
2022-02-07 15:24:49 +00:00
Adrien Widart 4911a26d2c [IMP] product: check barcode uniqueness
With GS1 nomenclature, products and packagins use the same pattern.
Therefore, we need to ensure the uniqueness between products' barcodes
and packagings' ones.

closes odoo/odoo#82883

Related: odoo/enterprise#23550
Related: odoo/upgrade#3180
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-02-07 14:18:00 +00:00
Raphael Collet a1904aa6f6 [IMP] core: field index names
The possible index names have been renamed "btree", "btree_not_null"
(instead of "not null") and "trigram" (instead of "gin").

Task 2742526

Part-of: odoo/odoo#83274
2022-01-28 14:10:01 +00:00
Aurélien (avd) e9d9058b64 [FIX] product: name_get performances
Currently, product.name_get goes through
each product in the record set
before calling _get_combination_name
on its attribute values.

This can lead to some slowdowns when the recordset
starts to grow (> 100 products). The reason for
that is that _get_combination_name
filters the recordset twice.

This commit speed-up _get_combination_name
by "resetting" prefetch_ids to self._prefetch_ids,
i.e. the prefetch_ids of the whole recordset.

opw-2624261

closes odoo/odoo#83563

X-original-commit: 2065c53a6e0c3f1c363f5b2bea401782a1f4b31b
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-28 12:21:51 +00:00
Touati Djamel (otd) e46d5cfad4 [FIX] product: prevent user to select a pricelist from another company
Steps to reproduce the bug:
- Have company A and B
- Create a pricelist A with company A and pricelist B with company B
- Select company A as current company and B as allowed company
- Create contact A without linked company

Problem:
You can select pricelist B while the current company is A, this causes an access error if you save and only select company A in the selector.
It also causes an error when you open a new POS session.

This contact is not linked to a company, so it should be accessible from all companies.

Solution:
Add a domain to allow the user to only select the pricelist linked to the current company or a pricelist that are not linked to a company

opw-2745267

closes odoo/odoo#83537

X-original-commit: 9f79c62fa56a1bb92ea3fc79fd82431bf9041d5c
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-01-28 08:54:38 +00:00
Touati Djamel (otd) 2de9342a11 [FIX] product: fix contained quantity decimal precision
Steps to reproduce the bug:
- Activate packaging in inventory configurations
- set the product UOM digits to more than 2 decimals
- Create a storable product:
    - Go to inventory tab > Packaging > Add a line
    - Change the contained quantity to a value with more than 2 decimal places

Problem:
It will round it to 2 decimal places regardless of the set digits.
Because the formatFloat function does not receive the digits in parameter, so it uses 2 as default value

Problem:

opw-2723068

closes odoo/odoo#83411

X-original-commit: 144761f07c9de53aaeb7e1468e017eee17cbacd2
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-01-26 14:09:02 +00:00
Fabien Pinckaers eedf37d6e2 [IMP] Better handling of indexes
Three supported types:
- btree (default for index=True)
- btree not null (when >90% of the data are null)
- gin trigram search (for char fields)

Review of indexes on all objects.

closes odoo/odoo#83015

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-01-19 16:52:23 +00:00
Raphael Collet 5a32587f16 [FIX] product: make cache invalidation more specific
Some aggressive cache invalidation in the middle of method write() where
the model has children models (in the _inherits sense) causes very nasty
errors that are hard to fix.

Consider two models A and B, where B inherits from A.  Also consider two
fields a1 and a2 on A, which are thus both inherited by B.  Now take a
record from model B, and update both fields as:

    record.write({'a1': ..., 'a2': ...})

As both fields appear as related fields on model B, the method write()
puts all values in cache, then it proceeds to call the inverse method of
both fields.  The inverse method of a1 is called, and this writes on the
parent record.  Now imagine that some override on A invalidates the
whole cache.  When the inverse method of a2 is called, the field's value
on B has been invalidated, and this therefore writes the value False on
the record's parent.

This patch removes and adapt such cache invalidations:
 - Since 4b1cb41cf7, the cache invalidation
   in method write() of product.product is no longer necessary.
 - The cache invalidation in method write() of product.pricelist.item
   has been removed as well, since field that needs to be recomputed no
   longer exists.

Fixes #76946, #77042

closes odoo/odoo#82958

Opw: 2657461
X-original-commit: 5a73a8a3697c0f2685471efa252e5eb1af738e83
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-01-18 11:56:55 +00:00
Thibault Libioulle 5b64d252d2 [IMP] product: add product tag model
This commit adds the product tag model.

Purpose
=======

The product tags allows to easily tag given types of product
independently from their category, following their product range, their
seasonal collection, their theme, etc

Specification
=============

A product template takes tags that are valid for all their variants.
In order to add granularity, product variants can also take additionnal
tags.
A field is defined on product variants to allow searching on both
product template and product variant tags.

task-2675384

Part-of: odoo/odoo#79296
2022-01-17 14:07:45 +00:00
Sylvain LE GALandvfe-odoo 4e31e23cc2 [REF] product : add a function that makes easy to add other related fields between product.template and product.product models (like barcode)
closes odoo/odoo#82642

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Co-authored-by: vfe-odoo <Feyensv@users.noreply.github.com>
2022-01-12 17:33:59 +00:00
Adrien Widart 38a3f7fea4 [FIX] {purchase_}stock, product: base product name on supplier
Suppose a product with several suppliers, all with the same partner. On
the purchase order, the product description will always be based on the
last supplier

To reproduce the issue:
1. Create a vendor V
2. Create a product P:
    - Type: Storable
    - In Purchase, add a line L01:
        - Vendor: V
        - Vendor Product Name: Name01
        - Vendor Product Code: C01
        - Quantity: 1
        - Price: 10
    - In Purchase, add a second line L02:
        - Vendor: V
        - Vendor Product Name: Name02
        - Vendor Product Code: C02
        - Quantity: 20
        - Price: 2
    - Once P is saved, ensure the lines order in the purchase tab:
        - L01
        - L02
3. Add a reordering rule on P:
    - Min: 1
4. Run the scheduler
5. Open the generated PO

Error: The description is incorrect ("[C02] Name02" instead of "[C01]
Name01")

When computing the display name of the product,
https://github.com/odoo/odoo/blob/7691567286869ca65e63fc79c2cee11e1f415fcb/odoo/models.py#L1728-L1730
`name_get` returns a tuples list: `[(37, '[C01] Name01'), (37, '[C02]
Name02')]` where `37` is the product identifier. This list is then
converted into a dictionary and here is the issue: it will use the last
tuple to define the value for key `37`, i.e. "[C02] Name02". Therefore,
`name_get` should return the correct name, and only this one.

Another issue could be highlighted: when the user changes the quantity
of the purchase order line, if another supplier info is selected, the
description won't be updated (for the same reason as above)

OPW-2702616

closes odoo/odoo#82321

X-original-commit: a42608214f2e9ef3f5e59b4b54cd7f72a6019e06
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-01-06 19:30:49 +00:00
Jairo LlopisandBenoit Socias 620b022250 [IMP] product: involve product template in last update computation
Since [1] whenever the image of a `product.template` is updated, the
write date of all its related `product.product` is updated.  This was
done to force a change of the unique parameter on image fields, which is
based on the last update field.

After this commit the `product.product`'s last update is instead
computed by also taking the `product.template`'s last update into
account.  This avoids the need for updating the write date when the
image is changed, but on the other hand it also forces product images to
be reloaded whenever any other field of the `product.template` is
changed.

[1] https://github.com/odoo/odoo/pull/71139

Related to https://github.com/odoo/odoo/pull/76309

task-2477438

closes odoo/odoo#78356

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Co-authored-by: Benoit Socias <bso@odoo.com>
2022-01-04 11:16:43 +00:00
Victor Feyens 83c583b494 [IMP] product: do not fallback on context values in price_compute
This adds too much indeterminism in price computation logic.

Furthermore, remaining calls to price_compute provide the parameter when
needed.
2021-12-23 15:30:24 +01:00
Yannick Tivisse bbd65b8a3a [IMP] product,sale: Convert _onchange_type into compute methods 2021-12-23 15:30:23 +01:00
Yannick Tivisse 9e99a9df46 [IMP] product: Remove price/pricelist_id field from template/variant
Purpose
=======

The fields are not used, don't work correctly and there is a specific
report to generate the product prices according to the pricelist and
the ordered quantities
2021-12-23 15:30:23 +01:00
Victor Feyens 0acd96c340 [IMP] sale: Use a 'cached' pricelist rule mechanism
Cache the pricelist rule used for price computation in a dedicated non
stored field, since it is used both for the price_unit and the discount
computation.

This divides by 2 the number of pricelist requests/queries when
discounts computation is enabled.
2021-12-23 15:30:23 +01:00
Victor FeyensandChafique delli 24fbbb7f83 [IMP] product: split rule filtering in separate method
Co-authored-by: Chafique delli <chafique.delli@akretion.com>
2021-12-23 15:30:23 +01:00