Commit Graph
62 Commits
Author SHA1 Message Date
Gorash 75a105f46a [REF] base/all: Update modifier syntax: remove 'states' from fields
These changes are made as a result of simplifying attrs and 'states' in
views. However, they should have remained in a separate commit. When
applying the script making the xml changes (used later for the migration
script), the script checked the definition of the python fields in order
to convert the information into a python expression. Therefore, this
commit is not applied when the script is applied to xml changes.

During this attribute deletion pre-existing errors were found. Part of
the code was using the boolean values of 'states' and another part of
the code was not. The behavior could therefore be different (in cases
where readonly on the field had the same value as the ballan in
'states').

Following the deletion of 'states' and without the application of the
view migration, the js tests (tower) were no longer functional. Tests
using the Form view suffered the same effect. There are few tests that
had to be adapted, including two tests in business accounting (updated
by the accounting team). A test for column_invisible did not work. Test
checking if the test system triggers an error if we try to write on an
invisible field. It turns out that Form was testing on the value of
invisible but not taking into account if the column was invisible. The
test system fix is applied separately because there were a lot of tests
that were incorrect.

Part-of: odoo/odoo#104741
2023-08-18 09:49:11 +02:00
Rémy Voet (ryv) c5cb357d90 [IMP] *: add dependencies to display_name field
The previous commit introduced an optimization to reduce the number of
queries and fields fetched when we call `name_search`. But it works much
better when the dependencies of `display_name` contain field names used
in the calculation (on the same record/model).

Then, to improve the performance and the cache coherency, add `depends`
and `depends_context` depending on the custom `_compute_display_name`.
Add only the first level of dependencies (never traverse relational
field) because only these have a positive impact on the previous
optimization and the cost is very low (see `modified`).
About `depends_context`, we don't include `lang` because (when `_` is
used by example) it is unlikely to get the same display_name in the same
request with two different lang.

closes odoo/odoo#122085

Related: odoo/documentation#4639
Related: odoo/enterprise#42599
Related: odoo/upgrade#4780
Signed-off-by: Raphael Collet <rco@odoo.com>
2023-06-28 17:41:19 +02:00
Rémy Voet (ryv) 3c62ca1eb9 [REM] core: remove name_get API
Rationale
=========

Since v8, the `display_name` field is present on all models. By default,
`display_name` uses `name_get` which has pretty much the same purpose
(return record name used by the web client). Gradually, many (backend)
developers (and the ORM: https://github.com/odoo/odoo/commit/6da1c3ac4c036eac289597602976538e243cb939)
started using `display_name` (more convenient than
`record.name_get()[0][1]`) but it still had the `name_get` override.
It becomes more complex than necessary and poeple start to misunderstand
the two (and sometimes override both, leading to inconstiencies between
`display_name`/`name_get`).

To simplify the ORM and the API, we decided to keep only one of them,
the `display_name` field:
- It is much more convenient from a backend point of view
(`record.name_get()[0][1]` vs `record.display_name`)
- It is cached during the same transaction (and invalidated if
its dependencies change)
- It can be overridden like any other compute field (override
`_compute_display_name` with any extra dependencies)
- `name_get` is replaced by `read(['display_name'])`
(API perceptive), which can actually be more efficient
(if `display_name`'s depends are correct, the ORM will only fetch the
fields it needs instead of every prefetchable field)

Changes
=======

- Deprecates `name_get` for the v17 and based the method on
`display_name` (the opposite of before)
- Converts all usage of `name_get`
- Overrides of `name_get` are now overrides of `_compute_display_name`
- For `res.partner`, rename the field store `display_name` into
`complete_name` because `display_name` context-dependent and it makes
no sense to have a compute store that is context-dependent.
- Previously, it was possible to return multiple names for the same
record with `name_get`, but it was tricky and most of the usage of
this `name_get` didn't take this into account. The only example of
this is the `name_get` of `product.product`
(now use `", ".join(<names>)`).

Part-of: odoo/odoo#122085
2023-06-28 17:41:19 +02:00
Maximilien (malb) deee288909 [IMP] l10n_{latam_invoice_document,ec,ar,cl}: translate
In the following task (https://github.com/odoo/odoo/pull/112803) there is two commits. One of them remove a change made in the other by mistake. We did a PR in saas-16.2 to revert the impacted localisation (https://github.com/odoo/odoo/pull/116292). The goal of this pr is to add back the translation for latam invoice documents.

closes odoo/odoo#116224

Task-id: 3244168
Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-03-23 19:13:49 +01:00
william e7df30a565 [IMP] account{,_sequence}: merge
This module was added in stable but was never intended as a separate
module.

closes odoo/odoo#106413

Related: odoo/upgrade#4073
Related: odoo/enterprise#37844
Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-03-07 18:02:19 +01:00
Maximilien (malb) d1b04bdf7e [IMP] l10n_ar: translation
Before this PR, all this localisation was written in Spanish, but all the localisation have to be written in english and then translated back in the native language. This PR correct that.

closes odoo/odoo#112803

Task-id: 3179209
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
2023-02-24 10:06:18 +01:00
Maximilien (malb) dae0b7ae9f [IMP] l10n_latam_invoice_document: removing duplicated code
Before this commit, the name and report name of document type for latam localization had been added in each latam localization. Since they depend on l10n_latam, we decided it would be better to just add translate=True to already existing field (name and report_name) instead of adding new field in those module. This commit corrects that.

Task-id: 3179209
Part-of: odoo/odoo#112803
2023-02-24 10:06:18 +01:00
wan 5125748616 [REF] account: remove chart template
Rewrite the whole chart template mechanism, removing the templates
stored in the database. The new format will mainly use CSV.

Speed up install time
---------------------

* About half of the time of installing a localization for the first time is
  taken by creating the template records. This new in code format gets
  completely rid of this.
* Creating the template records could often not be done in batch because
  of parent/children relations.
* The instanciation of the accounts on the company has been entirely
  reworked too, by
  - optimizing the order of creation of records to avoid UPDATE queries
  - using precomputed fields to avoid UPDATE queries
  - updating the translation in batch
  - deactivating logging in the chatter
  - avoiding access rights checks by checking the rights at the start

Overall, when installing a chart template for the first time, it is 4
times faster because half of the time spent on saving the template in
the database is not done at all anymore, and the instanciation on the
company is more than twice as fast.

Reduce technical debt
---------------------

There is no need to synchronize the templates with the real records
anymore. No need to use hooks to copy the data from one to the other.

It is easier to change a template in a stable version, which can often
be necessary due to legal reasons (i.e. a change of tax rates, reporting
tags,...)

Two modules have been removed:
* `l10n_generic_coa`: since there is nothing left datawise in this
  module, it can be integrated in `account` for free. It is just code
  and CSV.
* `l10n_multilang`: the fields that this module modified to be
  translatable are now always translatable:
  - there was an issue when updating modules that deleted all the
    translations because the fields were not translatable at some point
    during the loading of the registry, then they because translatable
    again but lost all translations because of the column type change.
  - most devs are not able to understand all the languages needed for
    all the localization available. Therefore, english has been added in
    the sources in most localization to understand better issues while
    debugging.
  - no need to call post init hooks anymore, doing the sync with the
    templates.
  - more: see "Translations" section

Because most of the data is now in CSV, it is also easier for product
owners to edit, audit, modify files themselves, removing one layer
during trivial development processes when only data should be changed.

More flexibility for declaration
--------------------------------

The data declaration can now be done easily in python or CSV.
A nice feature is that you can declare everything at once, even for some
more complex chart of accounts:
* if you have to set default taxes on accounts, would need to
  - declare the accounts because accounts are required on the taxes
  - declare the taxes
  - declare the taxes to put on the accounts
  This would lead to scatter information in multiple files. Now,
  everything can be declared in the same place and the loading of the
  chart of accounts will do the 3 steps automatically.
* if you have a relation of child/parent, you would first need to
  declare the parents then the children, and the loading would not be
  efficient because done one by one. Now, everything is done in batch
  automatically without having to think about it.

It is also easier to update fields on records where there was no field
for that on the templates, like
* setting a restriction for journals on accounts
* setting specific values on the company
* modifying journals and linking them easily by using the xml_id instead
  of having to compute it manually

Translations
------------

Some countries have multiple languages (i.e. Belgium uses officially
French, Dutch and German, and the CoA also has an official English
version) and we must support the languages in all these countries.
All these translations are known, and hard coded without using out
translation platform (Transifex). We also like to have the English
version (even if an official one doesn't exist) so that support can be
done more easily in databases using chart templates in other languages
(especially using a non roman alphabet).

Because the translations were not on Transifex for these records, it was
really hard to maintain: the translation templates (`.pot` files) were
not easy to extract as the automatic export would give values mixing
both the CoA and the menuitmes, the fields' strings,... But we don't
want to translate the CoA as we already know the value.
Managing the translations in the `.po` files was also annoying:
- it is easy to forget that the translations need an update too
- it requires a special editor, special terminal commands that everyone
  is not familiar with
- it is easy to make mistakes in the source string

The new format is the following: `field@en_US` where `field` is the
translatable field (usually `name`) and `en_US` is the locale code.
This allows to have the whole declaration on one line, everything in one
file. It also makes the process easier when debugging: instead of
searching for the translation in the `.po` files, it directly appears
next to the configuration of the account/tax/... .

Update of the code
------------------

The code can be updated using this script
https://github.com/william-andre/transform_coa
Forward ports can be managed too by stashing/resetting/checkout the new
modules or the changes in the modules updated in the same PR.

task-2687567

Part-of: odoo/odoo#110016
2023-02-17 19:30:40 +01:00
Josse Colpaert f07b8beb1a [IMP] l10n_latam_invoice_document: avoid changing back document number as well
The previous commit solved the issues for the Belgian, ... case, but not
for l10n_latam_invoice_document.

We saw two extra problems we solved:
- As the name is readonly you can not even store the new name easily, so
we needed a force_save on that field.
- As the _compute_name is inherited in this module as well, there is a
logic that recomputes the name when the document type is changed and the
invoice is in draft to recompute that initial value.
However, when you confirm and the date gets set, that logic
is also triggered, while we do not want to recompute but keep
our old document number.

closes odoo/odoo#111294

X-original-commit: 7edee80545daf29b3a46947838a23e1f4458f12d
Related: odoo/enterprise#36434
Signed-off-by: William André (wan) <wan@odoo.com>
2023-01-29 03:41:52 +01:00
Andrea Grazioso (agr-odoo) 691ef8e9f7 [FIX] l10n_latam_invoice_document: wrong name on batch post
Have a Peru company setup
Create 2+ draft invoices of mixed type 'Boleta' and 'Factura'
In list view select the created moves and do action>"post entries"

The posted entries will have the same name prefix, either all 'BOL' or
'FFI', depending on the first computed name, the system will use the
same prefix for the remaining move names

opw-2860231

closes odoo/odoo#95271

X-original-commit: d7a5b34e46436f49592ab6706ac33bcf7a3fbf80
Signed-off-by: William André (wan) <wan@odoo.com>
2022-07-04 19:57:51 +02:00
william 3155c3e425 [IMP] core,*: add helper for name_search
Most of the extensions of `_name_get` are very similar and only want to
search for the given string in multiple fields.
A lot of extensions also don't take into account the negative operators.
Some implementations were also really outdated and needlessly
complicated.

closes odoo/odoo#86588

Related: odoo/enterprise#25608
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-04-06 18:37:39 +02:00
Raphael Collet a1904aa6f6 [IMP] core: field index names
The possible index names have been renamed "btree", "btree_not_null"
(instead of "not null") and "trigram" (instead of "gin").

Task 2742526

Part-of: odoo/odoo#83274
2022-01-28 14:10:01 +00:00
Fabien Pinckaers eedf37d6e2 [IMP] Better handling of indexes
Three supported types:
- btree (default for index=True)
- btree not null (when >90% of the data are null)
- gin trigram search (for char fields)

Review of indexes on all objects.

closes odoo/odoo#83015

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-01-19 16:52:23 +00:00
Daniel Blanco d85a8acdcc [FIX] l10n_cl: modifications needed to create electronic vendor bill document type (46) since it is mandatory for some customers.
Adds new account to withhold vat tax, and new vat tax
Enables document type 46
Allow electronic docs in purchase journals
[FIX] l10n_latam_invoice_document Consider doc type 46 as a vendor document
More information -> https://www.sii.cl/preguntas_frecuentes/catastro/001_012_3665.htm

[RM] l10n_cl: remove _filter_taxes_included method

closes odoo/odoo#79479

X-original-commit: 0c34fe795cee7eb6f0c5678f9e505ccc9b6e57e8
Related: odoo/enterprise#22160
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-11-08 11:08:06 +00:00
Bruno Zanotti (ADHOC)andJuan Jose Scarafia ee7e20f49d [IMP] l10n_latam_invoice_document: remove fields
Fields removed:
 * l10n_latam_amount_untaxed
 * l10n_latam_tax_ids
 * l10n_latam_price_unit
 * l10n_latam_price_subtotal
 * l10n_latam_price_net

Methods removed:
 * compute_l10n_latam_prices_and_taxes
 * compute_l10n_latam_amount_and_taxes
 * _compute_invoice_taxes_by_group

We move the removed methods to l10n_ar and l10n_cl and now it returns
a dictionary with the removed fields as the keys.

X-original-commit: 667ffb286d27f1e7a834b15d8f61536e530acd6f
Part-of: odoo/odoo#78296
Co-authored-by: Juan Jose Scarafia <jjs@adhoc.com.ar>
2021-10-14 16:16:04 +00:00
oco-odoo 45c4a29e82 [FIX] l10n_latam_invoice_document: fix overridden function's name
It did not correspond to its parent, and hence wasn't called.

closes odoo/odoo#77112

X-original-commit: fe804d0882e0b378449f9c1c02a1e925c5779db8
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-09-27 16:56:35 +00:00
oco-odoo d9a3b938fe [IMP] account, sale, purchase, l10n_latam, l10n_ar: add the possibility to use subtotals above tax groups when displaying them
A new field on tax groups makes it now possible for this group to be displayed under a subtotal label. If not set, this defaults instead to "Untaxed Amount", keeping the traditional behavior. This is intended for withholding taxes, which can now be implemented with negative taxes and a tax group with this field set.

To do that, this commit entirely refactors the way amount_by_group worked, and replaces it with a more complete json field called tax_totals_json. It also streamlines the way taxe totals are displayed on invoices, PO and SO and makes it so that a common code is called instead of copy-pasting the same block 3 times as before.

[IMP] purchase: always display tax totals by groups on purchases orders

Before, tax totals on purchase.order's form were not shown by group, and were instead all aggregated in a single "Taxes" category. The same went for the pdf export. The portal view, though, did show the totals by group. We now display the tax groups in the same way all the time.

closes odoo/odoo#74138

Task: 2457374
Related: odoo/enterprise#19802
Related: odoo/upgrade#2670
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2021-09-02 14:15:13 +00:00
Katherine Zaoral 3654addf5c [IMP] l10n_cl, l10n_latam_invoice_document: move field
move l10n_latam_document_type_id_code field definition to latam module
in order to be re used by another latam localizations

closes odoo/odoo#75764

Related: odoo/enterprise#20513
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-09-01 09:38:51 +00:00
Nikunj Ladava 09f2e91105 [IMP] l10n_latam_invoice_document: remove sequence
- removed unsed l10n_latam_document_type_id from the sequence

task- 2464212
2021-08-03 13:01:39 +00:00
wan 0df91f7ca7 [FIX] l10n_latam_invoice_document: adapt compute method to constraint
The compute method `_compute_l10n_latam_document_type` could give
results that were not satisfied by the constraint
`_check_invoice_type_document_type`.
2021-07-19 10:14:25 +00:00
Josse Colpaert 6ab7290c36 [FIX] l10n_latam_invoice_document: do not restrict the inverse/onchange too much
The onchange/inverse would only be triggered in the case of manual document number (vendor bills)
or not highest_name, but in other localizations there are cases where we want to be more flexible
to when we change it and instead of inheriting the method, we can relax it here.

Also, it should have been avoided before already to change the document number and type in those situations
through the attributes in the view e.g.  This seems to have been more like an extra fail-safe blocking us
elsewhere.

closes odoo/odoo#73397

X-original-commit: a3f8e53deb45034250820ff54ba76288af167b6e
Signed-off-by: William André (wan) <wan@odoo.com>
2021-07-07 17:42:10 +00:00
Bruno Zanotti (ADHOC) b039bd92d5 [FIX] l10n_latam_invoice_document: unit price rounding
For the unit price (field l10n_latam_price_unit), we need the number
rounded based on the product price precision.

To compute it we use the method compute_all that rounds using the
currency accuracy, so to fix this we multiply and divide for
10^(decimal accuracy of product price) to get the price correctly rounded.

Steps to replicate the error:
    1) In a base with l10n_ar localization installed change the decimal
       accuracy of "Product Price" to 5 digits (keeping the currency
       precision in two digits).
    2) Create an invoice with a product with price $10.12345
    3) Print the invoice and check the column price unit.
       Before this commit, the price unit would be $10.12000.

closes odoo/odoo#72579

X-original-commit: 17e19c6bf787fd2bf77476ffcfa1d934058aa7ec
Signed-off-by: William André (wan) <wan@odoo.com>
2021-06-22 18:39:04 +00:00
Bruno Zanotti (ADHOC) 6101a19512 [FIX] l10n_latam_invoice_document: monetary fields
The fields l10n_latam_price_unit and l10n_latam_price_net should be
float instead of monetary in order to show rightly the decimal
accuracy on invoice's reports

closes odoo/odoo#69344

X-original-commit: 59afbc2e34c80516fa412de92f0d3bba2378661e
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-04-15 18:33:53 +00:00
Bruno Zanotti (ADHOC) e658ca9100 [FIX] l10n_latam_invoice_document: IVA on b2c invoices
For b2c invoices we mustn't show the IVA information on the reports

closes odoo/odoo#68758

X-original-commit: 4e31502f317fabc2004bd6db32883ce357563c57
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-04-03 10:49:03 +00:00
oco-odoo 17610e8ca9 [IMP] account, account_edi, l10n_*, purchase, sale: Generalize the use of account_fiscal_country_id
Before, account_fiscal_country_id was only use for tax operations; and country_id was used for all the other accounting stuff. Now, with the new ability to use foreign tax reports (with foreign VAT fiscal positions), we can generalize the fiscal country, sot that it is the one that needs to be used for the whole accounting. Since foreign tax reports were not supported before, account_fiscal_country_id is already set on existing database as the country for the "main" accounting, so the impact of this change is small.

closes odoo/odoo#68349

Related: odoo/upgrade#2322
Related: odoo/enterprise#17299
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-04-01 12:09:20 +00:00
Josse Colpaert ca4a25d884 [FIX] l10n_latam_invoice_document: only trigger constraint when partner_id is set
Before, when importing twice the same invoice, or even with the more
theoretical possibility of having the same number for different partners,
the constraint would be triggered, giving unnecessary problems when
importing vendor bills with an uncertain partner_id.

If we check the logic followed in the regular accounting on the ref field,
it only triggers when a partner is set, so we can follow the same logic here.

closes odoo/odoo#68408

X-original-commit: 9cbf63bd644d6d6d629266fe31edc91b44f22aa6
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-03-26 14:39:01 +00:00
Bruno Zanotti (ADHOC) d757c02d8c [FIX] l10n_latam_invoice_document: update of the method _compute_invoice_taxes_by_group
Odoo has made some modifications to the method
_compute_invoice_taxes_by_group from de Account module,
so we need to update the inherited method in the argentinian localization

Improves:
 - Don't depend on price_subtotal to compute amount_by_group
 - Show taxes when they are zero on invoices print

closes odoo/odoo#68178

X-original-commit: 011631a38564bcbdd8625428b9f897aefefce270
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-03-20 23:47:27 +00:00
Nicolás Mac Rouillon cee7b7cb1f [FIX] l10n_latam_invoice_document: For the latam invoice reporte show the base property in the correct value and currency
The problem that occurs before of this commit, is due the base of the taxes is in the currency of the company not in the invoice currency. For that the value that shows in this cases for the base is not correponding for the symbol of the currency.
After this changes we show the correct value an symbol for the base converting the value when is necessary.

X-original-commit: 4fd4f82ecd1b97f608168baaa780844f68e8a9d7
2021-03-20 23:47:27 +00:00
fw-bot 9fd700c82c [IMP] l10n_latam_invoice_document: Remove l10n_ar constraint on base latam module
Documents with `l10n_latam_document_type_id.code == '99'` just exists on **l10n_ar**
https://github.com/odoo/odoo/blob/13.0/addons/l10n_ar/data/l10n_latam.document.type.csv#L74 making this error arise
on other localizations which don't use it.

This was mistakenly introduced on 7748e0e

This method is inherited inside l10n_ar and we add this additional validation.

Original PR: https://github.com/odoo/odoo/pull/64831

closes odoo/odoo#68066

X-original-commit: 109b4b1aaac4d76ef273fb88d27e2b648331a266
Signed-off-by: Josse Colpaert <jco@openerp.com>
2021-03-18 11:00:33 +00:00
wan 072558c43d [FIX] l10n_latam_invoice_document: compute document type multi
Part of task 2124952
2021-02-17 08:39:29 +00:00
Nasreddin (bon) eb0b664349 [FIX] account: Negative fixed taxes on 100% discount
Issue

	- Install 'Accounting' module
	- Create a new 'Tax' X with a fixed price (e.g.: O.O57 $)
	- Create a new 'Customer Invoice'
	- Add a product P and set unit price to 0 $
	- Set tax X to product P

	Total tax amount : - 0.06 $ .

Solution

	The sign must be forced to a negative sign in case the balance is on credit
	to avoid negatif taxes amount.

enterprise PR : https://github.com/odoo/enterprise/pull/15035

opw-2378978

closes odoo/odoo#62758

X-original-commit: 684855529e8aaafa0cb90f958d19c563d6e2a897
Related: odoo/enterprise#15105
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-12-02 15:51:55 +00:00
Nicolás Mac Rouillon 51897a1499 [FIX] l10n_latam_invoice_document: Wrong calculation for the subtotal in the invoice report.
For this case, if the invoice currency is different from the invoice company currency, the tax calculation is considered the value in a different currency, and the subtotal is the sum of the amount untaxed + the taxes (wrongly in company currency) result in an incorrect value. This is verified when printing the invoice report

closes odoo/odoo#62388

X-original-commit: 91f152f479923a1d28dadcb3ded7c0296cc585fc
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-11-26 11:23:25 +00:00
Denis Ledoux 839c1857fe [FIX] l10n_latam_invoice_document: skip document_type computation on install
Skip the computation of the field `l10n_latam_document_type_id` at the module installation.

The case has been detected during an upgrade from Odoo 12.0 to Odoo 13.0,
but the case could really well happen outside the context of an upgrade,
for instance when you create a new subsidiary in Chile or Argentina
while you already have a lot of accounting entries in your other subsidiaries
(e.g. Odoo S.A. opens a new office in Chile and has to install `l10n_cl`)

Without this, at the module installation,
it would call `_compute_l10n_latam_document_type` on all existing records
which can take quite a while if you already have a lot of moves. It can even fail with a MemoryError.

In addition, it sets `_compute_l10n_latam_document_type = False` on all records
because this field depends on the many2many `l10n_latam_available_document_type_ids`,
which relies on having records for the model `l10n_latam.document.type`
which only happens once the according localization module is loaded.
(e.g. `l10n_cl/data/l10n_latam.document.type.csv`)

The localization module is loaded afterwards, because the localization module depends on this module,
(e.g. `l10n_cl` depends on `l10n_latam_invoice_document`, and therefore `l10n_cl` is loaded after)
and therefore there are no records for the model `l10n_latam.document.type` at the time this fields
gets computed on installation. Hence, all records' `_compute_l10n_latam_document_type` are set to `False`.

In addition, multiple localization module depends on this module (e.g. `l10n_cl`, `l10n_ar`)
So, imagine `l10n_cl` gets installed first, and then `l10n_ar` is installed next,
if `l10n_latam_document_type_id` needed to be computed on install,
the install of `l10n_cl` would call the compute method,
because `l10n_latam_invoice_document` would be installed at the same time,
but then `l10n_ar` would miss it, because `l10n_latam_invoice_document` would already be installed.

Besides, this field is computed only for drafts invoices, as stated in the compute method:
`for rec in self.filtered(lambda x: x.state == 'draft'):`
So, if we want this field to be computed on install, it must be done only on draft invoices, and only once
the localization modules are loaded.

It should be done in a dedicated post init hook,
filtering correctly the invoices for which it must be computed.

Though I don't think this is needed.
In practical, it's very rare to already have invoices (draft, in addition)
for a Chilian or Argentian company (`res.company`) before installing `l10n_cl` or `l10n_ar`.

```
Traceback (most recent call last):
  File "/src/odoo/13.0/odoo/service/server.py", line 1190, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/src/odoo/13.0/odoo/modules/registry.py", line 86, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/src/odoo/13.0/odoo/modules/loading.py", line 423, in load_modules
    loaded_modules, update_module, models_to_check)
  File "/src/odoo/13.0/odoo/modules/loading.py", line 315, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/src/odoo/13.0/odoo/modules/loading.py", line 202, in load_module_graph
    registry.init_models(cr, model_names, {'module': package.name}, new_install)
  File "/src/odoo/13.0/odoo/modules/registry.py", line 364, in init_models
    env['base'].flush()
  File "/src/odoo/13.0/odoo/models.py", line 5458, in flush
    self.recompute()
  File "/src/odoo/13.0/odoo/models.py", line 5875, in recompute
    process(field)
  File "/src/odoo/13.0/odoo/models.py", line 5859, in process
    recs.mapped(field.name)
  File "/src/odoo/13.0/odoo/models.py", line 5266, in mapped
    recs = recs._mapped_func(operator.itemgetter(name))
  File "/src/odoo/13.0/odoo/models.py", line 5225, in _mapped_func
    vals = [func(rec) for rec in self]
  File "/src/odoo/13.0/odoo/models.py", line 5225, in <listcomp>
    vals = [func(rec) for rec in self]
  File "/src/odoo/13.0/odoo/models.py", line 5690, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/src/odoo/13.0/odoo/fields.py", line 2329, in __get__
    return super().__get__(records, owner)
  File "/src/odoo/13.0/odoo/fields.py", line 995, in __get__
    self.compute_value(recs)
  File "/src/odoo/13.0/odoo/fields.py", line 1109, in compute_value
    records._compute_field_value(self)
  File "/src/odoo/13.0/odoo/models.py", line 3968, in _compute_field_value
    field.compute(self)
  File "/src/odoo/13.0/odoo/fields.py", line 579, in _compute_related
    record[self.name] = self._process_related(value[self.related_field.name])
  File "/src/odoo/13.0/odoo/models.py", line 5699, in __setitem__
    return self._fields[key].__set__(self, value)
  File "/src/odoo/13.0/odoo/fields.py", line 1070, in __set__
    self.write(protected_records, value)
  File "/src/odoo/13.0/odoo/fields.py", line 2564, in write
    cache.update(records, self, [cache_value] * len(records))
  File "/src/odoo/13.0/odoo/api.py", line 768, in update
    field_cache.setdefault(record_id, {})[key] = value
MemoryError
```

Upgrade request 49495

closes odoo/odoo#60573

X-original-commit: f2a08faa1e65cb381315cbd5d1a359901e8b7deb
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-10-22 20:49:20 +00:00
fw-bot 1c77b833d6 Cherry pick of 2b65a7c111232d31d5113565bb6a114486f0123c failed
stdout:

stderr:

closes odoo/odoo#58605

Error: could not apply 2b65a7c1112... [IMP] l10n_ar: Accounting Tour adaptation
Hint: after resolving the conflicts, mark the corrected paths
Hint: with 'git add <paths>' or 'git rm <paths>'
Hint: and commit the result with 'git commit'
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-09-29 13:46:59 +00:00
Katherine Zaoral 6b2d2bb18d [IMP] l10n_latam_invoice_document: remove context key
internal_type context key is not used anymore, now use the
debit_origin_id directly to know if the current account.move is a debit note

closes odoo/odoo#56673

X-original-commit: c45edd11a048d4822b1ffd5dcebdb63d0e0e8f45
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-08-27 14:39:23 +00:00
oco-odoo c07685e362 [IMP] l10n_ar, l10n_cl, l10n_latam_invoice_document: replace l10n_latam_country_code field by newly-introduced country_id
This new field was introduced in master by https://github.com/odoo/odoo/commit/013936261b26c601ce55015dbbbb99a7313a9a39 , making l10n_latam_country_code redundant.

closes odoo/odoo#56181

Related: odoo/upgrade#1666
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-08-20 08:00:30 +00:00
Raphael Collet 1f48130d2b [REF] core: _name_search() now returns a list of ids
This provides a better API to search for records by name without the
formatting part (`display_name`).

This also simplifies all the overridings of `_name_search` that no
longer need to call `name_get()`.  The call to `name_get()` is done in
method `name_search` in a generic way.
2020-08-18 13:02:41 +00:00
william 82dc0cb7b9 [IMP] account: soft post entries in the future
Add an easy way to not post the entries in the future when calling
post() on it, but rather set it to be auto-posted at accounting date.
This is useful when we are creating a lot of entries in batch and some
might be in the future, some in the past, and we don't want to separate
that in two batch every time. (asset, accrual, transfer,... )
2020-08-05 11:57:10 +00:00
Martin Trigaux 400cc4f14e [FIX] *: correct all or improve code translation lookup
This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
  _("Foo %s", bar)

to progressively migrate the code to the new syntax.

A few calls were not technically incorrect but still detected by the
linter.

  _("Foo" +
    "Bar")

has been converted to

  _("Foo"
    "Bar")

as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).

closes odoo/odoo#53683

Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-30 10:19:59 +00:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
Katherine Zaoral e8286ce4d9 [IMP] l10n_latam_invoice_document: adapt to new sequences
* remove logic of sequences in invoices and use new logic to set invoices sequences.
* re add l10n_latam_document_number field to make the sequence set possible.
* replace type field with move_type field in model account.move
* add new field l10n_latam_manual_number to know when the document number should be or not set
* update compute highest_name everytime that the journal and document type change.
* implement how we deal with first number
* for customer invoices only compute the name after they has been posted
* be able to search by document type code
* update translations
2020-04-01 16:48:53 +00:00
Pratima Gupta 2c93b994f2 [IMP] l10n_xx: use country_code field
l10n_latam_country_code field is no more needed for account.move
object thanks to commit 7edb5c11

Also, since country_code field has been defined in view_move_form,
no need to redefine it when it is inherited in l10n_cn module.

closes odoo/odoo#48719

Task: 2228210
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-04-01 14:23:20 +00:00
Katherine Zaoral 191530059f [IMP] l10n_ar: be able to generate refunds for OTROS COMPROBANTES document type
This document does not have any credit/debit note related documents, so
when a credit/debit not is required then the same document type is used.
This only applies in vendor bills so we are able to create the credit
note with this type of document

closes odoo/odoo#48117

X-original-commit: 7748e0e87fd3f4677a4026ed06516d36e8d52ad5
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-03-20 13:53:39 +00:00
Xavier Morel ff53bdfb09 [FIX] l10n_latam_invoice_document: check of account_move type
The `type` field was renamed `move_type` in
d675dbaa4c but a forward-port re-added a
use of the old `type` name, which breaks if an account.move is
unlinked while l10n_latam_invoice_document is unlinked (and there are
related moves to update).

Instead of renaming the field, use the proper utility method for the
category (purchase) provided by account.move.

closes odoo/odoo#47301

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-03-10 14:54:42 +00:00
Christophe Monniez 952c668b82 [FIX] account, l10n_latam_invoice_document: fix move_type typo
Two typos were introduced with d675dbaa4c.

closes odoo/odoo#45926

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-02-21 12:18:32 +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
Katherine Zaoral 62516ae5ff [FW][FIX] l10n_latam_invoice_document: proper validate vendor bills
Formerly the vendor bills, customer invoices and regular journal items were
evaluated by the _check_unique_sequence_number method, but this is wrong
and also was overwritten Odoo original constraint error message.

Now the _check_unique_sequence_number evaluate the account.moves that are
not vendor bills that use documents because this kind of bills uniqueness
depends on the vendor: we can have same name of vendor bill from different
partners. This is evaluated in the already existing
_check_unique_vendor_number method

closes odoo/odoo#44813

closes odoo/odoo#45643

Original-signed-off-by: Josse Colpaert <jco@openerp.com>
X-original-commit: beaa3bbacd4bd35ed11962a7466f111e5e85f0d8
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-02-18 14:09:25 +00:00
fw-bot 7954594d12 [FW][REF] account: new method _prepare_default_reversal
to be able to inherit these methods to make it easier to
add fields in the refund wizard e.g.

closes odoo/odoo#44629

X-original-commit: e814374a20de096fd795aec34ab0e3de4977fc85
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-02-06 10:02:56 +00:00
wan dfd01b8c5c [IMP] account: rework name sequences
Task 2146469

Rework the name computation:
* It doesn't use ir.sequence anymore
* It is an editable computed field
* Add a renaming tool

This allows the user to tweak the sequences more easily than having to
get through the ir.sequence settings.

The sequence depends on a parameter of the journal: continuous, montly
and yearly restart of the sequence. Everytime a new period is started,
try to make a pattern form another period.

The incrementing is done by taking the previous name, ordered
lexicographically, splitting it by taking the digits at the end, adding
1 and re contstruct with the prefix.

** This means there could be cases where the prefix has a big importance
on the next number. For instance, if you have
INVOICE/2019/0001
INVOICE/2019/0002
and then rename the last one to INV/2019/0002, don't expect the next
number to be INV/2019/0003. It will be INVOICE/2019/0002 (again) because
the highest number was INVOICE/2019/0001.
You will then end up with
INVOICE/2019/0001
INV/2019/0002
INVOICE/2019/0002

closes odoo/odoo#41485

Related: odoo/enterprise#7189
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2020-02-05 13:59:43 +00:00
Juan Jose Scarafia 58732e4dc8 [FIX] l10n_latam_invoice_document: bill unlink
closes odoo/odoo#44415

X-original-commit: fd8af7976b83656256edb563552edb7d4d324650
Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-01-31 16:29:29 +00:00