Commit Graph
1921 Commits
Author SHA1 Message Date
roen-odoo 017a572143 [FIX] account : Average price fix invoice report
Current behavior:
Invoices report had a wrong average price when invoice had credit note

Steps to reproduce:
Create a db with accounting
Create a customer C and a Product P
Create an Invoice for C for 10 pieces of P
Create a Credit note for C for 1 P
Go to Reporting > Invoice Analysis
Open the pivot view, in the Measures, display the Average Price, the Product quantity and the Untaxed Total
The Total multiplied by the quantity is not equals to the average.

opw-2557420

closes odoo/odoo#81238

X-original-commit: ef26467e288a12571c37d4c133b44f08d99cc702
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
2021-12-13 08:09:46 +00:00
Philémon van Helden 3b833c73a7 [IMP] mass_mailing, *: improve mailing stat buttons
*mass_mailing_crm, mass_mailing_sale 

Currently, the Mailing stat buttons have a few problems.
The business reporting smart buttons send the user to a list of linked records,
which doesn't provide much value (e.g. what is the user supposed to do with a
list of 12345 leads?). They also show wrong values depending on access rights.
The Mailing KPI smart buttons lead to a blank screen if there's no data to show.

In this commit, we add/adapt all action helpers to help users understand what is
going on. For the business reporting smart buttons we instead send users to
relevant reporting actions, so they can make sense of the data we showed before.
The values of the business reporting smart buttons are now calculated as a super
user.
We also change some domains from the whole UTM Sale Domain to only using
Source ID, which simplifies computation while staying accurate.

task-2604515

closes odoo/odoo#76798

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2021-11-30 16:53:33 +00:00
Anjali 7c5bfb42d4 [IMP] various: add list views for some important reporting models
Currently, there are many useful pivot views on reporting models but most
of them lacks the dedicated list view. Dedicated list views will allow users
to see useful information when one directly drill down to the records from
the pivot table in odoo spreadsheet [1].

With this commit

  1. we remove 'disabled_linking' attribute from the very important pivot
     and graph views (see the full list on task pad);
  2. we added dedicated list views for the following reporting models

    - account.invoice.report
    - fleet.vehicle.cost.report
    - hr.timesheet.attendance.report
    - purchase.report
    - project.profitability.report
    - report.membership
    - report.pos.order
    - report.project.task.user
    - sale.report

Task-2547881

[1] See task-2506116

closes odoo/odoo#72394

Related: odoo/enterprise#19122
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-07-29 09:33:56 +00:00
mhabboush bd497d5296 [FIX] account: inv. report price_average
When converting a price (average price in this case) the price should be multiplied by the source uom factor (uom_line.factor)
https://github.com/odoo/odoo/blob/72fea2fe11244a55e9a630049fc75f147e26e473/addons/uom/models/uom_uom.py#L172

closes odoo/odoo#72944

X-original-commit: 7f3dd371fc00df2d9e7b88ae2425e33db91966f7
Signed-off-by: William André (wan) <wan@odoo.com>
2021-06-29 14:41:41 +00:00
Andrea Grazioso (agr-odoo) a7e0268d64 [FIX] account: fix Average Price measure
Open Accounting>Reporting>Invoices
Add measure 'Average Price'

The reported amount will be wrong, as it will not consider the quantity,
making an average of the price subtotal

opw-2522621

closes odoo/odoo#71862

X-original-commit: 978012b38abb941c88fe85f1befa2ac659545915
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-06-08 13:04:17 +00:00
Mathieu Duckerts-Antoine e56a095f16 [FIX] *: disable linking on some graph views
For the graph views based on reporting models (e.g sale.report), click
on a group in the chart redirects the user to an "empty" list view. Here
we use the attribute disable_linking to avoid that redirection for those
views.

Task ID: 2336960

closes odoo/odoo#57622

X-original-commit: 0b0ae92b6bdac25843ba24d767dbcab3b75703e5
Related: odoo/enterprise#13192
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-09-14 10:01:49 +00:00
wan fa02f0ba21 [REF] account: use dynamic _table_query in invoice analysis
closes odoo/odoo#56080

Related: odoo/upgrade#1664
Related: odoo/enterprise#9914
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-08-20 07:45:18 +00:00
Barad Mahendra 30adc183f8 [IMP] *: set sample="1" on reporting view archs
The purpose of this commit is to enable sample data on various graph and
pivot views.

Task ID: 2319606

closes odoo/odoo#55917

Related: odoo/enterprise#12415
Signed-off-by: Mathieu Duckerts-Antoine <Polymorphe57@users.noreply.github.com>
2020-08-18 14:24:10 +00:00
Barad Mahendra 63f239163a [IMP] *: set sample="1" on various graph archs
The purpose of this commit is to enable sample data in various
graph views.

TaskID: 2311486
2020-08-12 09:57:09 +00:00
Jorge Pinna Puissant efe51fa56a [FIX] account: negative credit note product qty in invoice report
- Create an invoice with a Product X and Post it;
- Generate a Credit Note from the invoice;
- Reporting > Invoices;
- use Pivot Table View;
- Enable 'Product Quantity' in Measures;
- Filter by 'Invoice #';
- Expand Pivot Table by 'Product'.

Before this commit, the products in the credit note had a positive sign,
contrary to the untax total that has a negative sign. The issue with
this, is when the quantities of the credit notes is added with the
quantities of the invoices the total is not coherent with the actual
sell products.

Now, the product quantity that comes from a credit note has a negative
sign. This was already the behaviour in version 11 and 12.

opw-2283833

closes odoo/odoo#53931

X-original-commit: 917b2076b77ba3f682b342989c41b7f7d0670ca2
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2020-07-01 17:24:19 +00:00
Yannick Tivisse 893ec20236 [IMP] various: Add date filters on search views
PURPOSE
=======

The task aims at adding date filters across various modules in preparation
for the 'time range' feature rework on task 2245719

https://www.odoo.com/web#id=2245719&action=327&model=project.task&view_type=form&cids=1&menu_id=4720

SPECIFICATION
=============

New date filters to compensate the deprecated time ranges feature:

See task's pad for the complete details

closes odoo/odoo#52398

Taskid: 2263661
Related: odoo/enterprise#10938
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-09 10:50:17 +00:00
Nicolas Martinelli 9d1c3de480 [FIX] account: incorrect forwardport
Previous fixes on invoice analysis report were incorrectly
forward-ported.

closes odoo/odoo#51961

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-27 09:27:45 +00:00
Laurent Smet caeb782841 [IMP] account,*: Improve bank statements/payments workflow
- Create journal entries as soon as bank/cash statement lines are created, temporary booked on a suspense account set on the journal.
- Simplify the management of "blue" lines in the reconciliation widget. A "blue" line is now a journal item using a temporary liquidity account (outstanding payment/receipt accounts, set on the journal).
- Adapt and simplify the bank reconciliation report.
- Remove the bank reconciliation threshold date. The reconciliation report will show the not already reconciled journal entries using a liquidity account and the not already reconciled journal entries using a temporary liquidity account. Without accounting, an account.payment will involve directly the liquidity account and then, will be considered as a statement line directly.
- Remove the post_at bank reconciliation feature. The "paid" state will be set on the invoices only if reconciled with a journal entry involving the journal's liquidity account.
    With invoicing, the payment will do that so the "in_payment" state should never be shown up.
    With accounting, only the statement lines have the power to move an invoice to the "paid" state.
- Fix various corner cases about the management of multi-currency in bank statement lines.
- Fix the conversion dates in multi-currency: Since the bank/cash is always used on the statement lines, it will use always the real "bank" date instead of the fictive payment one.
- Ensure the 'reconcile' method will raise an error if the involved moves are not posted.

related enterprise PR odoo/enterprise#7019

closes odoo/odoo#41301

--task: 2092096
Related: odoo/upgrade#1018
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2020-04-10 09:47:24 +00:00
wan af2272ac56 [FIX] account: invoice analysis multicurrency + various imp
Task 2206699

* All the amounts are now expressed in the company currency
  - The amounts are taken from debit/credit on the aml
  - When opening the report for multiple companies, convert in the
    current company's currency
* New default view:
  - Group by month instead of category
  - Line chart instead of bar chart
  - Filter on customers
* Remove useless fields:
  - name
  - invoice_partner_bank_id
  - invoice_payment_term_id
  - residual (including taxes)
  - amount_total (including taxes)
  - nbr_lines as it is a generic feature
* Rename currency_id to the more correct company_currency_id
* Remove useless group_by clause from the SQL query

closes odoo/odoo#47066

Related: odoo/upgrade#1021
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-04-01 14:13:16 +00:00
Benjamin Frantzen (bfr) def8817d72 [IMP] accounting : several misc improvements
- open accounts in a full view instead of a modal
- ability to reverse entries at their own accounting date
- don't create draft closing entries and reminder if no configuration for tax groups
- reordered account menus
- improved invoice form view

Task ID : 2209497

closes odoo/odoo#48355

Related: odoo/upgrade#1001
Related: odoo/enterprise#9485
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-03-31 11:15:11 +00:00
oco-odoo 0eef278268 [IMP] base, account, l10n_ch, website_sale, payment, web: make payment QR-code generation more generic
This new modelling makes it easier to add new QR-code formats, and allows using all of them in website_sale and account.payment's form view as well (so, Swiss QR codes are now available there, while they were restricted to only invoices in the past). All barcodes are now generated as reports, from a dedicated route. This was only partly the case before : Swiss QR added a cross on top of the QR-code directly in the template, it wasn't part of the image returned by the route; now it is.

[ADD] base_qr_code_sepa: new module decoupling SEPA QR-codes generation from the base module

Each new QR-code generation option should thus be done in a dedicated module (or added to a localization) in the future.

[IMP] base_qr_code_sepa: update the generated QR codes to version 2 of the specification

Version 1 is still supported, so no need to backport this.

[IMP] l10n_ch: make Swiss QR-codes compatible with the new version of the specification (the old one is deprecated)

This will be backported to 11.0 and 12.0, as these QR-codes will soon replace ISR.

[IMP] account: make it possible to mark manual payments as sent with a button on the form view

This way, when making them directly with a QR-code (or doing a more classical wire transfer), people can keep track of what they already have asked the bank to do, and what they still have to treat.

closes odoo/odoo#44839

Related: odoo/enterprise#8262
Related: odoo/upgrade#992
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-03-30 11:28:41 +00:00
Ankita Raval d675dbaa4c [IMP] account,* : Change type field to move_type in account.move
task-id: 2028z813
2020-02-19 09:09:20 +00:00
Andrea Grazioso (agr-odoo) 825b227d5c [FIX] account: fix invoice report total incorrect
Go to Accounting / Reporting / Management / Invoices
Select Pivot view
Add "Total" measure
expand results adding "invoice #" and product

Total will be incorrect because it is summing up the value reported from
several lines of the query in which the total is taken as the invoice
total, so it will display total * # lines.

Using the price retrieved from the single lines fix the issue, but it
needs to be converted according to the currency rate of the invoice.

Moreover the test need to be modified because the amount_total variable
of the report should NOT be the move amount_total but the amount from
all the lines converted in company currency

opw-2187369

closes odoo/odoo#45050

X-original-commit: 1558bb2a62cf169e6b19a2aa4dd92fcd8ff1b25a
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-02-11 09:16:03 +00:00
oco-odoo 8e4158af81 [IMP] account: add 'partial' and 'reversed' payment states to invoices
- 'partial' payment state corresponds to invoices whose payable/receivable move line has been partially reconciled with some other line.

- 'reversed' payment state corresponds to entries that have been cancelled by the creation of a single reverse entry (using the dedicated button on the form view). This state can be set on invoice as well as on regular entries.

=> To stay consistent with the naming conventions, this commit also renames invoice_payment_state field to payment_state, since it's no longer only applicable on invoices.

closes odoo/odoo#41723

Related: odoo/enterprise#7202
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2020-01-16 18:04:26 +00:00
Nicolas Lempereur 98bba5fa0b [FIX] account: invoice report fallback company currency
In 13.0 if currency_id is not set, we are fallbacking on
company_currency_id.

This was not taken into account in account.invoice.report view and so
when grouping by currency, we would get an "Undefined" grouping which
meant "company currency".

Now we fallback on company_currency in the view, and if we displayed
data for several companies with different currency, this should also
remove the amalgamation of different currency in "Undefined" group.

opw-2151492
closes #41491

closes odoo/odoo#41593

X-original-commit: ee2858c9c9eec5121b63bd8565980d93846bcade
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-12-09 13:15:43 +00:00
Laurent Smet ebac65bebf [IMP] account: Cleanup remaining stuff of Aged Partner Balance
This report is only available in enterprise edition. This report is now entirely
moved in account_reports.

This report is no longer available in community since:
https://github.com/odoo/odoo/commit/e51b4f659fc5e4253d3156754ada21166c8d1bf8

closes odoo/odoo#38502

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2019-10-17 09:14:33 +00:00
qdp-odoo b33f98d81f [FIX] account, usability: field label renaming
closes odoo/odoo#38485

X-original-commit: 806456f7c7780a544958791e4ca47fbf8c2fa2fd
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2019-10-11 09:58:13 +00:00
Florian Gilbert ab483a3a66 [IMP] account: Add restrict mode and normal mode for account move.
This commit deletes account_cancel module and squash it into account.
The 'update_posted' field is changed by 'restrict_mode_hash_table' field.

If 'restrict_mode_hash_table' is true, you have a hash chain on your account journal.
These hash chains prove the inalterability of your accounting.

l10n_fr_certification module is deleted and all hashing method are moved in account module.
Now, you can download a PDF report about your inalterability in the company settings.

If you have l10n_fr or l10n_post_cert installed you have more information on this report
like the inalterability of pos orders, etc.

Task ID: 2039160
2019-09-25 11:26:02 +00:00
qdp-odoo d604deccee [IMP] account: speedup of the aged partner balance
Removed a browse on partners made in a loop, for a substantial gain of time and DB queries.

Observed gain for a real data DB with 500 partners to print in the aged report:
time (ms)                  # queries
Before patch               4583                       1623
After patch                2932                        553
Gain                       1651 (36%)                 1070 (66%)

closes odoo/odoo#36488

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2019-09-05 14:08:55 +00:00
Julien Castiaux 24c92d8b95 [FIX] account: move group visible search to inherited view
Make sure your user does not have the "Analytic Accounting" group,
access the Invoices Management Report, traceback.

The problem is linked to groups. When they are used on model field, the
field is removed by the ORM. When they are used in view field, the field
is set as invisible. As both fields were restricted to the group, the
frontend was trying to render an invisible field using a removed field
causing the traceback.

The problematic field has been moved to a dedicated inherited view with
the group applied on the entire view. This cause the field not to be
rendered when the user does not have the group.

closes odoo/odoo#36122

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-08-27 11:11:10 +00:00
Christophe Simonis 140ee6b8f0 [MERGE] forward port branch saas-12.4 up to 98a55917a6 2019-08-14 16:48:10 +02:00
Christophe Simonis f6c197e5d4 [FIX] account: use correct model
Oversight of previous forward-port.
2019-08-08 13:38:43 +02:00
Christophe Simonis b792ba7d9a [MERGE] forward port branch saas-12.3 up to 752b2553c6 2019-08-08 11:52:13 +02:00
Christophe Simonis 886eca0131 [IMP] *: remove usage of oldname attribute
This attribute is misleading as it is insufficient to correctly upgrade
the database. It only renames the column in the database, but other
operations are needed, like updating the corresponding `ir.model.fields`
record (and its xmlid). The default values and the translations are also
lost during the upgrade.

Moreover, this feature was misused. It was:
 - left on fields during multiple versions.
 - used on reports (SQL views). This would be ok if the feature was
   complete, but, as is, it was useless.
 - kept unchanged after a second renaming of the field (which can happen
   versions later the first rename).
 - used, even when the meaning of the field changed. i.e. the field
   `archived` has been renamed to the classic `active`, but the value
   in the database should be switched.
2019-08-05 09:36:41 +00:00
Nicolas Lempereur 32976c7f49 [FIX] account: simplify report implem. for studio
If in web_studio we:

- duplicate "Invoices" report
- delete "Invoices" report

The duplication will not work anymore, since the report class
report.account.report_invoice_with_payments is shared but requires
account.report_invoice_with_payments (original report).

With this changeset, we forgo checking model type of report since it
should always be account.invoice anyway.

opw-2045435
closes #35349

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-07-31 14:05:55 +00:00
Martin Trigaux 1f5a4649a6 [MERGE] Forward port of saas-12.3 to saas-12.4 up to 87fc1554d6
closes odoo/odoo#34820

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-12 13:59:35 +00:00
Laurent Smet beaa30a3d1 [IMP/REF] accounting-pocalypse yeaaahh
This commit merges the following models
 * account.invoice and account.move
 * account.invoice.line and account.move.line
 * account.voucher and account.move
 * account.voucher.line and account.move.line

It was the opportunity for a big cleanup of the code, so it also restructures the whole account module, its different models/fields, the tests etc. for a better world and a better code readability.

==== Rationale ====
The rationale of this huge change is that we want journal entries / invoices to be easily edited, and changes reflected in the other model. It's a HUGE feature and very strategic for the fiduciary companies. For example, changing the account of a journal entry needs to be automatically reflected on the related invoice.

The same reasoning applies to sale/purchase vouchers.

==== Changes made in features =====
When creating an invoice, you are now creating a journal entry directly.
--> The object account.invoice no longer exists.
In the same fashion when creating an invoice line, you're now adding journal items directly in the journal entry representing the invoice. If this invoice line has some tax, it may create additional journal items as well.
--> The models account.invoice.line & account.invoice.tax no longer exist

Identically, when creating a sale/purchase receipt with its lines, you are now creating a journal entry directly and there's no more usability difference between encoding a receipt or an invoice.
--> The object account.voucher no longer exists.
--> The object account.voucher.line no longer exists.
--> The whole account_voucher module no longer exists.

Positive side-effects coming from these changes are
* draft invoices/bills/sale or purchase receipts now create a draft accounting entry. Validate these objects now simply post its journal entry. That means that draft invoices/bills/sale or purchase receipt can straightforwardly be included in reporting or budgets.
* opening a journal entry in form view will now always open the correct view: if it's a sale/purchase journal entry we will have a customer invoice/vendor bill view or a sale/purchase receipt view, whatever the menu we're coming from.
* code & business logic simplification. It is also condensed in a single place instead of being partially duplicated on invoices, vouchers and journal entries.

There should be no feature loss, except the one allowing to group multiple journal items together based on the same product during the invoice validation.

==== Changes made in models =====
* account.invoice: model removed. Instead, now use account.move with following mapping

field (account.invoice) 		field (account.move)
-----------------------			--------------------
name 					invoice_payment_ref
number 					name
reference 				ref
comment 				narration
user_id 				invoice_user_id
amount_					total_company_signed amount_total_signed
residual 				amount_residual
state 					state + invoice_payment_state 		/!\ selection changed
date_invoice 				invoice_date
date_due 				invoice_date_due
sent 					invoice_sent
origin 					invoice_origin
payment_term_id 			invoice_payment_term_id
partner_bank_id 			invoice_partner_bank_id
incoterm_id 				invoice_incoterm_id
vendor_bill_id 				invoice_vendor_bill_id
source_email 				invoice_source_email
vendor_display_name 			invoice_vendor_display_name
invoice_icon 				invoice_vendor_icon
cash_rounding_id 			invoice_cash_rounding_id
sequence_number_next 			invoice_sequence_number_next
sequence_number_next_prefix 		invoice_sequence_number_next_prefix

'invoices' subset of account.move can be accessed by using the selection field 'type' or one of the many helpers like is_invoice()

* account.move: now has a valid state 'cancel' that has to be excluded from all business logic
* account.move: field 'amount' renamed into 'amount_total'
* account.move: field 'reverse_entry_id' renamed into 'reversed_entry_id'
* account.move.line: now has a field 'display_type' that has to be excluded from all business logic, in order to support invoice layouting
* account.invoice.line: model removed. Instead, now use account.move.line with following mapping

field (account.invoice.line) 		field (account.move.line)
----------------------------		-------------------------
invoice_id 				move_id
uom_id 					product_uom_id
invoice_line_tax_ids 			tax_ids
account_analytic_id 			analytic_account_id

'invoice lines' subset of all account.move.line from a journal entry can be accessed by using the boolean field 'exclude_from_invoice_tab'

* account.invoice.tax: model removed. Instead, now use account.move.line with following mapping

field (account.invoice.tax) 		field (account.move.line)
---------------------------		-------------------------
invoice_id 				move_id
account_analytic_id 			analytic_account_id
amount 					price_unit
base 					tax_base_amount

'tax lines' subset of all account.move.line from a journal entry can be accessed by using the relational field 'tax_line_id'

* account.invoice.confirm: model removed. Instead, now use the 'post()' function of account.move
* account.invoice.refund: model removed. Instead, now use account.move.reversal to reverse the entries with the same options as we had for invoices
* account.voucher: model removed. Instead, now use account.move of type in ['out_receipt', 'in_receipt]
* account.voucher.line: model removed. Instead, now use account.move.line

==== Changes made in functions ====
* on account.move, method _run_post_draft_to_post() renamed into _autopost_draft_entries()
* on account.move, method action_account_invoice_payment() renamed into action_invoice_register_payment()
* on account.move, method action_invoice_reconcile_to_check() renamed into action_open_matching_suspense_moves()
* on account.move, method _get_domain_edition_mode_available() renamed into _get_domain_matching_supsense_moves()
* on account.move, method _get_intrastat_country_id() renamed into _get_invoice_intrastat_country_id()
* on account.move.line, method _get_domain_for_edition_mode() renamed into _get_suspense_moves_domain()
* in account.bank.statement, contextual key 'edition_mode' renamed into 'suspense_moves_mode'

Was task 1917430
2019-06-28 11:52:55 +00:00
qdp-odoo 90334b7db0 [FIX] account: aged partner balance with private partners
When hr is installed, with 'private' type, you should be member of
hr/officer group to read them, or you'll face an access right error.

closes odoo/odoo#34587

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2019-07-04 12:30:44 +00:00
Christophe Simonis 25e3f27062 [MERGE] forward port branch saas-12.3 up to 48a9f5a633 2019-06-17 13:20:35 +02:00
Christophe Simonis 71a50a2214 [MERGE] forward port branch saas-12.3 up to 409679866b 2019-06-06 11:54:35 +02:00
Nans Lefebvre 77da958be6 [FIX] account_invoice_report: fix group by product
Group by invoice, products: the untaxed total is correct,
while the (taxed) total is the sum of the lines divided by the number of lines.

On account.invoice.line, there is a price_subtotal_signed, which is the
price_subtotal (untaxed) in the company currency.
Unfortunately price_total_signed does not exist for price_total (untaxed).

As a result, we need to use the price_total on the invoice line,
and divide by the currency rate.
Unfortunately we cannot do it in the subquery because of the scope of the rate.

opw 2003185

closes odoo/odoo#33802

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
2019-06-04 06:00:08 +00:00
Yannick Tivisse f5dfe4727c [IMP] api.py: Rename company_id/company_ids into company/companies
The goal is to be coherent with the user property.

Actually, company_id and company_ids on the environment are no fields.

Calling env.company_id returns a browse record, not an id.
2019-05-29 08:09:15 +00:00
Lucas LefèvreandYannick Tivisse 3e97cff779 [IMP] base: Remove customer and supplier fields from res.partner
Purpose
=======

Fields `customer` and `supplier` on `res.partner`
are mostly used in domains of many2x fields.

Those domains can confuse end users because they don't
see the partner they are looking for; and it's not obvious why.

Some identified problems:

1. It can lead to duplicated partners: the user does not find
   the partner, so he creates a new one.

2. The user imports supplier contacts in the Contacts app, so they
   don't get the `supplier` flag. Then the user wants to make a purchase order,
   and cannot find the new suppliers in the list

3. A user removes the customer flag on a prospect, because they don't think
   it's a customer yet - except now they can't make a quote for that customer...

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

Remove the two mentioned fields.

Since fields `customer` and `supplier` have been removed, all partners
are now shown in many2one dropdowns.

But in some cases, not all partners are relevant or some are more likely
to be relevant than others. e.g. when creating a PO, top suppliers have a
higher priority than other partners.

So, adapt the places where those fields were used with the new mechanism to
display the searched the partners, according to the number purchase/sales
orders they made.

TaskID: 2031147

Co-authored-by: Yannick Tivisse <yti@odoo.com>
2019-08-01 12:42:03 +02:00
Martin Trigaux fd15ca1918 [MERGE] Forward port of saas-12.4 to master up to 1f5a4649a6
closes odoo/odoo#34850

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-15 08:12:26 +00:00
Raphael Collet c552fb7a61 [IMP] api: remove deprecated decorators 2019-07-08 13:51:35 +00:00
Laurent Smet bc131c0cfb [MERGE] manual forward port of accounting-pocalypse (beaa30a3d1)
This commit merges the following models
 * account.invoice and account.move
 * account.invoice.line and account.move.line
 * account.voucher and account.move
 * account.voucher.line and account.move.line

It was the opportunity for a big cleanup of the code, so it also restructures the whole account module, its different models/fields, the tests etc. for a better world and a better code readability.

==== Rationale ====
The rationale of this huge change is that we want journal entries / invoices to be easily edited, and changes reflected in the other model. It's a HUGE feature and very strategic for the fiduciary companies. For example, changing the account of a journal entry needs to be automatically reflected on the related invoice.

The same reasoning applies to sale/purchase vouchers.

==== Changes made in features =====
When creating an invoice, you are now creating a journal entry directly.
--> The object account.invoice no longer exists.
In the same fashion when creating an invoice line, you're now adding journal items directly in the journal entry representing the invoice. If this invoice line has some tax, it may create additional journal items as well.
--> The models account.invoice.line & account.invoice.tax no longer exist

Identically, when creating a sale/purchase receipt with its lines, you are now creating a journal entry directly and there's no more usability difference between encoding a receipt or an invoice.
--> The object account.voucher no longer exists.
--> The object account.voucher.line no longer exists.
--> The whole account_voucher module no longer exists.

Positive side-effects coming from these changes are
* draft invoices/bills/sale or purchase receipts now create a draft accounting entry. Validate these objects now simply post its journal entry. That means that draft invoices/bills/sale or purchase receipt can straightforwardly be included in reporting or budgets.
* opening a journal entry in form view will now always open the correct view: if it's a sale/purchase journal entry we will have a customer invoice/vendor bill view or a sale/purchase receipt view, whatever the menu we're coming from.
* code & business logic simplification. It is also condensed in a single place instead of being partially duplicated on invoices, vouchers and journal entries.

There should be no feature loss, except the one allowing to group multiple journal items together based on the same product during the invoice validation.

==== Changes made in models =====
* account.invoice: model removed. Instead, now use account.move with following mapping

field (account.invoice) 		field (account.move)
-----------------------			--------------------
name 					invoice_payment_ref
number 					name
reference 				ref
comment 				narration
user_id 				invoice_user_id
amount_					total_company_signed amount_total_signed
residual 				amount_residual
state 					state + invoice_payment_state 		/!\ selection changed
date_invoice 				invoice_date
date_due 				invoice_date_due
sent 					invoice_sent
origin 					invoice_origin
payment_term_id 			invoice_payment_term_id
partner_bank_id 			invoice_partner_bank_id
incoterm_id 				invoice_incoterm_id
vendor_bill_id 				invoice_vendor_bill_id
source_email 				invoice_source_email
vendor_display_name 			invoice_vendor_display_name
invoice_icon 				invoice_vendor_icon
cash_rounding_id 			invoice_cash_rounding_id
sequence_number_next 			invoice_sequence_number_next
sequence_number_next_prefix 		invoice_sequence_number_next_prefix

'invoices' subset of account.move can be accessed by using the selection field 'type' or one of the many helpers like is_invoice()

* account.move: now has a valid state 'cancel' that has to be excluded from all business logic
* account.move: field 'amount' renamed into 'amount_total'
* account.move: field 'reverse_entry_id' renamed into 'reversed_entry_id'
* account.move.line: now has a field 'display_type' that has to be excluded from all business logic, in order to support invoice layouting
* account.invoice.line: model removed. Instead, now use account.move.line with following mapping

field (account.invoice.line) 		field (account.move.line)
----------------------------		-------------------------
invoice_id 				move_id
uom_id 					product_uom_id
invoice_line_tax_ids 			tax_ids
account_analytic_id 			analytic_account_id

'invoice lines' subset of all account.move.line from a journal entry can be accessed by using the boolean field 'exclude_from_invoice_tab'

* account.invoice.tax: model removed. Instead, now use account.move.line with following mapping

field (account.invoice.tax) 		field (account.move.line)
---------------------------		-------------------------
invoice_id 				move_id
account_analytic_id 			analytic_account_id
amount 					price_unit
base 					tax_base_amount

'tax lines' subset of all account.move.line from a journal entry can be accessed by using the relational field 'tax_line_id'

* account.invoice.confirm: model removed. Instead, now use the 'post()' function of account.move
* account.invoice.refund: model removed. Instead, now use account.move.reversal to reverse the entries with the same options as we had for invoices
* account.voucher: model removed. Instead, now use account.move of type in ['out_receipt', 'in_receipt]
* account.voucher.line: model removed. Instead, now use account.move.line

==== Changes made in functions ====
* on account.move, method _run_post_draft_to_post() renamed into _autopost_draft_entries()
* on account.move, method action_account_invoice_payment() renamed into action_invoice_register_payment()
* on account.move, method action_invoice_reconcile_to_check() renamed into action_open_matching_suspense_moves()
* on account.move, method _get_domain_edition_mode_available() renamed into _get_domain_matching_supsense_moves()
* on account.move, method _get_intrastat_country_id() renamed into _get_invoice_intrastat_country_id()
* on account.move.line, method _get_domain_for_edition_mode() renamed into _get_suspense_moves_domain()
* in account.bank.statement, contextual key 'edition_mode' renamed into 'suspense_moves_mode'

Was task 1917430
2019-07-01 13:45:57 +02:00
Christophe Simonis 9035fb8a2a [MERGE] forward port branch saas-12.4 up to 618ea1ab67 2019-06-18 10:24:25 +02:00
Hiral Bhavsar 3cd7ed07a2 [IMP] *: remove 'view_type' on window actions.
The old tree views don't really exist anymore, this odd pseudo-flag to
dispatch between "list" and "tree" tree views has no reason to remain.

Task 1937686

closes odoo/odoo#31243

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-17 11:34:17 +00:00
Yannick Tivisse a5b6f31cf2 [IMP] base: Contextualize the multi company
Purpose
=======

Allow the user to select the allowed companies for which he wants to see records
on top of selecting his current company.

It is confusing for users to see the records from the company he is connected to
and the records of the children companies.

Instead of using the hierarchy of companies to access records across companies,
the user can now select (from his set of allowed companies) the companies for
which he wants to access records.

/!\ This means that the user will interact with records from company A when in
company B.
Example: a SO has been created and confirmed in A. When in B, I create the
invoice from it.

Specifications
==============

1/ Deprecate the parent/children hierarchy on the res.company model. The fields are
kept on the res.company model to ensure the retro-compatibility, but won't be used
accross the standard code anymore. The only functional usage for this mechanism
was to allow to see records from several companies by creating a virtual parent
company, which will be possible with the new mechanism.

2/ By default, a user will only see the records of the company he is connected
to (or records without a company). (It is still editable by the user if needed).
For that, put this information in the user context, to allow having different
configurations on different browser tabs. Instead of having domains like
['|',
('company_id', '=', False),
('company_id', 'child_of', user.company_id.id)]
you'll have something like
['|',
('company_id', '=', False),
('company_id', 'in', company_ids)]
Note that the 'company_ids' is a value that is passed in the evaluation
context on the record rule, as we already have user, or time.
company_ids is a list of the ids of all the enabled companies in the
user's context.

3/ Out of the generic improvements brought by this task, this will illustrate
issues that could exist since several versions. For example, it should not be
possible to create a scrap order for the company A with a package of the company
B, or it should not be possible to create an invoice on the company A with
payment terms from the company B. Before the version 12.0, it was easy to
encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side
effect of the fact that the SUPERUSER_ID has become an inactive user was to
make it more difficult to introduce mismatch on the records, but haven't solved
the issue, as it was still possible to do it with parent companies
configuration. Some of these issues have been fixed in this commit, but all the
business flows should be re-tested to check if an ir.rule should be introduced
(eg: a multi company rule for stock.quand.package), if the company of a record
is correctly transfered to another record created from the first record (eg:
From a SO, create an invoice and a payment, the company of the sales order
should be transfered on the invoice and the payment, even if the company of the
sales order is A and I'm logged into the company B with the company A enabled.

4/ Currently, if I click on a button on a notification email (example 'View
Task'), I face a traceback if I'm not logged into the company of the record.
Now, if you click on a button and if you have access to the record, the correct
company will be automatically set.

5/ If I display a kanban view with several records from several companies (and
an image), all the images should be displayed.

6/ Currently if you copy paste an url, this will crash if you're not in the
correct company. This won't be fixed because it's quite impossible to do it in
a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into
the correct company, re-copy/paste -> Ok.

7/ 2 property methods have been added on the environment to retrieve the company
on which the user is logged in and the companies the user enabled, on a specific
tab.
That way, when creating a record, instead of doing
default=lambda self: self.env.user.company_id
do
default=lambda self: self.env.company_id
On the other hand, to retrieve the enabled companies, do
companies = self.env.company_ids

8/ Modify the Company Switcher widget to allow to log into another company
WITHOUT writing on the res.users (and thus bringing cache invalidation issues
and so on). Also allow to enable several companies and see records from several
companies, and independantly of the other browser's tabs.

9/ When focusing on a tab, save the current company configuration on the local
storage. That way, when doing 'CTRL+T' or a middle click, the context is
propagated to the new tab.

10/ Improve the error message in case of multi company access errors. Now, when
the user is in debug mode, display the related names of the records and the name
of the user who brings the issue.

11/ Remove the context erasing when writing on a res.users
This is probably coming from the migration to new API of the base module.
The context was not propagated at this moment, which was a common mistake at
that time. When migrating the module, probably by using the 'black box' method,
as the context was not propagated, it was erased on the new version. This is
now an issue because the context (i.e. the enabled companies) was erased when
writing on a res.users, leading to tracebacks.
See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624

12/ Fix the crash manager on redirect warnings. The issue is the following
- Create an invoice on a company without a configured CoA.
- Set a partner
- On the onchange_partner_id, a redirect warning is raised to propose you
to configure a CoA
- Click on 'Go to the configuration panel'
- A generic warning says something like 'Do you want to discard your changes?'
- Click on yes, the page refreshes, but not on the redirect action.
Now, set correctly the action on the hash, and reload instead. The breadcrumb is
lost for example, but you reach the correct action at least.

13/ Introduce a res.group to enable/disable the multi company per tab
feature.

14/ To help the users to know which tab is in which company, add the
possibility to have a favicon per company. When creating a company,
the classical 'O' icon is colored by default in a random color.

15/ Remove the company switcher on the frontend. This was mainly there
to allow a user to swicth to the company linked to the website.
This behavior is now transparent to the user. If the website A is
activated, then the company set on the context is the company of the
website.

16/ Deprecated the _company_default_get method on the res.company
model. Remove the method _get_company on the res.users model.

17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval
context. You can now use those variables on domains in the views to
access directly to the activated company.ies on the current tab.

TaskID: 1960971

closes odoo/odoo#32341

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-05-13 08:57:49 +00:00
Jorge Pinna Puissant 418babf7af [FIX] account: Invoice Analysis product quantity
To calculate the product quantity and the average price, two UOM are
used: The UOM of the product, and the UOM of the invoice line.

The UOM of the product it's mandatory in the product, but the product
itself it's not mandatory in the invoice. The UOM of the invoice line
it's not mandatory.

When either of the UOM is not filled, it gives as value NULL, and gives
'empty' as result of the calculation.

Now, we use the psql function COALESCE to return '1' when one of the UOM
is not filled.

closes odoo/odoo#33465

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-05-17 13:31:44 +00:00
Jorge Pinna Puissant d48da27e64 [FIX] account: Invoice Analysis total without sign
- Go to Accounting > Reports > Invoices
- Go to the pivot view
- Enable 'Total' and 'Untaxed Total' in the measures

The Total is wrong.

The sign of the total must be positive for the customer invoices and the
vendors refunds; and negative for the credit notes and the vendors bills.

Before this commit, the total of the credit notes and the vendors bills
weren't negative.

This occurs because the sign of the result of amount_total * invoice_type.sign
is different of the sign of amount_total_signed. Indeed amount_total is
the total amount without sign, and invoice_type.sign is used to change
the sign only for the vendors bills and the vendors refunds
(see https://github.com/odoo/odoo/blob/3cf9cfc985950c30c6b76480f77f5ffe53650b24/addons/account/report/account_invoice_report.py#L144).
Contrariwise amount_total_signed is the total amount signed : negative
for the credit notes and the vendors refunds.

Later on the calculation, the total amount is multiplied to
invoice_type.sign, to have the signs as expected
(see https://github.com/odoo/odoo/blob/3cf9cfc985950c30c6b76480f77f5ffe53650b24/addons/account/report/account_invoice_report.py#L118)

Fine tuning of this commit: 4218f3b

opw-1999175
2019-05-17 13:31:44 +00:00
Nicolas Martinelli 4218f3b5fb [FIX] account: Invoice Analysis
- Go to Accounting > Reports > Invoices
- Go to the pivot view
- Enable 'Total' and 'Untaxed Total' in the measures

The Total is wrong.

`amount_total` is retrieved on the invoice, unlike the subtotal which is
retreved on the invoice line. We apply the same logic than
`residual_company_signed`.

opw-1950663

closes odoo/odoo#31991

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-03-20 15:11:23 +00:00
Lucas Perais (lpe) 6a24660f7e [FIX] account: aged partner: partner can be unknown
Have one move with
- one debit in receivable with a partner which has a partner.category on it
- one other debit in receivable, without a partner
- one credit wherever

Open the aged partner balance report, filter partners on the relevant tag (partner.category)

Do the same with a move with an earlier date that will put the amounts in a different column

Before this commit, it crashed because some result variable did not contain
the key "False"

After this commit, it doesn't crash

OPW 1933749

closes odoo/odoo#30603
2019-01-28 12:03:03 +00:00
qdp-odoo 98313838da [FIX] account: aged partner report
The aged reports were wrongly taking the previous day of the requested date to compute the different report periods.
E.g: An aged balance requested for the 31-12-2018 was excluding entries made on the that exact date and was starting from the 30-12-2018

closes odoo/odoo#30195
2019-01-14 14:33:52 +00:00
Christophe Simonis caf1837216 [MERGE] forward port branch saas-11.3 up to d4c65a7ede 2018-12-05 12:27:57 +01:00