Commit Graph
140847 Commits
Author SHA1 Message Date
Simon Lejeune 6fd05759e7 [REF] stock_account: remove old valuation code
The new code was sitting next to the old one, now that everything is
adapted (minus the cost method changes), we can remove the old one.

We also adapt the valuation wizard to use the stock valuation layer
action, now that the others are removed.

task-1875873
2019-06-10 20:42:59 +00:00
Simon Lejeune e93ede220d [REF] mrp_account: adapt to valuation layers
A finished move is considered as an incoming move and will pass by
_create_in_svl. We thus compute the price_unit that will be set on the
valuation layer.

We also set a stat button on the MO displaying the valuation
layers, similar to the one on the picking.

task-1875873
2019-06-10 20:42:59 +00:00
Simon Lejeune 5c62700698 [REF] stock_account: dropshipping valuation
We standardize the dropshipping by handling it as it was an receipt
directly followed by an out.

We also follow the same logic whatever the cost method, ie we don't run
fifo or update the AVCO.

task-1875873
2019-06-10 20:42:59 +00:00
Simon Lejeune 36f701e9d7 [REF] stock_account: add a small test for standard negative
task-1875873
2019-06-10 20:42:59 +00:00
Simon Lejeune c4f25ac615 [REF] stock_account: AVCO "negative" tests
Now that the vacuum is implemented and ran in AVCO, we can unskip the
old avco negative tests and implement new ones in
test_stockvaluationlayer to explain why we wanted to run the vacuum in
AVCO (see test_negative_1).

task-1875873
2019-06-10 20:42:59 +00:00
Simon Lejeune 54d1adf31a [REF] stock_account: fifo "negative" cost method with valuation layers
Re-implement _run_fifo_vacuum on the product this time with
float_is_zero and without remaining_value.

Trigger the vacuum at each receipt. Before it was done in the scheduler
each night, meaning the valuation on the move was not really
understandable nor consistent (the estimated value could be fixed by
some other move than the next receipt).

task-1875873
2019-06-10 20:42:59 +00:00
Simon Lejeune 8d21d0f888 [REF] stock_account: fifo "normal" cost method with valuation layers
We don't implement fifo negative handling in this commit.
We make sure we run fifo in average mode to get a proper remaining_qty
field.
`_run_fifo` is now a method on product (since it could be user outside
of a stock move context). It is really similar to its ancestor on the
stock move, with a few float_is_zero and compare more and a missing
remaing_value.

We move the valuation sanity check into a proper helper,
_sanity_check_for_valuation.

We complete the _create_correction_svl method with accounting entries.

task-1875873
2019-06-10 20:42:56 +00:00
Simon Lejeune 168f4d75ef [REF] stock_account: average cost method with valuation layers
One of the goal of this refactoring is also to run the vacuum when the
cost method is AVCO. This will be used allow already out landed cost
on AVCO and also to have a consistent value when going into negative.

We update `_prepare_in_svl_vals` to set the remaining_qty field that
will be used when fifo is implemented. On the stock move, we create the
layer in with the real price unit of the move and adapt
product_price_update_before_done. This method will now compute the AVCO
according to the quantity valued in stock (quantity_svl) instead of all
the quantities in stock (qty_available), which was wrong (qty_available
could contain consigned quants).

We also make sure to recompute the avco when editing a done move.

We don't implement yet the negative handling as we'll need fifo for
that.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 6127608cae [REF] stock_account: standard cost method with valuation layers
Valuation of standard move: We introduce _create_in_svl and
_create_out_svl and call these method in _action_done only on the
standard move, the other valuation methods still use the old code. We
hijack _account_entry_move to create journal entries anyway for the
valuation layer with a minimal diff. Helpers for the valuation layers
creation are added on the product because we will need to create similar
layer without stock move later on when we'll implement changes of cost
method. We also make a first implementation of the edition in the past
to make some tests pass, it will be completed with other cost method
implementation

Change of standard price: Before this commit, the wizard to change the
standard price was only displayed in perpetual, because it was used to
create accountign entries. We also use this wizard in manual now,
because we want to create a stock valuation layer. Fortunetaly, the
accounting fields of this wizard are not required if the product has a
manual valuation. And the new method is private.

We adapt the existing tests as well as we can and include the start of a
new battery of tests: test_stockvaluationlayer.py

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune fb65f8c916 [REF] stock_account: minor lint in account_move.py
task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 2c77efb05c [ADD] stock_account: stock valuation layer
This commit brings the model, views and compute method for the value and
the quantity valued. An ir rule prevents to read the value of another
company. Stat button are added on done picking to access the generated
layers.

Further commits will adapt one by one the cost method to actually use
the stock valuation layer when

As the goal is to move the valuation fields away from the stock move, we
set the necessary fields on the layer. Note the absence of `remaining_value`.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 7a27d52d71 [REF] stock_account: refactor _is_* helpers
Before this commit, there were the `_is_in`, `_is_out`, `_is_dropshipped`
and `_is_dropshipped_returned` helpers on stock move. These methods were
called on the stock moves upon their validation to know if they should
be valued.

But the valuation of a stock move actually depends on its move lines[0].

These helpers weren't convenient enough since every cost method should
implement the logic to get the valud quantity (see _run_valuation and
_run_fifo).

We add helpers returning in and out move lines and `_is_in` and
`_is_out` to use these helpers to decide their return value.

We also expose a list of valued type (`_get_valued_types`) that will be
used in the move validation to check every `_is_*`helper without calling
them explicitely. Once we'll know the valued type of each move to
validate, we'll be able to call the methods actually doing something
with the valuation in batch. We prepare this in _action_done to lay the
foundation of the batch calls when the stock valuation layer will be
implemented.

We took the opportunity to fix an edge case of the consignment: if the
owner of a move is the company of the move, it should be valued.

[0] 48f4ce4afa

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 977169feeb [REF] stock_account: unit price of rereturn
`_get_price_unit` is used to get the price to value a stock move and
returns `unit_price` if present (most of the times it is set by purchase_stock
to copy the price unit of po line) or the standard price.

Note that a return copies the original move and `price_unit` is set as
copy False.

Before this patch, a return of a return used the standard price (due to
the copy False), which doens't bring any issue but could be confusing
as explained in the following receipt scenario.

On a receipt, return and rereturn. The original and rereturn move may
not have the same price if the standard price has changed between the
operations, which is weird since there's a unit price on a potentially
linked po line.

On an delivery, there won't be any effect since the valuation methods do
not use the result of `_get_price_unit` but force it to the standard
price (standard and avco) or run fifo.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 0477bdb75a [REF] product, stock_account, etc: remove product.price.history table
This table tracked standard price changes.
It was used to compute the valuation at date in AVCO and standard
through `get_history_price`.

The next commits will introduce the stock valuation layers, separating
the valuation from the stock move. As a valuation layer will be created
when a standard price is updated on the product or when a stock move
impacts the valuation, the information from this table will be
duplicated.

We don't plan to adapt `get_history_price` to work with the valuation
layer since the valuation report at date and today will be the same: a
grouped list on the valuation layers with eventually a domain on the
date.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 72693c1d0a [REF] stock_account: make property_stock_journal required in the view
As journal_id is required on an account move, this field should not be
treated differently as the other accounting fields on this view.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune f30ca1687d [FIX] purchase_stock: don't call _is_dropshipped on an empty recordset
We will enforce an `ensure_one` in a further commit.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune f81eb396e9 [REF] stock_account: stock move to its own file
No changes on the code. Actually a rename of `stock.py`.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune e9ca33de8d [REF] stock_account: stock picking return to its own file
No changes on the code.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune d6b3536119 [REF] stock_account: procurement group to its own file
No changes on the code.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune da983190c8 [REF] stock_account: stock move line to its own file
No changes on the code.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 95b4fd1a25 [REF] stock_account: stock location to its own file
No changes on the code.

task-1875873
2019-06-09 14:11:36 +00:00
Simon Lejeune 806d0a52a1 [REF] stock_account: stock inventory to is own file
No changes on the code.

task-1875873
2019-06-09 14:11:36 +00:00
Robot Odoo 5c0f4e8122 [MERGE] sale_rental: new renting application
New Rental App (sale_rental) : community side.

1. Product configurator:
Refactoring to ease product configurator extension (e.g. rental configurator)
Closes #33371

2. Event_sale
Fix tests of event configurator s.t. they still work when sale_rental is installed (with its extension of the product configurator).

3. Sale
XML names for XPath in rental extension
Minor UI changes

[Enterprise PR](https://github.com/odoo/enterprise/pull/3939)

Related to #30855
Task 1909410

closes odoo/odoo#32210

Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2019-06-09 01:43:44 +02:00
Nicolas Martinelli a25f6e1b96 [FIX] sale: recompute delivered qty
- Create a product A of type "Service", Invoice based on "Milestones",
Service Tracking "Create a task in a new project".
- Create a new SO with A, confirm.
- Go the to task associated to the SO, go to "Timesheets" tab, add an
entry
- In the SO, edit the delivered quantity
- Create invoice, validate

Back to the SO, delivered quantity is reset to 0.

We make sure to filter out SO lines which have a delivered quantity set
manually.

Introduced by d6ad22227c.

opw-1982020

closes odoo/odoo#33991

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-06-07 14:20:35 +00:00
Odoo Translation Bot 34ae29e68b [I18N] Update translation terms from Transifex 2019-06-09 03:07:58 +02:00
Lucas Lefèvre 92d0419467 [FIX] hr_holidays: Display approve button when needed
This commit reverts commit 492764c

*Note for forward port*
This commit will conflict with 76ee0af. Keep this version.

TL;DR: the fix had unintended effects and the original problem has been
fixed by b5c2004 in the mean time.

Why the original commit?
------------------------
To know if the current user has the rights to approve/delete a leave,
two boolean fields are computed (respectively `can_approve`
and `can_reset`). Associated buttons are shown in the form view according to
the field values.
In the compute methods, the `check_approval_update(state)` method is called.
This method checks various conditions, including `ir.rules` by calling the ORM
method `self.check_access_rule('write')`. If one condition or one `ir.rule`
is not met, an Error is raised.

If the method raises, the user does not have the rights.
The exception is catched and the field `can_approve|reset` is set to False.

However, an unexpected behaviour happens when fields are re-computed
in the context of an onchange. In an onchange, `self.ids` is an empty list.
When checking ir.rules, the `_filter_access_rules()` method is used
to retrieve valid records in self by checking every record against ir.rules.
If some records are not in the valid set, they are considered invalid and an
exception is raised.
But because self.ids is empty, no record is actually checked and therefore
no record is valid.
=> in an onchange it always raises an AccessError and the users is considered
as not having the rights to approve nor refuse a leave as soon as an
onchange has been triggered. Thus associated buttons does not appear.

The original commit fixed the problem by preventing checking the rules
when in an onchange.

In the mean time, the root cause of the problem has been fixed by b5c2004.

Why revert?
-----------
While commit 492764c allowed HR users and Team leaders to approve
after an onchange, it had the unintended effect to
show the "Approve" and "Refuse" buttons to other users.
In summary:

- With commit 492764c: buttons are shown more than necessary
(which is confusing to users who don't actually the rights
to approve)

- Without: Thanks to b5c2004, the original problem no longer exists.
Users with access rights always see buttons. Users without never see
buttons.

closes odoo/odoo#33894

Signed-off-by: Romain Libert (rli) <rli@odoo.com>
2019-06-07 13:10:05 +00:00
Victor Feyens 9cfe599973 [FIX] event_sale_product_configurator: remove files brought back by conflict 2019-06-07 11:33:42 +00:00
Christophe Simonis a2582c4252 [MERGE] forward port branch 11.0 up to bdc62d8031 2019-06-07 13:00:07 +02:00
Christophe Simonis bdc62d8031 [FIX] test_lint: move custom pylint checkers to new module
Oversight of previous forward-port.
2019-06-07 12:08:29 +02:00
Christophe Simonis 9bf4766f3d [MERGE] forward port branch saas-15 up to 6c6e652673 2019-06-07 11:38:48 +02:00
Christophe Simonis 6c6e652673 [MERGE] forward port branch saas-14 up to 757846c591 2019-06-07 11:09:29 +02:00
Christophe Simonis 757846c591 [MERGE] forward port branch 10.0 up to 7746621b92 2019-06-07 11:08:13 +02:00
Nicolas Martinelliandjev-odoo b5a04fd29f [IMP] mail, website_mail, base: extra info on error messages
Display extra information on error messages:
- Access error based on ACLs: user, fields (if applies)
- Access error based on record rules: user, ids
- Missing error: model, operation, user, ids

closes odoo/odoo#33942

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>


Co-authored-by: jev-odoo <jev@odoo.com>
2019-06-07 06:38:06 +00:00
Christophe Simonis b4337f57d7 [MERGE] forward port branch saas-15 up to ec8cfd5624 2019-06-18 10:59:18 +02:00
Odoo Translation Bot ca8b354cc1 [I18N] Update translation terms from Transifex 2019-06-16 03:07:16 +02:00
Julien Castiaux 45bd7a58d5 [FIX] website_sale_comparison: concurrent add/delete
1) Add a 1st product to compare from the ecommerce /shop page.
2) Open the compare list pop up at the bottom.
3) Add a 2nd product to compare from the /shop page.
4) Remove the 1st product from the compare list before the rpc of the
2nd product is done.
5) Javascript error `self.product_data[res] is undefined`

The function `add_new_products` and `rm_from_comparelist` are
concurrent, they both modify the internal `comparelist_product_ids`
product list. The first one perform an RPC and delay the update once the
request is done, the second does the update immediately.

The solution has been to use a mutex to exclude the two functions.

opw-1974108

closes odoo/odoo#33302

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-06-14 09:02:09 +00:00
Lucas Perais (lpe) 187b77d7b9 [FIX] product: report pricelist empty data
Try to get the report_pricelist with empty data
(Studio Report editor can)

Before this commit, it crashes because we tried to access dict keys directly
in an empty dict

After this commit, it doesn't crash

OPW 2009862

closes odoo/odoo#34118

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-06-14 08:05:33 +00:00
ThanhDodeurOdoo 66e2aeb660 [FIX] tools: image.crop_image default type fix
Backport of fa39019ee1.
If crop_image is called without a default format, it would try the default,
'PNG', to save the result and crash at save when processing non-PNG images.
For example, if a jpeg image was in CMYK colors.

Here it will still crash non-gracefully when failing to save, but the default
should almost always work; if it doesn't it means we failed to detect the format
of the stream, so it is unlikely that we could save the image anyway.

opw 2009029

closes odoo/odoo#34088

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
2019-06-13 16:05:34 +00:00
Nicolas Martinelliandjev-odoo fa492d87f4 [IMP] mail, website_mail, base: extra info on error messages
Display extra information on error messages:
- Access error based on ACLs: user, fields (if applies)
- Access error based on record rules: user, ids
- Missing error: model, operation, user, ids

closes odoo/odoo#33945

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>


Co-authored-by: jev-odoo <jev@odoo.com>
2019-06-07 06:37:25 +00:00
Lucas Lefèvre 6b93738299 [FIX] test_assetsbundle: Properly unpatch ir.attachment
`_patch_method` and `_revert_method` do not work properly.
This commit fixes a test which patches `create` and `unlink`
of `ir.attachment`.
The methods are not correctly unpatched.

One consequence:
if a module is installed after this test is executed and
the new module overrides `create` and `unlink`, the overritten
methods are never called.

closes odoo/odoo#33952

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-06-06 14:23:28 +00:00
Odoo Translation Bot bafe82309a [I18N] Update translation terms from Transifex 2019-06-09 06:06:20 +02:00
Lucas Lefèvre 12ace54a9f [FIX] hr_holidays: Fix out of office message default value
If a user has an ooom in his Preferences, it should be
used as the default value for a leave ooom.

closes odoo/odoo#33890

Signed-off-by: Romain Libert (rli) <rli@odoo.com>
2019-06-07 12:51:02 +00:00
Lucas Lefèvre 8dff37f3ec [FIX] hr_holidays: Fix out of office message edition
Purpose
=======
Currently, the ooom field is editable in the leave view but an ir.rule
prevents the employee to save as soon as the leave is approved.

Specification
=============
An employee should be able to edit the out of office message
even if the leave is already approved.
2019-06-07 12:51:02 +00:00
Cedric Snauwaert cc6cc7ae8b [FIX] account: remove the warning in reconciliation widget for to_check
The goal of the to_check checkbox in the reconciliation widget is to set the to_check field present on the move that will be created. However since the UI is not perfect, the to_check checkbox was added on the wizard when we create a new line in the widget, which cause the following problem: what if we select to_check on line1 and then deselect it on line2, previously it was not possible to do this, a warning was thrown to tell the user that he had some line with to_check set and some other not. A better way to do this, and more user friendly is by preventing the user from deselecting the checkbox if some other line has the to_check value set.

closes odoo/odoo#33956

Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com>
2019-06-07 09:15:43 +00:00
Rishabh Jadia 7746621b92 [FIX] base: prevent renaming the column for non stored field
Before this task, when creating the related field from the studio, it is by
default stored. When we change the field name in 'ir.model.fields' using ORM's
write method, it also renames the column in the table associated with the
field's model.

This is the expected behavior. But when someone tries to change the 'name' of a
non stored field, the column is not available in the associated model, and so
trying to rename the column results into traceback. This issue was probably
there for a while but came into light with the task 1985710. More info can
be found on the chatter of the task.

This commit fixes the issue by adding an extra check before renaming the table
column. The query will be executed only when the field is stored and thus
exists in the table.

closes odoo/odoo#33944

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-06-06 11:47:19 +00:00
wan e358c41313 [FIX] account: manual reconciliation no data
The function get_all_data_for_manual_reconciliation got an empty list instead of None. This leads to not query the db. However we want to get results in the default behavior for get_all_data_for_manual_reconciliation

closes odoo/odoo#33711

Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com>
2019-06-06 10:26:42 +00:00
Nicolas Martinelli f7b870ca1b [IMP] account: constraint error message
Make SQL constraints errors more accurate.

closes odoo/odoo#33934

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-06-06 08:34:00 +00:00
Barad Mahendra ef7ae9ae14 [FIX] base: avoid traceback on params field of client action
The content of these fields can't be updated, there's no reason to
even show them. Just remove them from the default / auto-generated
view for client actions.

Task 1772242

closes odoo/odoo#29179

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-06 10:10:12 +00:00
Goffin Simon d1a5ce02dc [FIX] hr: Impossible to change job_id in hr.employee
The field job_id is displayed in the tree view but it was not available in the form view
like in 12.0. So it was not possible to change it.

opw:2006084

closes odoo/odoo#33933

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2019-06-06 08:16:12 +00:00
Victor Feyens 1f0721acf0 [FIX] Purchase description string 2019-06-06 06:52:26 +00:00