Commit Graph
4775 Commits
Author SHA1 Message Date
Samuel Degueldre 138f00255a [FIX] account, hr_timesheet, product, web: add missing oe_inline classes
Since the fields were rewritten in owl, they all have a width of 100% by
default, which is what we want when displaying a field on their own.
In some places, fields are used as part of a longer block of content (eg
unit of measure behind a number). In those cases, we want to display the
field inline, which requires the addition of the oe_inline class in the
arch.

There was also a missing piece of css for the monetary field, as the
previous rule no longer applied because of the slight changes to the DOM
structure.

closes odoo/odoo#99529

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-05 09:31:57 +02:00
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
Denis Ledoux 9f89137bb2 [IMP] product: move group inside the view
The goal being to get rid of the `groups_id` feature for backend views

Part-of: odoo/odoo#98551
2022-08-29 22:42:54 +02:00
Denis Ledoux 8b91cab67f [IMP] base: remove groups_id from ir.ui.view
The goal of this revision is to get rid of the `groups_id` field of the model `ir.ui.view`.

- This feature wasn't really known or used by most developers,
   and not straight-forward to understand.
   Removing it allows one less complicated thing to learn for developers.
   Besides, thanks to odoo/odoo#95729,
   changing the behavior of the `groups=` attribute,
   we can easily get rid of this `groups_id` feature
   by simply adding `groups=` in the elements of the views
   using the `groups_id` field, it will have the same effect:
   adding the elements in the view only for the users part of the specified group.

- By getting rid of the groups_id many2many field on ir.ui.view,
   it makes possible to cache the view architecture without
   requiring to use the groups in the cache key.
   Currently, if we want to cache the view architecture,
  it would be required to use the intersection of the user
  groups with the groups_id groups of the view,
  making it costly to compute the cache key,
  therefore altering the performance point to cache the view
  architectures.

Part-of: odoo/odoo#98551
2022-08-29 22:42:50 +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
Xavier-Do 5648cc9aa4 [FIX] base, l10n_*: set currency with existing lines
Since #96791 the currency is reset to USD when starting a test to be
less dependant of demo data when starting tests.

Unfortunatelly, some l10n_modules will add account.move.line demo data
leading to an error:

        You cannot change the currency of the company since some journal
        items already exist

An initial solution would be to delete the existing account.move.line

        cls.env['account.move.line'].search([('company_id', '=', company.id)]).unlink()

This is only possible passing some context flags in order to disable some checks

        existing = cls.env['account.move.line'].search([('company_id', '=', company.id)])
        existing = existing.with_context(dynamic_unlink=True, force_delete=True)
        existing.unlink()

Actually, unlinking account.move.line also creates other ones.

        existing = cls.env['account.move.line'].search([('company_id', '=', company.id)])
        existing = existing.with_context(dynamic_unlink=True, force_delete=True)
        existing.unlink()
        existing = cls.env['account.move.line'].search([('company_id', '=', company.id)])
        existing = existing.with_context(dynamic_unlink=True, force_delete=True)
        existing.unlink()

Finally, it looks easier to bypass all business logic leading to the proposed solution.

closes odoo/odoo#98736

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-08-25 12:05:06 +02:00
Denis Ledoux 0501bbd62e [IMP] base: uniform "groups" in back-end view
This revision is to make uniform the behavior of the `groups` attribute
on the Python model fields
and on the node in the view architecture.
In both cases, remove the node from the view completely.

Before this revision,

in a back-end view:
 - In the Python model, if a field has the `groups` attribute set
   and the user is not part of
   the groups, the field is removed, completely, from the view.
 - In the view architecture, if a node has the `groups` attribute set
   and the user is not part of
   the groups, the node is made invisible (not completely removed, just
   made invisible).

in a front-end view:
 - if a node has a "groups" or "t-groups" set and the user
   is not part of the groups, the node is removed from the view.

So it's 2/3 cases removing nodes restricted to a group.
and 1/3 case making invisible nodes restricted to a group.
It's simpler to have a uniform behavior for the 3 cases,
simpler to understandard for developers.

In addition, this will help for the goal to cache back-end views.
It makes possible to convert views using the `groups_id` field
by moving the content of these views directly
in the view to which they add content which is suppose to be completely
removed when the user has not the according group.
By getting rid of the `groups_id` many2many field on `ir.ui.view`,
it makes possible to cache the view architecture without
requiring to use the groups in the cache key.
Currently, if we want to cache the view architecture,
it would be required to use the intersection of the user
groups with the `groups_id` groups of the view,
making it costly to compute the cache key,
therefore altering the performance point to cache the view
architectures.

closes odoo/odoo#95729

Related: odoo/enterprise#29592
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-08-19 19:10:39 +02:00
luvi 731a85f80e [FIX] web, product: BooleanField style
The field style was broken in form views since it
uses the display: contents rule. This commit
fixes the style of the field as it is now correctly
displayed inline.

It also changes the css selector to set the
style appropriately inside product views.

closes odoo/odoo#98185

Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-08-17 10:02:59 +02:00
Romain Estievenart 36628c9b1c [FIX] *: removes .form-inline
this commit removes the usage of .form-inline class which is deprecated
since BS5.

here is the css rules that was used:
https://github.com/twbs/bootstrap/blob/8fa0d3010112dca5dd6dd501173415856001ba8b/dist/css/bootstrap.css#L2303

'''Breaking change: Dropped form-specific layout classes for our grid
system.
Use our grid and utilities instead of .form-group, .form-row, or
.form-inline.'''

https://getbootstrap.com/docs/5.0/migration/#forms

We also took the opportunity to remove some .input-group-append and
.form-group. We are currently working to remove all of them.

Part-of: odoo/odoo#97967
2022-08-16 09:19:08 +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
Martin Trigaux b821961236 [I18N] *: sync fr_BE translation terms
Only for terms containing Credit Note and expenses

closes odoo/odoo#97840

X-original-commit: 1754b094a66476a0bdb29fe60dc5583c03336c3f
Related: odoo/enterprise#30262
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-08-10 03:11:53 +02:00
Arnaud Joset 60c362ae7f [FIX] product: add product_tmpl_id to allow easy view inherit
Before this commit, the product_tmpl_id field was present in the
product_pricelist_view but not the product_pricelist_view_inherit.

This changes allows to have a simple solution to modify the product_tmpl_id attributes
in other modules.

closes odoo/odoo#97721

Taskid: 2886054
X-original-commit: 312107060f1b6d7aaa907792ee18c9ef22a47cd9
Related: odoo/enterprise#30211
Signed-off-by: Kevin Baptiste <kba@odoo.com>
Signed-off-by: Arnaud Joset <arj@odoo.com>
2022-08-09 09:00:16 +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
Victor Feyens 546721e441 [REF] product: test infrastructure
* commons & setup refactoring:
  * convert setUp to setUpClass
  * move setups where needed (stock/mrp commons or specific test
classes)
  * create test data in batch (faster, less sql queries & batched
operations)
* move most tests post-install to allow runbot splits
* by default, run tests without mail logic
* by default, run tests in a consistent environment (fixed currency
imposed in the BaseCommon)
* refactor existing tests to use new commons data (while trying to keep
diff reduced)
* add dedicated test file to test the common data
* use mute_logger to reduce useless test logs (less spam to scroll in
logs, less data on runbot builds, ...)

Part-of: odoo/odoo#96791
2022-08-08 12:33:03 +02:00
Adesh Jolhe (adjo) 540c740ae4 [IMP] sale_,hr_(project,timesheet): generic improvements for project
Purpose of this PR to improve generic usage of project app.

So in this commit did the following changes:
 - Changed recurrence conformation messgae
 - Changed Burger menu actions  in
   project.project kanban view
 - Added quick search Description in project.task search view
 - In product form view hide button based on condition
 - Added sample data in project_milestone_views
 - switch the state and the author fields from place and add author
   label underneath it's value
 - switch the date and the progress fields from place
 - Added table-stripes class
 - Changed label sprint summary to summary in project_update_default_description
 - In project.project form view and project.update right-side panel hide
   'collaborators' button on condition

task-2895388

closes odoo/odoo#95245

Related: odoo/enterprise#29089
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-08-03 20:47:50 +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) 48a6f88c50 [FIX] product: prevent printing labels for archived products
Steps to reproduce the bug:
- Create a storable product
- Archive it
- Try to print labels

Problem:
A traceback is triggered, Because when we click on print the label
we have to open the wizard, so we load the wizard model
`product.label.layout` via an onchange:
https://github.com/odoo/odoo/blob/15.0/odoo/models.py#L6357-L6360
thanks to the context, it will find the concerned product
(via default_product_id) Except that the product is archived,
so ignored in the result returned by the onchange

therefore, in the confirmation, we will create the wizard,
but it will not have a product filled, so in the `_prepare_report_data`
function we do not enter in the if or the elif:
https://github.com/odoo/odoo/blob/d9f45ba6941939b3d4b40beb5abbc330be84d695/addons/product/wizard/product_label_layout. py#L49-L54

it will therefore raise a traceback when we want to iterate on it:
https://github.com/odoo/odoo/blob/d9f45ba6941939b3d4b40beb5abbc330be84d695/addons/product/wizard/product_label_layout.py#L60

opw-2855659

closes odoo/odoo#97226

X-original-commit: 6dcec12074014434ce1283449700aa352993ac0c
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-08-01 19:37:20 +02:00
MAHAMADASIF ANSARI 6807eea38c [FIX] various: display full name/title in form views
With commit[1], we added `o_text_overflow` classes at several places to avoid
long names going out of the boxes. However, for the name/title fields in the
form views, we should always show the full name.

So this commit replaces `o_text_overflow` class with `text-break` from
name/title fields in the form views to display full string in the read
only mode, but also keep them from going outside of the form view.

Below are the modules affected:
 - base
 - coupon
 - crm
 - event
 - mass_mailing
 - mass_mailing_sms
 - project
 - sales_team

commit[1] - a0ebb46

task-2889845

closes odoo/odoo#96132

X-original-commit: 4a74c7af6b54bd771f50d3885813f4aae442c9e7
Related: odoo/enterprise#29552
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-07-18 18:42:03 +02:00
Denis Ledoux 5ccc32fcf7 [IMP] tests: common.Form, can't write on invisible fields
In the web client, in a real use case, it's not possible
to write on fields which are invisible,
as it's not possible to write on fields which are readonly.

This is a first step in the goal to change the behavior
of the `groups=` attribute in the back-end views,
to remove them for the view instead of making them invisible.

This is mainly to reduce the diff of the revision that will introduce
the mentioned above behavior change.

As nodes with `groups=` will be removed from the view
when the user doesn't have the group, it's no longer possible
to set a value on a field having a `groups=` the user doesn't have
in the `Form` test class, as the field will no longer be at all in the
view.
However, these unit tests shouldn't have been able to set values
on invisible fields in the first place.
This revision therefore aims to correct the unit tests setting value
on fields which were invisible because the user executing the
test was not part of the required group(s) for these fields
to be visible in the view.

closes odoo/odoo#94337

Related: odoo/enterprise#28936
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-08 14:33:47 +02:00
Romeo Fragomeli 1fcd098af5 [REF] *: BS5: migration
Automated change made by a lot of RegEx to change all think that is
possible to automate.

https://getbootstrap.com/docs/5.1/migration

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:24 +02:00
Romeo Fragomeli 9ea1351334 [REF] *: BS5: Migrate forms and inputs
- BS5 uses native inputs instead of pseudo-element for some
  input like checkbox, radio, ...
  in BS5 input checkbox don't have "virtual visual" checkbox anymore
  (::before), so we remove the relative's rules

- removed `.custom-control` class

- `form-switch` use a new layout system in BS5 we adapt the code to
  match the Bootstrap approach (inline SVG).

- In tests, we don't check the exact value of the background as it
  change in community/enterprise, and it's difficult to check the value
  of an SVG.

- Overflow in progressbar is now hidden.
  -> we had to restore it.

- In BS5 margins in forms/inputs has been changed
  -> we had to restore it (e.g. 'mb-3')

- .form-group, .form-row, .form-inline
> Dropped form-specific layout classes for our grid system.
> Use our grid and utilities instead of .form-group, .form-row,
> or .form-inline.

- .input-group-append and .input-group-prepend
> Dropped .input-group-append and .input-group-prepend.
> You can now just add buttons and .input-group-text as direct
> children of the input groups.

Ref:
[1] https://getbootstrap.com/docs/5.1/migration/#forms

Task ID: 2766483

Part-of: odoo/odoo#95450
2022-07-07 13:30:18 +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
Victor Feyens 39d0f38738 [FIX] product,*: empty group in view
Since #75862, the group "Upsell & Cross Sell" was shown in the "Sales"
tab of the product views, even if empty (its content is only defined in modules
sale_product_configurator & website_sale).

This commit makes sure that the group is invisible while it has no content.

closes odoo/odoo#93504

X-original-commit: 4f6c15f07141da80525e0c361a6fa19374ef4c2c
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-06-13 20:37:35 +02:00
Martin Trigaux 5acb6db891 [I18N] *: export saas-15.4 source terms
closes odoo/odoo#93246

X-original-commit: 5ff6d185f70650c26c28a6aef7dd37c859ab58d2
Related: odoo/enterprise#28218
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-06-10 07:27:26 +02:00
Touati Djamel (otd) 74526ff1c7 [FIX] product: add the product’s company to the context
Steps to reproduce the bug:
- Enable “Product Packagings” in the settings
- Create a storable product
- Set the company field
- Go to the inventory tab:
    - Click on add packaging

Problem
The company field is not set automatically

opw-2864554

closes odoo/odoo#92826

X-original-commit: 79223022e79a95c9c1f7d6307c48866a0f9a13ef
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-06-03 12:02:28 +02:00
Ahmed Khalaf(ahkh) cd40bad675 [IMP] product: vendor pricelist default filter active products
Task: 2764771
Part-of: odoo/odoo#91640
2022-06-03 12:02:07 +02:00
Ahmed Khalaf(ahkh) fc692e5f9c [FIX] product: Ordered printing product labels
Product labels are now printed by name order

Task: 2764771
Part-of: odoo/odoo#91640
2022-06-03 12:02:06 +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
Ivan Yelizariev 09417b6ae0 [FIX] product: disable company creation via list view
List of companies is a quite delicate configuration, which must be done by Admin
via`Settings > Companies` menu. Inline creation should be always disabled for
`company_id` field. Few such cases were presented probably because of
ambiguous setting name `no_create_edit`: it disabled "Create & Edit" button, but not
"Create" button.

STEPS:

-Go to Sales -> Products and go to the List view.
-Select one Product and try to change their Company
-You'll be able create a new company.

opw-2861853

closes odoo/odoo#92453

X-original-commit: 73e6d2250b2bf15d757f0333f8f014bd8a9895cb
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2022-05-31 10:04:07 +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
Victor Feyens 42bad1a6d2 [IMP] *: remove useless keys from manifests
Remove most values uselessly specified because giving the same value as 
the default one (see _DEFAULT_MANIFEST in odoo/modules/module.py)

* auto_install is Falsy by default
* author is Odoo SA by default
* summary & description are empty strings by default
* application is False by default
* test, demo, depends and data are empty lists by default

This will reduce noise/inconsistencies between manifests specifications, 
simplify analysis of manifests content, ...

closes odoo/odoo#90209

Related: odoo/enterprise#26807
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-05-03 13:31:16 +02:00
Julien Van Roy 6ec316930d [FIX] product: fix wrong value for product type in test
The test 'test_inactive_related_product_update' raises a ValueError
"Wrong value for product.template.detailed_type: 'product'".
(which causes the L10n nightly build many fails)

See https://github.com/odoo/odoo/pull/89468

closes odoo/odoo#90339

X-original-commit: d0ff5fe311cd69a3068593142aff66b09f13c43d
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
2022-05-03 12:28:41 +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
Touati Djamel (otd) 93c2348f0c [FIX] product: fix Dymo report label
Steps to reproduce the bug:
- Create a storable product:
    - Add a Barcode and an internal reference
- Click on Print Labels:
    - Select Dymo format
    - Add an Extra Content

Problem:
1:/ The extra content is not displayed because there is not enough space
2:/ The internal reference is displayed twice: in the display_name and in another line,
It's useless to display it twice, we should use name instead of display_name for the model `product_template`

opw-2791754

closes odoo/odoo#89771

X-original-commit: 3c4c27a266f954baa28bee3bf23cabc4928b99b8
Signed-off-by: Steve Van Essche <svs@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-04-27 10:04:34 +02:00
Martin Trigaux 158b537c28 [I18N] *: export saas-15.2 source terms
closes odoo/odoo#89225

X-original-commit: 5925a83d87fa4702f4c0f22346304dc2da47c728
Related: odoo/enterprise#26435
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2022-04-23 08:33:43 +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
momegahed 3001419e15 [FIX] product: variant sale price is wrong
If applied, this commit will fix the following bug by using the price
with the additional cost added instead of only the price

Steps to reproduce:

1- install sales
2- create a product p with variant pv
3- set an extra value for pv
4- go to Products>Product Variants
5- open the pv in form view
6- the Sales Price is the price of p not pv
(which should be p + extra value)
7- also the tax string is calculated on p not pv

Bug:

```list_price``` is being used

Fix:

replace ```list_price``` with  ```lst_price```

OPW-2774199

closes odoo/odoo#88270

X-original-commit: 46526f629f7645eaac8ce86e81e806cfa392b8b8
Signed-off-by: William André (wan) <wan@odoo.com>
2022-04-08 11:39:56 +02:00
Laurent Desausoi (lade) af77021ac1 [IMP] product: tests for pricelist in another currency
When using a pricelist with a currency different than the one
of the product, the surcharges, max_margin and min_margin must use
the currency defined in the pricelist.

These tests intends to ensure that this behavior is respected.
This behavior was in fact not present (and a fix was created in stable releases)
in previous releases (before the refactoring 57ced812f0).

To reproduce the issue:
1. Enable multiple currency and enable a second one with an exagerated rate for the sake of clarity.
2. Create a formula pricelist with the newly activated currency using either surcharge or the margin.
3. Create a SO with a standard product. By switching between pricelist, you will see an invalid price.
E.G.:
        EUR_rates = 2 compared to USD        PRICELIST = surcharge of 10€ on any product
        PRODUCT_price = 300$      PRODUCT_price_euros = 150€
        CURRENT_SO_price = (300 + 10)/rate_EUR = (300 + 10)/2 = 155€
        EXPECTED_SO_price = (300 + 10*rate_EUR)/rate_EUR = (300 + 10*2)/2 = 160€

Solution:
Convert the pricelist item margin & surcharges to the base price currency.
To do so, the needed currency conversion date is given through the context.

opw-2760720

closes odoo/odoo#88243

X-original-commit: 20140e8f53633cfdf7a7147bad6055dcd707a778
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Desausoi Laurent (lade) <lade@odoo.com>
2022-04-07 16:58:49 +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
Gorash 880954ebfc [IMP] *: remove _render from ir.ui.view and simplify report
There were inconsistencies in the calls to `_render`.
* the view context could contain information that misled developers.
Indeed, the context and value of the view are not supposed to be found
in the rendering. Thus by calling `ir.qweb` with the name of the
template, we ensure that there is no unwanted information and in
addition the cache key is that of the name of the template which saves
a query.
* the context used for rendering was modified by a method on
`ir.ui.view`, except this is not information used by this model. There
is now a `_prepare_environment` method residing on `ir.qweb`. This
method allows to modify the value dictionary as well as the context in
which the rendering will be done. This preparation of the data as well
as my security check is done only once per rendering. This also saves
some queries
* Freeze options for rendering were inconsistent. It could be that
options on which rendering depends were not part of the cache key. Thus,
depending on the user who generated the generation of the rendering
function, there was or was not information in the template. For example
for automatic branding. This is no longer possible, because it is the
context that is used. The options serving as a cache key are only
recorded for information (for the profiling system for example). A
simplification of the `ir.qweb.field` models could be made.

The report rendering and call `ir.qweb` instead of `ir.ui.view`.

Part-of: odoo/odoo#85110
2022-03-29 10:56:15 +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 33114b9007 [IMP] stock: resize prod. form view fields
Some fields in the inventory tab of the product
form view had their input widget needlessly stretched
to the maximum available size.

closes odoo/odoo#84056

Task: 2654703-9
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-03-21 11:12:00 +01: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