Commit Graph
30 Commits
Author SHA1 Message Date
damr 5ad0aa5c2a [IMP] project,web_form_project : add the handling of AAL for
project_profitability + change the name displayed in portal

This commit's purpose is to
- add the computation of the AAL for the project profitabity. If a the
analytic account of a project contains AAL that were manually added (
and thus not linked to any sol/purchase/etc ) those lines are not
computed in the 'other costs/other revenues section.

- to display the title of the ticket/task/project in the name of the page My ticket/My task/My project of the portal

task-2960753

closes odoo/odoo#106438

Related: odoo/enterprise#34344
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-04-06 17:20:44 +02:00
Jinane Maksoud 66a99f4743 [FIX] account: fix stat button computation when multiple analytic accounts exist
The first problem when multiple analytics accounts exist is the
sql query, it is generated with less placeholders than the actual
parameters.
The second problem is the getter from the collected data dict, it
is assuming there is only a single account.

closes odoo/odoo#115189

X-original-commit: 8da76614c58ea1989694a5af3ee623640db126dd
Related: odoo/enterprise#38146
Signed-off-by: William André (wan) <wan@odoo.com>
2023-04-04 13:35:03 +02:00
Victor Piryns (pivi) 1adaaba90e [FIX] (sale_)project(_purchase): proj.prof. w/ AA distr. for inv/bills
Current behaviour:
The project profitability panel doesn't take into account the AA
distribution of the project's AA for solo invoices and bills.

Expected behaviour:
It should take the distribution set into account.

Steps to reproduce:
- Install Accounting, Sales, Project, Purchase
- Settings > Activate AA
- Create a new project with a new AA for it.
- Create a new bill or invoice, on the line set the 2 AA, one with
  the project's AA with some X%, and the other AA is irrelevant (the
  sum of all AA on the line should be 100%)
- Confirm the invoice/bill
- Go to the project profitability report (project updates), see that
  we have 100% of the line value that contributed, when it should have.

Reason for the problem:
The contribution of the AA was not taken into account when computing
the project profitability for solo invoices/bills (invoices/bills
w/o SO/PO respectively)

Fix:
Additionally get the analytic_distribution when fetch the
account_move_lines to compute the project's profitability.

Affected versions:
- 16.0
- saas-16.1
- saas-16.2
- master

opw-3246199

closes odoo/odoo#117163

X-original-commit: c3c66d05d039514c9dd02ebdede20a3dff757728
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
2023-03-30 16:23:04 +02:00
Audric Onockx (auon) 978037a74b [MOV] project_{mrp,purchase,sms,hr_expense}: copy/move files per model
In this commit, we just copy/move the files.
In next commit, delete the part of each file
that is not related to its model.

task-3244226

Part-of: odoo/odoo#116165
2023-03-22 17:03:46 +01:00
Raphael Collet 136eb34f07 [IMP] core: _search() no longer uses a default order
This simplifies the use of subqueries by avoiding some costly default
order on the model or the idiotic order='id'.  Method _flush_search()
has been adapted accordingly.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Thomas Lefebvre (thle) 5da3ab038b [FIX] base, sale_project, project_purchase: convert currencies in profitability
Steps to reproduce:
- create a project with an analytic account;
- create sale orders/invoices and purchase order/bills for a project;
- use other currencies;
- go to the "Project Updates".

Issue:
The amounts are used without being converted
into the currency of the analytic account.

Solution:
Convert amounts used in the currency of the analytic account.

Note:
For performance reasons, it is acceptable to fetch all currency
on the same date to get the conversion rate.
In this case, today's date is the most appropriate
(as the project is in progress).

opw-3193676

closes odoo/odoo#113684

X-original-commit: 68b4ea69c173dd5894bcb42b99e6818f241f9734
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-02-24 20:14:01 +01:00
det f79ff3fb37 [IMP] hr_expense: do not create purchase.receipt
Rework of the hr.expense workflow so that:
- expenses paid by employee generate purchase.order
- expenses paid by company generate entry that look like payments

Main reason being that purchase.receipt are not active by default.
That makes the entry hard to find, holes in sequences, inconsitency
with payment states.

It also remove the refusal of expenses as this was dead / inaccessible code, only reports can be refused.

task-id: 3126550
[community](https://github.com/odoo/odoo/pull/110518)
[enterprise](https://github.com/odoo/enterprise/pull/36090)

closes odoo/odoo#110518

Related: odoo/upgrade#4266
Related: odoo/enterprise#36090
Signed-off-by: Laurent Smet <las@odoo.com>
2023-02-24 10:06:06 +01:00
Victor Piryns (pivi) 9ffe67a975 [FIX] project_purchase: consider analytic_distribution in costs
Current behaviour:
Project Update doesn't take into consideration the `analytic_distribution`
percentage of the analytic_account on the line of the purchase orders.

Expected behaviour:
Account correctly for the % of the analytic account for the project,
just like in the Accounting app.

Steps to reproduce:
- Install Accounting, Sales, Purchase, Timesheet, Inventory, Project
- Activate "Analytic accounts" in Settings
- Create a product service which is creating a project at sales
- Create a new SO, add the service, confirm the SO and invoice
- Create a new PO, add some random product, on that same line add 2
analytic account, 50% of the SO project we just created, and 50% from any other.
- Confirm the PO
- Go to the SO's project update section, observe the cost is 100% of the line cost, not 50%

Reason for the problem:
`analytic_distribution` ratios are not taken into account when calculation the costs
of the project.

Fix:
Get the ratio of the `analytic_distribution` and multiply by it when processing the costs

Affected versions:
- 16.0
- master

opw-3079537

closes odoo/odoo#108222

X-original-commit: b676222c129863c154efb48e454e144b77157617
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2022-12-19 11:33:49 +01:00
Victor Piryns (pivi) 9ed8db4f6e [FIX] project: account invoices/bills in project update dashboard
Current behaviour:
In the project update dashboard, invoices and bills that are created
directly (without sales order or purchase order) are not taken into account
in the calculations for profits/costs.

Expected behaviour:
They should be taken into account, as long as the line on them has the
analytic account line on it.

Steps to reproduce:
- Install Project, Sales, Purchase, Accounting
- Activate "Analytic Accounting" in Settings
- Create a new Project and create a new analytic account for the project
- Create a Bill with a product (storable/consumable) and the analytic account
on the line
- Post the bill
- Go to your project update dashboard and notice the cost of the bill
is not taken into account, but we do have a smart button that goes to the bills

Reason for the problem:
Profits/Costs calculations are done based on the sales/purchase orders,
missing the "orphaned" invoices and bills. A side effect of this problem,
storable products on sales are also not taken into account, since Sales Orders
don't have an analytic account per line before version 16, unless that product
is a service (all services intrinsically have an analytic account)

Fix:
Get all invoices/bills that have lines with the project's analytic account,
and removing from those the lines that were already accounted for.

Affected versions:
- saas-15.3
- 16.0
- master

opw-3058198

closes odoo/odoo#108176

X-original-commit: 3d3f4109a06445b6ce9606770085c763ea206b35
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
2022-12-16 17:20:00 +01:00
gawa-odoo 2769d08b02 [IMP] project_purchase, project_hr_expense: change groupby of counts
We could do the Group By directly with sql instead of doing the computations by hand afterwards.
As we're already doing a sql query, we can include it here.

closes odoo/odoo#104933

X-original-commit: 3cec95d0a18f3c343db36bb0700936833e98f7fc
Related: odoo/enterprise#33594
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Wala Gauthier (gawa) <gawa@odoo.com>
2022-11-04 10:54:57 +01:00
gawa-odoo cb0ff3bc64 [FIX] project_purchase: analytic_distribution and recordset
In `_compute_analytic_distribution`, we're dealing with recordset and so, should iterate on it.
Also, the distribution expects an id, not the record.

closes odoo/odoo#104458

X-original-commit: d41d5ef7aebc9f65066ecf86939e3f60aa515539
Related: odoo/enterprise#33378
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Wala Gauthier (gawa) <gawa@odoo.com>
2022-10-28 14:21:08 +02:00
gawa-odoo b8dca3b174 [IMP] analytic, *: Json field for analytic distribution
The `analytic_distribution` field is a Json.
It was stored temporarily as a char.

Search is not available yet, so we do queries by hand when we need to search on keys.

Also added a constraint on account_analytic_distribution_model,
so we don't have models with accounts specific to a company when the model has no company or another company.
It would cause an issue when looking at the models from another company.

X-original-commit: 7064c95aa04e5138bb12ae97acfee04ebb67cc0e
Part-of: odoo/odoo#103097
2022-10-17 10:11:09 +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
Xavier BOL (xbo) b8ef0cc4f2 [REF] project,*: convert kanban, list and form views in OWL
Before this commit, all the custom code for the widgets, form, list and
kanban views are always in OWL and have to be migrate to the new JS
framework.

This commit converts all the widgets, list, kanban and form views used
in the project app in OWL. Some JS tours has been adapted according to
the OWL views, the project right side panel has been reviewed since it
was LegacyComponent (in old component in OWL)

task-2944742

Part-of: odoo/odoo#98380
2022-08-30 20:22:34 +02:00
Xavier BOL (xbo) 2432b4a490 [IMP] project_purchase: allow user to add new purchase order
Before this commit, when the user is in the project update kanban view
and click on Purchase Order row shown in Project Profitability section
in the right side panel, the user cannot create or edit a purchase order
because the AA on each purchase order line is used to link those
purchase orders to the project.

This commit adds the project and also `project_update` key in the
context to use them keys to set the AA on new Purchase Order Line by
default.

task-2861207

closes odoo/odoo#95721

Related: odoo/enterprise#29304
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2022-07-12 01:29:25 +02:00
Xavier BOL (xbo) 2e124663e4 [FIX] project_purchase: display the form if only one record to display
Before this commit, when the user clicks on the Purchase Order row in
costs of project profitability section displayed in right side panel,
the action redirects the user to the list view of `Purchase Order Line`
even if there is only one record.

This commit fixes the issue to display the form view when there is only
one record to display.

task-2814466

closes odoo/odoo#88219

Related: odoo/enterprise#26004
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-04-08 17:13:31 +02:00
Xavier BOL (xbo) 1a32fbd9c9 [IMP] project_purchase: take into account PO confirmed in project profitability
Before this commit, the PO is only taken into account in the project
profitability if the quantity to invoice or the quantity invoiced is
greater than 0 in its lines. However, we could take into account the PO
when it is confirmed and the products ordered are not delivered to have
an idea on the costs impacted by this PO.

This commit computes the costs impacted by the PO linked to the AA from
the project if the PO is confirmed and there is a quantity ordered or
invoiced or to invoice in its lines. If no quantity to invoice is found
then the amount to invoice will be the price unit of the product
multiplied by the difference between the quantity ordered and the quantity
invoiced.

task-2814466

Part-of: odoo/odoo#88219
2022-04-08 17:13:30 +02:00
Xavier BOL (xbo) e26bdb3282 [IMP] project,*: sort the row displayed in profitability section
Before this commit, the order of rows shown in costs and revenues is not
fixed and depends on the order of the modules.

This commit adds a sequence on each row and then sort the rows to fix
the order of those rows.

task-2710808
2022-04-01 15:33:00 +02:00
Xavier BOL (xbo) 31b2ddc42f [IMP] project*,sale_timesheet: add profitability label
Before this commit, the label is giving with the data computed for the
project profitability.

This commit separes the label with the data to avoid translating many
times the same things.

task-2710808
2022-04-01 15:33:00 +02:00
Xavier BOL (xbo) 658c485e51 [IMP] project_purchase: add action to get the purchase orders
Before this commit, the project profitability shows the total due to the
purchase orders linked to the project. However, the user cannot easily
sees which purchase orders impact the project profitability.

This commit adds an action to see all purchase orders related to the
project. However, the 'Purchase Orders' section in the costs will be
clickable only if the user has access to the purchase orders

task-2710808
2022-04-01 15:33:00 +02:00
Xavier BOL (xbo) 812940237d [IMP] project,*: filter AAL to avoid compute many times in profitability 2022-04-01 15:33:00 +02:00
Xavier BOL (xbo) bd4b36d971 [IMP] project_purchase: add purchase in project profitability 2022-04-01 15:33:00 +02:00
Xavier BOL (xbo) 7f218598fe [IMP] project_purchase: improve performance for purchase_orders_count
Before this commit, when the `purchase_orders_count` field is computed,
we do a search in `purchase.order.line` to get the purchase order linked
to the projects in `self` of the `_compute_purchase_orders_count`
method. However, if no project has AA set this search is useless, we can
directly set `purchase_orders_count` to 0 for all projects because the
linked between the POs and the projects is made with AA of the project.

This commit changes the method to search the PO linked to the projects
only when at least one project has AA set, otherwise we directly set the
`purchase_orders_count` to 0 for all projects contained in `self`.

task-2710808
2022-04-01 15:33:00 +02:00
41bcee0cda [FIX] *: use lazy translation for _get_stat_buttons in project update
Before this commit, the translation is not done in lazy, so for each
stat button shown in the right side panel of the project update, a query
is done to find the correct translation based on the language of the
user. It means, the translation is costly and need to be done in lazy to
reduce the time for the translation of those stat buttons.

This commit uses the `_lt` to translate in lazy mode those stat
buttons. By doing that, the execution time is reduced from 750 ms to 250 ms.

X-original-commit: 95fe018
Part-of: odoo/odoo#85660
Co-authored-by: Yannick Tivisse <yti@odoo.com>
Co-authored-by: Laurent Stukkens (LTU) <ltu@odoo.com>
2022-03-03 03:07:57 +00:00
Vincent Schippefilt 05fc9a6733 [IMP] *: use _read_group instead of read_group
This commit modifies most of the usages of read_group and uses
_read_group instead. _read_group doesn't join automatically on the
many2one fields when no order_by is specified, making it more performant
when the "name" of the many2one is not relevant, which is the case for
most back-end cases

closes odoo/odoo#84908

Task-id: 2479334
Related: odoo/enterprise#24877
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-03-02 17:10:48 +00:00
Cedric Prieels (cpr) ea038c6b19 [IMP] project: follow up the project overview removal
The project overview is a significant technical debt
as it is a custom qweb view. It is quite limited:

It is not possible to group the data, to filter on dates,
SOs or Field Service projects.
Improving this is very difficult and would require weeks
of development that are not worth it.
In any case, all the information provided by the project overview
can be found elsewhere. The stat buttons of the report are basically
duplicates of the ones from the project form view.
Therefore, we are removing this report and its twin,
the Project Costs and Revenues.
In addition, analytic items lack context for the user to understand
what generated a certain cost or revenue:

there is no link to the source document;
the entries are not categorized (e.g. it is not easy to understand
if a cost comes from a timesheet cost, a purchase order or an expense);
the billable type group by works fine for timesheets but then all
the other entries are flagged as Undefined, which is not very helpful;
there is no option to easily isolate costs from revenues.

task-2646234
See odoo/enterprise#20936

closes odoo/odoo#76553

Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-11-23 11:12:14 +00:00
Thibault Libioulle 95c16f35ce [FIX] project*: fix groups on computed field
*: account_sale_timesheet,
   project_hr_expense,
   project_mrp,
   project_purchase,
   sale_project_account

This commit fixes issue regarding fields in project form stat buttons.
Those fields are evaluated in any cases, and should rather be computed
only when the user has the right group.

Steps to reproduce :
1) Install project with one of this bridge
2) Connect with a user with only the group_project_admin right
3) Go to the form view
4) Issue:
An internal user with the group "Project Administrator" is unable to
access the form view of a project because of missing rights on the
X model.

Desired Behavior
================
The stat button should not be shown and the field not computed.

opw-2675514

closes odoo/odoo#78981

X-original-commit: 981bbf59d624c3a7bd22d6d7bf26c09e14835862
Related: odoo/enterprise#21889
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-10-26 13:23:04 +00:00
Cedric Prieels (cpr) 828d5157a5 [FIX] project{,_mrp}: fix project update stat buttons
We are copying 3 stats buttons from the project
view form (manufacturing orders, work orders and bills of materials)
 and we add them to the project update page.

See task-2638359

closes odoo/odoo#76421

X-original-commit: 4572e710a5e755c0c75c95a6d033e44f0a2799f8
Related: odoo/enterprise#20811
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-09-14 12:07:39 +00:00
Cedric Prieels (cpr) 2b3e3a44a9 [IMP] project_{account,purchase,hr_expense}: extend form and panel
This commit extends project form and panel in order to add buttons
which allow user to view documents linked to the project analytic
account.

This commit adds bridge modules in order to handle those extensions.

PR : #72736
See odoo/upgrade#2706

task-2545084
2021-09-06 10:41:13 +02:00
yhu-odoo a7007748c3 [ADD] project_purchase: Monitoring purchase in project
Show purchase information in project when both use the same analytic
account.

Task-2469742
PR #68708
2021-08-27 16:40:50 +00:00