Commit Graph
47 Commits
Author SHA1 Message Date
Walid 1fb4d356b5 [FIX] mrp_account: AVCO product valuation with component cost 0
Steps to reproduce:
- Create a manufactured product P with AVCO valuation
- On the bom of the previous product add a component C with unit cost 5$
- Manufacture product P (Unit cost correct so far 5$)
- Change component cost to 0 and manufacture again
- Unit cost of P is still 5$ were it should be 2.5$

Bug:
since the move unit price is 0 the standard price of the product P is
used insted for the valuation of the newly created qty

Fix:
force unit price to 0 in the case of manufacturing

opw-3374462

closes odoo/odoo#132047

X-original-commit: f6c2b5368e3abdc292e66dc04efc4031eb12f742
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
2023-08-16 17:48:19 +02:00
Touati Djamel (otd) 5e4dbe2616 [FIX] stock_account: remove AAL when changing qty of the component to 0
Steps to reproduce the bug:
- Create a storable product “P1” with BoM:
    - Component: "C1", cost: $100
- Create a Manufacturing Order to produce 1 unit of "P1":
    - Set any analytic account
    - Confirm and validate the MO
- An analytic account line is created for $100 of C1.
- Change the quantity of the component to 0.
- Try to save

Problem:
A traceback is triggered, because the `amount` and `unit_amount`
variables are used without assignment.

Solution:
Assign “0” value to both variable in the beginning of the function,
therefore the analytic account line will be deleted.

opw-3257240

closes odoo/odoo#128495

X-original-commit: 513e3dea2c838bb6f805c567069ea39406c6634e
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-07-15 12:00:07 +02:00
Pieter Claeys (clpi) f13d537a42 [IMP] mrp: New analytic for MRP
The (legacy) analytic account field on MOs, BOMs and workcenters has
been replaced by the new "analytic distribution" field.

The analytic line items are now created based on this distribution for
the raw materials, workcenter costs and employee costs.

A new analytic applicability (=domain) has been added for manufacturing
orders as well.

Community PR: https://github.com/odoo/odoo/pull/116477
Enterprise PR: https://github.com/odoo/enterprise/pull/38690

closes odoo/odoo#116477

Task: 3196563
Related: odoo/upgrade#4704
Related: odoo/enterprise#38690
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2023-06-23 17:59:57 +02:00
Walid 35d84b0c27 [FIX] mrp_account: remove related analytic line when WO is deleted
Steps to reproduce:
* Create an analytic account
* Create MO with Analytic Account
* Create WO on MO
* Create Time Tracking on WO
* Delete the WO

Bug:
The analytic line related to the work duration remains on the Account

Fix:
Remove the lines when the WorkOrder is deleted

opw-3174736

closes odoo/odoo#124014

X-original-commit: 59ebf21d126d9d5c93e97e6b404b23270050aa6f
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
2023-06-07 12:02:12 +02:00
Pieter Claeys (clpi) 4b5fb81084 [FIX] mrp: Update analytic lines when changing account on MO
Upon changing/removing/adding the analytic account on a manufacturing order, only the analytic lines due to the raw material moves are updated, but not the ones for workcenter costs.

To reproduce:
- Create an MO with a workorder on a workcenter which has an operating cost set
- Complete time on this workorder to generate the [WC] AALs on this MO
- Change the analytic account on the MO (or delete it)
  Bug: The [WC] AALs never get correctly updated.

This fix builds on https://github.com/odoo/odoo/pull/79614 to correct this behaviour and also take into account changes for the workcenter cost AALs when the analytic_account of a manufacturing order is changed.

Community PR: https://github.com/odoo/odoo/pull/117308

closes odoo/odoo#122396

Task: 3252742
X-original-commit: 35e3af77051d1dfdf54600b607acfb593aa49e34
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Claeys Pieter (clpi) <clpi@odoo.com>
2023-05-25 16:29:50 +02:00
William Henrotin 5e5d92ef79 [IMP] stock: picking flow reworked
This commit changes the process flow of stock pickings. A new picking will
always be created in immediate transfer mode and 'ready' state. From
their, it can be validated directly or 'reset to draft'. This second action
switch the immediate mode to planned mode and reset the state as draft.
From their the classical workflow is processed
confirm -> (assigned ->) validated

Task: 3256447
Part-of: odoo/odoo#117513
2023-05-17 13:37:47 +02:00
clesgow 2f73020e08 [FIX] mrp: replace workcenter times when specific capacity is defined
Currently, when a specific capacity is defined for a product in a
workcenter, if a setup / cleanup time is given, it will be added to the
existing setup / cleanup time of the workcenter.

What we want instead is to be able to fully define what the
setup/cleanup time is for this specific product. So the given times in
the specific capacity override the times defined in the workcenter for
that specific product.

To help with that, we set the workcenter's setup/cleanup time as a
default for their related specific capacities, since if not changed,
they will follow the workcenter times.

Updated the tests so their specified capacities match the new behaviour.

closes odoo/odoo#119212

Related: odoo/upgrade#4576
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-15 18:50:16 +02:00
stcc-odoo 03aa724125 [FIX] mrp{_account}: consider capacities when computing duration
Related enterprise PR: odoo/enterprise#39669

Steps to reproduce:

Install mrp_workorder
Create Product P1, Workcenter W1
Edit W1 > Specific capacities > Add line: Product = P1, Start time = 5, End time = 5
Create BoM > Product: P1, Operations tab > Add line: Workcenter = WC1, Default duration = 60:00 min > Save
Click on overview stat button
Issue:

The created operation has expected time of 60:00, instead of 70:00. The workcenter start and stop times are considered in this calculation, so the workcenter capacities should be considered too.

Solution:

Use `_get_expected_duration` to compute the expected duration.

opw-3229485

closes odoo/odoo#121060

X-original-commit: 7b5a30fb3e51434154050052ec39ed299c6094d3
Related: odoo/enterprise#40905
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-11 09:36:29 +02:00
yhu-odoo 1eb2e7c814 [IMP] {,mrp_,stock_}account, *: add default stock accounts and production cost
account

1. We introduced a new Production Cost account that can be set on
locations with Production type. When products move into/out of a
production location. The account entry will be post on this account
instead of previous Stock in/out account.

2. On the accounting setting page, we can now set the default values for
all stock accounts. Users can also disable automatically accounting for
stock there.

Task-3046333

closes odoo/odoo#113973

Related: odoo/enterprise#37653
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-10 15:19:32 +02:00
Adrien Widart (awt) 4bccbb175f [FIX] {stock_,}account, stock_landed_costs: set categories properties
When a product category valuation is set to `real_time`, we use the
stock accounts. However, in the code, to know which account we
should use, we do: "use stock accounts if defined, else use basic
ones" (the best should be "use stock accounts if `real_time`" but
this refactoring task will be done in master). So, here, we need to
ensure that stock accounts are not defined when the valuation is manual.

This is the case when installing `stock_account` module: the
valuations will be set to manual, so we need to force the stock
accounts to `False`. Same when creating a new company, we also need to
ensure that the stock accounts are not defined. This explains the
changes in `_post_load_data`

About changes in `_check_valuation_accouts`, the explanation is in
the method body: the defined values directly depends on the value of
`property_valuation`

Note about test modification: for the tests in `stock_landed_costs`
module, we set the categ to auto so the stock accounts are defined.
Otherwise, when validating the landed costs, it will lead to an error
https://github.com/odoo/odoo/blob/9cd316f038dc95051814ede9474f8f15f7d165df/addons/stock_landed_costs/models/stock_landed_cost.py#L396-L397

OPW-2746384

X-original-commit: 2780c37cfdb8560ac7c725fd27f4fe272f1d3072
Part-of: odoo/odoo#119564
2023-04-26 17:06:13 +02:00
Antoine (ande) ce0e1c095d [FIX] mrp_account: no currency in analytics
Current behaviour:
Cannot add a Work Order to a Manufacturing Order
if the analytic account linked to the MO doesn't
have an associated company.

Expected behaviour:
Should be able to add a WO to a MO even
if the linked analytic account doesn't have
an associated company.

Steps to reproduce:
1. Activate analytic accounts
2. Activate work orders
3. Create an analytic account without company associated
4. Create a Manufacturing Order
5. In miscellaneous, link the analytic account
6. Try to add a WO line
7. Error log

Reason for the problem:
When trying to add a WO line, if the MO has been linked
to an analytic account, it checks for the currency in
the company in the analytic account, which was not
existent, since the company didn't exist.

Fix:
When trying to access currency, if the company in the analytic
account doesn't exist, it defaults to the company in the WO.

opw-3210708

closes odoo/odoo#117708

X-original-commit: f0d8f5e82e62e0bcfc05e25dac2504f8f07537f4
Signed-off-by: Demany Antoine (ande) <ande@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-04-05 09:42:37 +02:00
Raphael Collet c1d2e712f2 [FIX] mrp: tests with Form on 'mrp.production'
Add the group 'mrp.group_mrp_routings' on the main user to make field
'workorder_ids' visible in the form view of 'mrp.production'.  Many
tests use that view, and require the subviews of that field to be
present in order to create records.

closes odoo/odoo#116779

Related: odoo/enterprise#38858
Related: odoo/documentation#3968
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-03-31 17:02:44 +02:00
Adrien Widart (awt) d645518638 [FIX] stock,{stock,mrp}_account: add SML with kit to draft picking
If account is installed, it is not possible to scan a kit and
validate the picking

To reproduce the issue:
(Need stock_barcode_mrp)
1. Create two products P_kit, P_compo:
   - P_kit:
     - Barcode: 123
2. Create a kit-type BoM
3. Barcode > Operations > Receipts, Create
4. Scan 123
5. Validate

Error: an error message is displayed ("Record does not exist or has
been deleted")

When validating the receipt, it creates the SML_kit and its SM_kit.
Both are in draft state. So, we validate SM_kit. In
`/stock_account._action_done`, we add SM_kit to a dict
(`valued_moves`) and we then call the `super` method:
https://github.com/odoo/odoo/blob/33fa9cff038691a98ca840fe0d72484da16276ba/addons/stock_account/models/stock_move.py#L244-L257
In `/stock._action_done`, because of the state of SM, we confirm it:
https://github.com/odoo/odoo/blob/24f2e3f73498e5eb180a6793de6c25efd414aadb/addons/stock/models/stock_move.py#L1517-L1518
And, therefore, we explode SM_kit:
https://github.com/odoo/odoo/blob/5f8da70b5b1f313e9b676846e55e84621f55e734/addons/mrp/models/stock_move.py#L239-L240
This creates SM_compo and unlink SM_kit. However, there are two issues:
- In `/stock._action_done`, we don't keep any reference to SM_compo.
  The method will not return it and `/stock_account._action_done`
  will not create any layer, if needed, for that SM_compo
- In `/stock_account._action_done`, we don't consider that SM_kit
  may have been deleted. As a result, we keep using it:
  https://github.com/odoo/odoo/blob/33fa9cff038691a98ca840fe0d72484da16276ba/addons/stock_account/models/stock_move.py#L266-L271
  This is the reason why an error will be raised

OPW-3015933

closes odoo/odoo#108762

closes odoo/odoo#112814

X-original-commit: c78666e3fbd06bc7a7899ccaa6e562bf3072e955
Related: odoo/enterprise#37137
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2023-02-16 11:35:50 +01:00
JF Aubert 0cdf410a44 [IMP] mrp: Remove mrp.immediate.production model
closes odoo/odoo#108446

Task: 3094741
Related: odoo/upgrade#4163
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-11 13:20:48 +01:00
yhu-odoo 0961a54eca [IMP] mrp_account: adapt tests
Adapt tests for other moudules to use

ENT PR odoo/enterprise#33399

X-original-commit: 88cad50cac8130e1ff66a21ab63d53b41488a74a
Part-of: odoo/odoo#106007
2022-11-18 14:00:11 +01:00
yhu-odoo ba4e24b932 [FIX] mrp_account: missing employee cost when calculate bom cost
Adapt community to make it possible to add employee cost when calculate
bom cost.

closes odoo/odoo#105645

X-original-commit: a239802249b2af2cc3fc2b3bb9fdfd0a408d887a
Related: odoo/enterprise#33898
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Yuchen Huang (yhu) <yhu@odoo.com>
2022-11-14 13:01:57 +01:00
Walid HANNICHE (waha) fd17d80efd [FIX] mrp_account: include time effeciency in bom price
Steps to reproduce:
- set time effeciency of a workcenter to less than 100
- on a product page with a BoM using that workcenter
- for the cost click on compute price from BoM

Bug:
workcenter effeciency is not taken into consideration

Fix:
included time_effeciency in computing the expected duration
addepted tests to take it into consideration aswell

opw-3033672

closes odoo/odoo#104566

X-original-commit: 1dcd9dbef0a5e6d9bd2c5e52a42cff9aec98f1d0
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
2022-10-28 22:44:49 +02:00
gawa-odooandHabib 7e3403068f [REF] *: Analytic Apocalypse
The goal of this commit is to get rid of the analytic tags as they were confusing, serving tag purposes as well as distribution on analytic accounts.

Everywhere analytic tags were used as a distribution have been replaced with a new widget that will dispatch distribution on analytic accounts. If there was an analytic account field next to the tags, it has been included in the distribution.

Analytic tags that were used simply as information tags have been removed.

To fill the new widget, there are now 2 kind of rules that will help fill and prefill it.
The first are applicability: previous groups have been removed, and have by replaced by plans. Each account is required to have a plan. These plans define when they are available in the widget: a default applicability per plan and applicability lines that can specify rules following the context of the widget.

The second one are distribution models, that will replace previous default rules but follow the same principles. The accounts (and so the plans) that will be given by the distribution model can override the applicability rules from before.

closes odoo/odoo#98914

Related: odoo/upgrade#3885
Related: odoo/enterprise#30743
Signed-off-by: William André (wan) <wan@odoo.com>
Co-authored-by: Habib (ayh) <ayh@odoo.com>
2022-09-20 12:36:01 +02:00
william-andre d8d47f9ff8 [REF] accounting v16. Yeeeeaah
TLDR:
* invoices are implemented using computed methods instead of onchange
* the synchronization only happens when switching tabs in the Form view
  to improve perfs.

_______________________________________________________________________

The whole engine of the synchronization of Invoices to the Journal
Entries has been refactored
* by using computed fields instead of onchange functions
* by synchronizing only from invoice to journal entry in `create` and
  `write`
* by saving when switching tabs on the Invoice form, to synchronize
  before showing the values

This comes with numerous advantages:
* no need to call the onchange methods manually
* no need to use the Form emulator to build invoices (i.e. EDI, OCR,
  intercompany, ...)
* the performance for invoices with many lines improves drastically, going
  from 2 minutes to 4 seconds to create an invoice with 500 lines
* the model is more declarative, we can now see how the values are computed
  instead of having the values being copied from various places.
* remove the hack in `onchange` that disabled the recursivity of it,
  which was unexpected and needed to be managed manually in all the
  onchange methods

This means that:
* Some fields need to be exclusively computed on journal entries values
  or invoice values, more specifically the Tax Summary widget.
  It is now
    - computed from entry lines, when opening the view
    - computed from invoice lines when changing those, because the tax lines
      will need to be recomputed anyways, erasing previously set values
    - set with an inverse function when saving; after the sync has been done
* Some possible operations previously possible have been dropped.
  (i.e. look at the removed test test_in_invoice_line_onchange_accounting_fields_1)
  This is because such a behavior was undefined (how is changing the balance going
  to affect the unit price? How is the amount currency going to affect it?)

_______________________________________________________________________

Implementation Details
----------------------

The "dynamic lines", meaning the payment terms and the tax lines are now
only created in the `create` and `write` functions.
In order to reduce code duplication, it has been implemented using
context managers used in both `account.move` and `account.move.line`
These context managers help comparing the values before/after, acting
like a local `onchange`, but getting benefit from the dirty flags from
the `compute` dependences.
This is relying on computed fields on the move (`needed_terms`) and on
the lines (`compute_all_tax`) which contain the values needed for the
related move.
Depending on the needed values and the existing values (`term_key` and
`tax_key`, respectively) the context manager will determine what needs
to be created/updated/deleted.

Some related changes are to produce a `dict` instead of a `str` for the
`tax_totals` (previously `tax_totals_json`) fields, by simplicity to
reduce the complexity of IO, and simplicity of debugging, because the
logic of the field needed to change (cannot be computed at the same time
anymore since it needed the lines to be synced)

By simplicity, and also because it makes more sense, some boolean fields
have been merged into `display_type`:
* `is_rounding_line`
* `exclude_from_invoice_tab`
* `is_anglo_saxon_line`

The `price_unit`, `quantity` and other "invoice fields" are now not set
anymore on lines that are not product lines since it didn't make any
sense to have it.

Performances
------------

You have to keep in mind that a simple `create` didn't compute a lot of
fields, for instance not taxes were set, no payment terms,...
Now it does.

```python
import random
from timeit import timeit
from odoo import Command
domain = [('company_id', 'in', (False, self.env.company.id))]
products = self.env['product.product'].search(domain).ids
partners = self.env['res.partner'].search(domain).ids
taxes = self.env['account.tax'].search(domain).ids
def create(nmove, nline):
    self.env['account.move'].create([
        {
            'move_type': 'out_invoice',
            'partner_id': random.choice(partners),
            'invoice_line_ids': [
                Command.create({
                    'name': f'line{i}',
                    'product_id': random.choice(products),
                    'tax_ids': [Command.set([random.choice(taxes)])],
                })
                for i in range(nline)
            ]
        }
        for j in range(nmove)
    ])
                                                             # After  | Before
print(timeit("create(1, 1)", globals=globals(), number=1))   # 0.11   | 0.09
print(timeit("create(100, 1)", globals=globals(), number=1)) # 2.76   | 2.50
print(timeit("create(500, 1)", globals=globals(), number=1)) # 14.56  | 12.34
print(timeit("create(1, 100)", globals=globals(), number=1)) # 1.03   | 5.52
print(timeit("create(1, 500)", globals=globals(), number=1)) # 3.99   | 125.02
print(timeit("create(50, 50)", globals=globals(), number=1)) # 19.44  | 79.55
```

Another metric that can be used is running the test suite with
`--test-tags=/account` (only `account` installed)
* before: 404s, 267127 queries (366 tests)
* after: 318s, 232125 queries (362 tests)

Why this commit title?
----------------------

Someone told me that this was the perfect way of naming your commits.
c04065abd8

task-2711317

closes odoo/odoo#96134

Related: odoo/upgrade#3715
Related: odoo/enterprise#29758
Signed-off-by: Laurent Smet <las@odoo.com>
2022-08-03 13:44:49 +02:00
aliya 26b2472f49 [IMP] account: refactor account types
Task: 2856281

- Remove user_type_id, account.account.type model, internal_type
- Add account_type that is a simple selection field
- Move internal_group and include_initial_balance to account.account
- Because of these changes, type_control_ids on account.journal is also removed

closes odoo/odoo#93212

Related: odoo/documentation#2223
Related: odoo/upgrade#3595
Related: odoo/enterprise#28205
Signed-off-by: Cedric Snauwaert <csn@odoo.com>
2022-07-08 19:52:15 +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
JF Aubert fcc7b3d46a IMP] mrp: add workcenter capacity per product
Allow workcenter capacities based on product instead of
applying the same capacity for all.

closes odoo/odoo#87131

Task: 2691328
Related: odoo/enterprise#25532
Related: odoo/upgrade#3370
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-06-03 16:40:09 +02:00
Arnold Moyaux d7716f071d [REF] mrp: onchange to compute
This task will:
- Clean the code (e.g. the production's moves are now created directly)
- Have the same behavior when creating object in the UI or directly in
backend

It's mainly on the `mrp.production` object and most of the computed
stored field are used as default value or act like an onchange on draft
production. Once the production order is validated, it's only modify
by direct write

Task-2709753

closes odoo/odoo#83576

Related: odoo/enterprise#24405
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-04-22 12:04:23 +02:00
yhu-odoo 8d0b087525 [IMP] mrp: enable manual consumption on components
Currently, when changing qty_producing on a MO, consumed number of each
component will always be updated. In this commit, we add a new boolean
field manual_consumption to bom.line. If checked, that line won't be
updated when changing qty_producing.
The same but invisible field manual_consumption is also added to each
line on MO. It will use the value on BOM as defualt value. When user
manually set the consued qty, it will be checked automatically. Also,
when user manually update the SML, the field on SM will also be set to
true.

Task-2687494

closes odoo/odoo#80118

Related: odoo/enterprise#25607
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-03-31 17:24:44 +02:00
Touati Djamel (otd) dc8948d79c [FIX] mrp_account: Update the AAL when changing the MO analytic account
Analytic Accounts can be defined in the MO and can be changed in any MO stage. So the analytic account line will also have to be updated to be linked to the new AA

opw-2674347

closes odoo/odoo#79955

X-original-commit: 65a18382c1712968148898998e3778b77f199dea
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2021-11-18 08:37:45 +00:00
Rémy Voet (ryv) b33983d532 [REF] stock*,mrp*: clean setUp vs setUpClass
In a lot of test class, we use `setUp` instead of
`setUpClass`. `setUp` is execute for each test method and `setUpClass`
will be execute only once by Class (and use savepoint + rollback).

Then change setUp into setUpClass reduce the time to make all tests
and avoid to repeat this error for the future.

closes odoo/odoo#78082

Related: odoo/enterprise#21563
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-10-13 18:24:16 +00:00
Rémy Voet (ryv) 6aa8b7dd67 [IMP] mrp_subcontracting: improve mrp bom report
- The "BoM Structure & Cost" takes now in account
the subcontracting cost.
The subcontracting cost depends of the best supplier info in product
and subcontractor register in the BoM.
- Also add this subcontracting cost (to the cost field) when we click on
"Compute Price from BoM" in the product view.

task-2486811

Part-of: odoo/odoo#75041
2021-09-03 10:37:46 +00:00
yhu-odoo 45912aaebd [IMP] analytic, project, *: Improve views
Improve the views of analytic.account and project.project.
Add category to analytic.line.

Task-2469742
PR #68708
2021-08-27 16:40:49 +00:00
yhu-odoo edacd76e21 [IMP] mrp_account: analytic accounting on MO
Add analytic accounting for MO.

Post expense entries for:
  1. raw material cost (change with consumed)
  2. work center cost (change with real duration on work order)

Task-2469742
PR #68708
2021-08-27 16:40:49 +00:00
Tiffany Chang (tic) fd52760266 [IMP] mrp(_account): include byproduct cost share in BoM/MO
For improved cost analysis, byproducts can now have a "cost share" (out
of 100%) indicated. This cost share will by multiplied by the total BoM
cost (i.e. components + operations costs) and reflected in the stock
valuation. The final product will also have the byproducts cost
subtracted from its final stock valuation. This is of course only
applies when costing methods are appropriate (i.e. non-standard price).

Additionally, we can now "Compute Price from BoM" for byproducts (via
its product form) and the BoMs that it is a byproduct of are now counted
towards its # BoMs smart button (we will now also see these BoMs when
clicking on the smart button). Of course when there is no cost share for
byproducts then clicking on "Compute Price for BoM" will not change the
a byproduct's cost and if there are multiple BoMs the prodcut is a
byproduct of, the calculation will only be based on the first BoM it
finds (i.e. same as current logic for manufactured products).

BoM Cost report has been updated to include byproducts with cost shares
(byproducts with cost share = 0 will not show up in report).
Additionally we update the report to display operations only costs now
that BoMs are allowed to have no components in them.

Part 1 of Task: 2440068
Upgrade PR: odoo/upgrade#2727
Related ENT PR: odoo/enterprise#20169

Part-of: odoo/odoo#74951
2021-08-26 11:34:35 +00:00
yhu-odoo 2915ac1226 [IMP](stock,mrp)_account: use location valuation account
Previous fix f056254d1c5153467b10d9581214ff6d1348be76 didn't take the
situation when production location has its own valuation accounts into
consideration. Fix it in this commit.

opw-2476417

closes odoo/odoo#71064

X-original-commit: 60e83f03b871605b7aa281503269f66ac3ea940b
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Yuchen Huang <yhu-odoo@users.noreply.github.com>
2021-05-19 17:01:08 +00:00
Arnold Moyaux bdcb3d192b [REF] stock: move stock.inventory feature into stock.quant
This commit removes stock.inventory(.line) and moves its general
functionality into stock.quant. Some features are lost during this
switch as well.

Feature Additions:
- New single list view for inventory adjustments (no more multiple
  inventory adjustment records to keep track of!)
- Improved cyclic counts (annual inventory day setting) + next inventory
  dates are immediately viewable in view (vs auto-generated inventories
  based only on location)
- Specific quants (i.e. counts) can be assigned to users for more
  flexibility (vs only able to restrict by location + product
  combinations)
- Counts can be requested (i.e. bulk assigned to user/for a specific
  inventory date)

Feature Removals:
- Can no longer look at previous inventory adjustments linked to a
  specific record. Each quant has a history button to show inventory
  related moves. [relevant account moves are also now harder to see via
  stock as well]

Other changes:
- Bulk of changes were for demo/test
- Some changes were done to ensure "Update Quantity"/"Inventory Report"
  views still mainly function the same as before with the exception of a
  new column added to support updating quant quantities in these views.

Task: 2440026
ENT PR: odoo/enterprise#17329
Upgrade PR: odoo/upgrade#2326

closes odoo/odoo#68409

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-02 11:51:38 +00:00
fja-odoo 8c5e3af174 [IMP] mrp: remove batch from operations
This doesn't make sense anymore: when we record production on a WO, in
any cases everything is processed as we make backorders.

Part of: https://github.com/odoo/odoo/pull/54283
task-2278147
2020-08-18 12:46:54 +00:00
Arnold Moyaux ed7012e8fd [REF] mrp: workorders for enterprise
Removed abstract workorder

Removed the integration of expiry wizard in tablet view since it should
be moved in enterprise in the tablet view implementation (not possible
to set consumed lot on workorders on community anymore)

Refactor _set_quantity_done to use ORM command in order to not return a
dict with vals to_create/to_write

task-2241471
2020-06-15 16:59:41 +02:00
Rémy Voet (ryv) 5011ec520c [REF] mrp: review consumption allowing
Now, by default, a Bill of Material have a flexible
consumption instead of strict consumption. Also
add new consumption choice: a flexible consumption
but with a warning when the bom isn't respected.
Also, now, the strict (a new warning option) consumption
is checked only when we try to mark as done the MO.

task-2241471
2020-06-15 16:59:41 +02:00
William Henrotin 0e2765f5fd [REF] mrp: no more produce wizard
Use a view similar as the pickings one.

task-2241471
2020-06-15 16:59:41 +02:00
Simon Lejeune c660770ebd [REF] mrp: remove routing model
Set the operations directly on the Bill of Material.
Duplicate the demo data where a routing was shared.
Adapt the tests.

Remove the following feature:
    - set the same routing on parent and kit child bom
    - when planning, if the component of the kit have the same operation
      than a component of the parent bom, merge these operations

task-2241471
2020-06-15 16:59:40 +02:00
William Henrotin 9503f463e3 [FIX] mrp: always show post inventory button
The inventory button was shown or hide depending of the product valuation.
As the valuation was previously stored on the stock moves and posting
split the stock moves. Fifo and Avco valuation was not well computed.
The migration to stock valuation layer fixed this behavior. This
commit shows the post inventory button as soon as there are some
finished move to be posted.

task : 54665

closes odoo/odoo#41781

X-original-commit: 5dfa3f817d3a9f47a863a587569a862a40c7d159
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2019-12-10 12:41:06 +00:00
Debauche Stéphane 42d3a82a80 [IMP] stock_account: remove the wizard which change the `standard_price`
Overwrite the method ``write`` of the model ``product.product``.

When we write on ``standard_price``, if
- the context key ``disable_auto_svl`` is not set
- the ``cost_method`` is not "fifo"
We automatically compute ``stock.valuation.layer``

(before we needed to manually call ``_change_standard_price``)

Task #2031422

closes odoo/odoo#41265

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-12-06 10:58:03 +00:00
Yannick Tivisse 0e67a66111 [IMP] mrp_account: Avoid multi-executed tests
Some tests (test_00_workorder_process, ...) are executed several times, only
because we extend a test class to retrieve the setUp (or setUpClass) instead
of creating a common class.

This could lead to issues, (like for test_00_workorder_process) depending on the
installed modules.
2019-11-12 09:27:51 +00:00
Yannick Tivisse 102717c042 [IMP] mrp_account: Adapt tests to work with/without demo data 2019-11-05 13:08:03 +01:00
Julien Castiaux 4f03a5f136 [FIX] *: remove old deprecated modules/functions
PEP-594 is deprecating a bunch of modules. As part of the cleanup, we
are also dealing with long deprecated modules, functions and aliases.

* `assert_` -> `assertTrue`
* `assertEquals` -> `assertEqual`
* `assertNotEquals` -> `assertNotEqual`
* `assertAlmostEquals` -> `assertAlmostEqual`
* `assertRaisesRegexp` -> `assertRaisesRegex`
* `assertRegexpMatches` -> `assertRegex`
* `base64.encodestring` -> `base64.encodebytes`
* `base64.decodestring` -> `base64.decodebytes`
* `inspect.getargspec` -> `inspect.signature`
* `inspect.formatargspec` -> `inspect.signature`
* `logging.warn` -> `logging.warning`

closes odoo/odoo#36863

Task: 2003936
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-17 11:36:42 +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
svs-odoo cc9324f740 [IMP] *: usability of Inventory Adjustment
Change the use of Inventory Adjustment, notable changes are:

    - Removed filter field: When user creates a new inventory
    adjustment, he can set one or multiple locations and/or products.
    An inventory adjustment will worry only about defined
    locations/products, but if neither product or location was set,
    it'll manage all stock.

    - Inventory Adjustment Lines have their own view instead of be
    listed on the Inventory Adjustment form view.
    Inventory adjustment lines have new color legend:
        - Red: The quantity is outdated.
        - Blue: There is difference between the on hand quantity and the
        counted quantity.
    New inventory lines created by the user are written in bold.

    - User can't modify already existing inventory lines, except for the
    counted quantity.

    - When an inventory line is outdated, the user has the possibility
    to select and update it, that'll recompute the on hand quantity.

    - When an inventory adjustment is validated, it will take in account
    only the difference between the theoretical quantity ('On Hand
    Quantity') and the counted quantity to adjust the quants.

    - When an inventory adjustment is canceled, it will keep its
    inventory lines and won't regenerate them when re-started.

    - When an Inventory Adjustment generates Account Moves, user can now
    find them in a stat button in the Inventory Adjustment form view.

Also, made some changes in demo data to match new requirement.

Task #1935921
2019-05-29 14:03:29 +00:00
svs-odoo a765a38edb [MOV] mrp_account: merge with mrp_bom_cost
Merges mrp_bom_cost into mrp_account since they have both the same
depedences.

Task #1964809

closes odoo/odoo#32722

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-04-24 08:13:56 +00:00
Simon Lejeune e972d25400 [REF] mrp_account: add an extra_cost notion on the manufacturing order
This is a preliminary work to handle the price of subcontracting. We put
this field in the generic `mrp_account` module because we also want to
support adding an extra cost on a finished move without having to work
with the wokorders, on a future task.

task 1831382
2019-04-03 13:51:05 +00:00
Arnaud Baes 1019ceee6e [MOV] mrp_account
The module is moved from the enterprise repository as it
was *without* the bom cost report.

task 1831382
2019-04-03 13:51:05 +00:00