Commit Graph

85 Commits

Author SHA1 Message Date
Víctor Martínez
2b0122ef4f [IMP] contract: Set fixed start dates in test contracts 2022-12-07 08:23:41 +01:00
Víctor Martínez
4d55c73699 [IMP] contract: Set invoice_user_id field with Form() to apply the correct values of other fields (team_id for example).
TT39934
2022-10-18 15:54:49 +02:00
Denis Roussel
266780115a [FIX][15.0] contract: Fix forwardport from 14.0 #741 2022-06-22 11:23:07 +02:00
Denis Roussel
188822f9bf contract: Improve multi-company tests / don't break former tests structure 2022-06-22 11:23:07 +02:00
Denis Roussel
de8f06b11f contract: Simplify test flow 2022-06-22 11:23:07 +02:00
Denis Roussel
92e551cd22 contract: Improve tests
Adds multi company tests
2022-06-22 11:23:07 +02:00
Jean-Charles Drubay
4a73cbbe2b ADJ: When generating invoices from the Wizard to create invoices manually, reraise any UserError with information about which contract triggered the exception to facilitate the investigation by accountants in case invoices are not generated automatically. 2022-02-18 08:09:30 +01:00
Jean-Charles Drubay
119b5b6700 [MIG] contract: Migration to 15.0
Most changes are related to the switch from jinja to qweb in mail templates.

Also included:
- convert deprecated onchange that returns a domain and other deprecation warnings
  (see below)
- Add migration scripts from version 14.0 (force the update of the mail templates)
- Fix warnings from pre-commit checks

Fixes depreciation warnings:

- onchange method ContractAbstractContractLine._onchange_product_id returned
  a domain, this is deprecated
- SavepointCase is deprecated:
  https://github.com/odoo/odoo/blob/15.0/odoo/tests/common.py#L742
- assertDictContainsSubset: According to:
  https://stackoverflow.com/questions/20050913/python-unittests-assertdictcontainssubset-recommended-alternative
2021-11-09 10:08:29 +07:00
Jean-Charles Drubay
7537451d2f [IMP] contract: black, isort, prettier 2021-11-09 10:08:29 +07:00
João Marques
992cac4deb [FIX] contract: Fix invoice creation and salesperson assignment
In v13, the `user_id` field is a related field to `invoice_user_id`, that defaults to the environment user (`self.env.user`).
Therefore, if we try to create an invoice just by passing `user_id`, it would be overwritten by the default computation of `invoice_user_id`.
This fixes it by passing the correct field and data.

TT31715
2021-11-09 10:08:29 +07:00
Francisco Ivan Anton Prieto
40851a4934 [MIG] contract: Migration to 14.0 2021-11-09 10:08:21 +07:00
Francisco Ivan Anton Prieto
0853330308 [IMP] contract: black, isort, prettier 2021-11-09 10:08:21 +07:00
Víctor Martínez
f9bf927689 [FIX] contract: Changed modification_mail auto to appear like email and not internal comment 2021-11-09 10:08:20 +07:00
Víctor Martínez
54a0fc96c4 [FIX] contract: Error in test_contract_invoice_followers 2021-11-09 10:08:20 +07:00
Denis Roussel
b1c2a771bb [13.0][FIX] contract: Impossible to create invoices from contract lines as section 2021-11-09 10:08:20 +07:00
Víctor Martínez
9120b7fc4c [FIX] contract: Modification mail + Auto-create follower in contract creation related to partner_id
Co-Authored-By: Pedro M. Baeza <pedro.baeza@tecnativa.com>
2021-11-09 10:08:20 +07:00
Víctor Martínez
ea8fefaec9 [IMP] contract: Add contract modification
[UPD] Update contract.pot
2021-11-09 10:08:15 +07:00
Víctor Martínez
5d558019d3 [IMP] contract: Portal 2021-11-09 10:08:11 +07:00
Víctor Martínez
da79e59a16 [IMP] contract: Add followers to invoices created
[UPD] Update contract.pot

[UPD] README.rst
2021-11-09 10:08:05 +07:00
Denis Roussel
c6ea22e985 [13.0][FIX] contract: Recompute recurring next date
After invoice creation, the recurring next date has to be recomputed
in order to get good values

[UPD] Update contract.pot
2021-11-09 10:08:02 +07:00
Pedro M. Baeza
8d2dfb0376 [IMP+REF] contract: Allow to set recurrency at header level
Big refactoring for allowing to define recurrency at header level for simplifying
the use of the module for most of the cases where you don't need different
recurrency at line level.
2021-11-09 10:08:01 +07:00
Pedro M. Baeza
9ed0486d44 [MIG] contract: Migration to 13.0
- Standard procedure
- Adapt invoice creation to new account.move
- Tests adapted
2021-11-09 10:08:01 +07:00
Pedro M. Baeza
92a4e7781e [IMP] : black, isort, prettier 2021-11-09 10:08:01 +07:00
Pedro M. Baeza
dd3d648b66 [IMP] contract: Allow to set a manual currency
Done through an extra field + inverse in the existing compute. This way, we have
the flexibility of auto-remove custom value if it matches the computed one + we don't
need extra changes in the rest of the code.
2021-11-09 10:08:01 +07:00
Jairo Llopis
3d89c352de [FIX] contract: do not die if modified partner has contracts in several companies
In a multicompany scenario where a contact belongs to a company and has contracts in several companies, if the user goes to the contact to edit anything, when saving, it will trigger the recomputation of the `commercial_partner_id` field, which gets populated to all the related contracts, and will undeniably fail with an `AccessError`.

A simple test is provided that, without the fix, fails like this:

```
2020-06-25 07:21:24,859 33 ERROR devel odoo.addons.contract.tests.test_contract: ERROR: test_multicompany_partner_edited (odoo.addons.contract.tests.test_contract.TestContract)
2020-06-25 07:21:24,859 33 ERROR devel odoo.addons.contract.tests.test_contract: ` Editing a partner with contracts in several companies works.
2020-06-25 07:21:24,859 33 ERROR devel odoo.addons.contract.tests.test_contract: Traceback (most recent call last):
2020-06-25 07:21:24,859 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/auto/addons/contract/tests/test_contract.py", line 2513, in test_multicompany_partner_edited
2020-06-25 07:21:24,859 33 ERROR devel odoo.addons.contract.tests.test_contract: `     'parent_id': parent_partner.id,
2020-06-25 07:21:24,859 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/auto/addons/partner_autocomplete/models/res_partner.py", line 183, in write
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     res = super(ResPartner, self).write(values)
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_partner.py", line 570, in write
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     result = result and super(Partner, self).write(vals)
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 321, in write
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     result = super(MailThread, self).write(values)
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/auto/addons/mail/models/mail_activity.py", line 613, in write
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     return super(MailActivityMixin, self).write(vals)
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3381, in write
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     self.recompute()
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5308, in recompute
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     target._write(dict(vals))
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3433, in _write
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     self.check_access_rule('write')
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `   File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3081, in check_access_rule
2020-06-25 07:21:24,860 33 ERROR devel odoo.addons.contract.tests.test_contract: `     + ' - ({} {}, {} {})'.format(_('Records:'), invalid.ids[:6], _('User:'), self._uid)
2020-06-25 07:21:24,861 33 ERROR devel odoo.addons.contract.tests.test_contract: ` odoo.exceptions.AccessError: ('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: Contract, Operation: write) - (Records: [101], User: 12)', None)
```

@Tecnativa TT24482
2021-11-09 10:08:01 +07:00
sbejaoui
01aad3f24a [IMP] - Contract: add new recurring_rule_type quarterly and semesterly 2021-11-09 10:08:01 +07:00
Pedro M. Baeza
be5cc51fe9 [FIX+IMP] contract: improve test coverage with new sections + fix search method 2021-11-09 10:08:01 +07:00
sbejaoui
8f0987dce4 [IMP] - contract termination 2021-11-09 10:08:01 +07:00
sbejaoui
b88b9eec95 [12.0][IMP] - Add an action for contracts manual invoicing
It happen that a company has to trigger the invoicing action to generate invoices before
the scheduled date (to print and prepare invoices documents, check invoices, etc.).
This requires technical access for end users with the risk that this represents.

This commit adds a new wizard to run the invoicing action for a given date with a helper
to see and check the contract that will be invoiced. When the manual action is called,
the system displays all created invoices.

[12.0][IMP] - log the manual invoice action in contract chatter

[IMP] - Add alink to the invoice in contract message at manual invoicing

[IMP] - Improve code

[FIX] - log message for invoice creation only when there is an invoice

[IMP] - split the manual invoice menu into to menus sale & purhcase

[IMP] - hide invoice button if there is nothing to invoice
2021-11-09 10:08:01 +07:00
sbejaoui
5df6bf3879 [12.0][IMP] - Add failing test for wrong invoicing date after contract line stop 2021-11-09 10:08:00 +07:00
sbejaoui
bf8845d683 [12.0][IMP] - extend contract line at renewal 2021-11-09 10:08:00 +07:00
sbejaoui
2cd93a819c [12.0][IMP] - add new option: create_new_line_at_contract_line_renew
Add a company config option to decide whether to create or to extend contract
line at renew action
2021-11-09 10:08:00 +07:00
sbejaoui
c9b304bf36 [12.0][IMP] - Add failing test for next invoice date before the last date invoiced 2021-11-09 10:08:00 +07:00
sbejaoui
0814555b14 [IMP] contract: add unit test for different combinations for next invoicing period 2021-11-09 10:08:00 +07:00
Stéphane Bidoul (ACSONE)
b7b993a153 [REF] contract: rename _get_recurring_next_date as get_next_invoice_date
It is easier to understand. Also make it public.
2021-11-09 10:08:00 +07:00
Stéphane Bidoul (ACSONE)
901d934ed8 [REF] contract: make recurring_invoicing_offset a computed field
In preparation to making it user modifiable.
2021-11-09 10:08:00 +07:00
sbejaoui
3257a058f4 [FIX] contract: Improve unit tests 2021-11-09 10:08:00 +07:00
Stéphane Bidoul (ACSONE)
5636fa9894 [IMP] contract: support pre-paid for monthlylastday
monthlylastday is (almost) not a special case anymore \o/.
montlylastday is simply a montly period where the
periods are aligned on month boundaries.
The last bit of special casing is that postpaid generates
invoice the day after the last dasy of the period, except
for monthlylastday where the invoice is generated on the
last day of the period. This last exception will disappear
when we put the offset under user control.

This is a breaking change because the post-paid/pre-paid
mode becomes relevant for monthlylastday invoicing.
The field becomes visible in the UI. Code that generate
monthlylastday contract lines must now correctly set
the pre-paid/post-paid mode too. Some tests have had
to be adapted to reflect that.
2021-11-09 10:08:00 +07:00
Stéphane Bidoul (ACSONE)
f1c5ad37ca [REF] contract: refactor _update_recurring_next_date
Reuse the logic that is now fully located in _get_recurring_next_date.
2021-11-09 10:08:00 +07:00
Stéphane Bidoul (ACSONE)
7a24716cda [REF] contract: handle max_date_end in _get_recurring_next_date
This concentrates all next date calculation
logic in one place, and will allow further simplifications.
2021-11-09 10:08:00 +07:00
Stéphane Bidoul (ACSONE)
ab20ff9d3f [REF] contract: rename misnamed methods 2021-11-09 10:08:00 +07:00
Pedro M. Baeza
e451ca97d6 [FIX] contract: Tests with duplicated name
So they are not executed at all. Detected by chance looking for a test for the other PR.
2021-11-09 10:08:00 +07:00
Sergio Teruel
699632825a [IMP] contract: Fix test crash with other modules 2021-11-09 10:07:59 +07:00
Thomas Binsfeld
5383d0b68d [REF] Contract Sale Invoicing: split from analytic account
[REF] Contract Sale Invoicing: update translations

[IMP] - Assert that the predecessor is available for new link at uncancel

[RMV] - remove usless changes

[RMV] - Remove usless field recurring_invoices

after the total isolation between contract model and account analytic one.
recurring_invoices which was used to mark analytic account as contract became usless

[IMP] - P3 syntax

[IMP] - use @openupgrade.migrate() and openupgrade.logged_query

[IMP] - drop transient table in migration script
2021-11-09 10:07:59 +07:00
Thomas Binsfeld
bfe3154377 [REF] Contract: split from analytic account 2021-11-09 10:07:59 +07:00
sbejaoui
1250997cd6 [IMP] - A canceled contract line can't be set to auto-renew
[REF] Contract: pep8

[IMP] Contract: update USAGE section of README

[IMP]call onchange_is_auto_renew when changing template
2021-11-09 10:07:59 +07:00
sbejaoui
280727e5cf [FIX] - don't play onchange date_start for old lines on contract template change
[FIX] - Fix stop post message

[FIX] - Fix sale_contract_count should count all partner contract

[FIX] - set recurring_next_date to False if contract line stoped at last date invoiced

[FIX] - Group by next_invoice also considers dates in the past
2021-11-09 10:07:59 +07:00
sbejaoui
16d460fde1 [FIX] - Onchange contract line don't reste contract lines
[FIX] - Rename _get_invoiced_period to _get_period_to_invoice

[ADD] - Add stop_at_date_end to _get_period_to_invoice

[FIX] - Remove useless filter
2021-11-09 10:07:59 +07:00
sbejaoui
51c1eb35d8 [REF] - add method to get quantity to invoice
the contract line quantity can be in some use cases variable, to simplify
the way it is changed we add a new method _get_quantity_to_invoice.
2021-11-09 10:07:59 +07:00
Thomas Binsfeld
96ffd8a54d [FIX] Contract to Invoice: take contract vendor instead of partner's 2021-11-09 10:07:59 +07:00