Commit Graph

72 Commits

Author SHA1 Message Date
Víctor Martínez
25baee81f9 [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-01-15 09:24:35 +01:00
Víctor Martínez
6daf88a437 [FIX+IMP] contract: Fix tests + Batch modifications 2020-12-25 12:07:46 +01:00
Pedro M. Baeza
c09c93cda6 [FIX+IMP] contract: Make template to work + other refinements
- Contract modification subtype non default
- Hybrid template between mail.template Jinja + inheritable QWeb
- QWeb element qualified for easing inheritance
- Translations updated
- _modification_mail_send multi-record
- Tests resilience
2020-12-24 09:43:34 +01:00
Víctor Martínez
a9f65b439a [IMP] contract: Add contract modification 2020-12-23 18:43:16 +01:00
Víctor Martínez
305ca3f540 [IMP] contract: Portal 2020-12-14 08:49:11 +01:00
Víctor Martínez
e093a51bbc [IMP] contract: Add followers to invoices created 2020-12-02 09:16:03 +01:00
OCA-git-bot
90272ecebe Merge PR #523 into 12.0
Signed-off-by pedrobaeza
2020-07-17 15:00:40 +00:00
Pedro M. Baeza
86d82ee9ee [IMP] contract: Avoid warning on non existing field in tests
The field doens't exists, so we can avoid the warning simply not writing it.
2020-07-15 17:48:30 +02:00
Jairo Llopis
4b1bfb8502 [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
2020-06-25 08:41:35 +01:00
Pedro M. Baeza
b3d64d300c [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.
2020-06-05 19:13:19 +02:00
sbejaoui
ce97dede3d [ADD] - Add unit tests 2020-05-18 10:17:23 +02:00
Pedro M. Baeza
0712757fce [FIX+IMP] contract: improve test coverage with new sections + fix search method 2020-04-14 13:14:10 +02:00
sbejaoui
e71fcc1694 [IMP] - use terminate term instead of resiliate 2020-03-11 11:13:13 +01:00
sbejaoui
58b38490f6 [IMP] - contract resiliation 2020-03-10 11:11:59 +01:00
sbejaoui
29cc7cb23a [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
2020-01-29 16:40:22 +01:00
sbejaoui
75372cfcda [12.0][IMP] - Add failing test for wrong invoicing date after contract line stop 2020-01-07 13:17:12 +01:00
OCA-git-bot
f588b5c28b Merge PR #447 into 12.0
Signed-off-by sbejaoui
2020-01-02 13:06:59 +00:00
sbejaoui
61737ea920 [12.0][IMP] - extend contract line at renewal 2019-12-23 16:49:18 +01:00
sbejaoui
c7365b028f [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
2019-12-23 16:49:18 +01:00
sbejaoui
294f92b7ac [12.0][IMP] - Add failing test for next invoice date before the last date invoiced 2019-12-21 14:11:02 +01:00
sbejaoui
5a46e97527 [IMP] contract: add unit test for different combinations for next invoicing period 2019-12-09 13:17:16 +01:00
Stéphane Bidoul (ACSONE)
8ba9033903 [REF] contract: rename _get_recurring_next_date as get_next_invoice_date
It is easier to understand. Also make it public.
2019-12-09 13:17:16 +01:00
Stéphane Bidoul (ACSONE)
8b30ed0a3e [REF] contract: make recurring_invoicing_offset a computed field
In preparation to making it user modifiable.
2019-12-09 13:17:16 +01:00
sbejaoui
a90e18b092 [FIX] contract: Improve unit tests 2019-12-09 13:17:15 +01:00
Stéphane Bidoul (ACSONE)
557097be2d [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.
2019-12-09 13:17:15 +01:00
Stéphane Bidoul (ACSONE)
aff3781c92 [REF] contract: refactor _update_recurring_next_date
Reuse the logic that is now fully located in _get_recurring_next_date.
2019-12-06 14:12:18 +01:00
Stéphane Bidoul (ACSONE)
e6b9ea9ce7 [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.
2019-12-06 10:51:16 +01:00
Stéphane Bidoul (ACSONE)
5ee13d4cbd [REF] contract: rename misnamed methods 2019-12-06 09:19:18 +01:00
Pedro M. Baeza
8392d61221 [FIX] contract: Tests with duplicated name
So they are not executed at all. Detected by chance looking for a test for the other PR.
2019-12-02 16:04:36 +01:00
Sergio Teruel
e0ff2922ff [IMP] contract: Fix test crash with other modules 2019-11-14 13:43:58 +01:00
Thomas Binsfeld
a429b10c20 [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
2019-09-14 14:34:02 +02:00
Thomas Binsfeld
da7826797c [REF] Contract: split from analytic account 2019-09-14 14:34:02 +02:00
sbejaoui
3bd431e0ed [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
2019-09-14 14:34:02 +02:00
sbejaoui
130fbb693e [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
2019-09-14 14:34:02 +02:00
sbejaoui
834d0b959b [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
2019-09-14 14:34:02 +02:00
sbejaoui
2f7aed2744 [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.
2019-09-14 14:34:02 +02:00
Thomas Binsfeld
be5cc5fba1 [FIX] Contract to Invoice: take contract vendor instead of partner's 2019-09-14 14:34:02 +02:00
sbejaoui
75fa034db1 [ADD] - Add more value for auto_renew_rule_type
[REF] - refactoring for compute_first_date_end

[RMV] - remove auto_renew_rule_type option monthlylastday

[IMP] - rename manual_renew_needed label

[IMP] - use get_product_multiline_description_sale to get contract line description
2019-09-14 14:34:02 +02:00
sbejaoui
22c1b25311 [IMP] - Should be able to stop a past contract line 2019-09-14 14:34:02 +02:00
sbejaoui
361d57fb64 [IMP] - Replace is_suspended flag by manual_renew_needed
Add a computed field for the first date of the termination notice period

Adapt state compute and search method

[IMP] - Improve unit tests
2019-09-14 14:34:02 +02:00
sbejaoui
8171c1d955 [IMP] - Link invoice line to contract lines
[IMP] - Add index on contract line

[IMP] - Add is_suspended flag and _search_state

[IMP] - Add is_suspended flag to stop contract line
2019-09-14 14:34:02 +02:00
sbejaoui
54c3b17f63 [FIX] - filter by termination_notice for contract line to renew 2019-09-14 14:34:02 +02:00
sbejaoui
42a70ddaac [12.0][IMP] - check invoice line vals before assignment
[FIX] - Fix unit tests.
2019-09-14 14:34:02 +02:00
sbejaoui
494892f6b1 [FIX] - default value for active field in contract line
[FIX] - fix flake8
2019-09-14 14:34:02 +02:00
sbejaoui
3e6633046e [FIX] - as date_start is required, constraints on it become useless
[FIX] - for finished contract _get_lines_to_invoice should return False
2019-09-14 14:34:02 +02:00
Thomas Binsfeld
f95d2a3582 [REF] Contract: invoice creation
[REF] Contract Unit Tests: base the cron check on invoice lines instead of invoices
2019-09-14 14:34:02 +02:00
sbejaoui
d1d6500452 [FIX] - contract recurring_next_date ignore canceled lines
[FIX] - fix _get_invoiced_period if recurring_next_date manually updated
2019-09-14 14:34:02 +02:00
sbejaoui
1c43029541 [IMP] - don't allow to unlink uncnaceled contrac line 2019-09-14 14:34:02 +02:00
sbejaoui
aefa12ab9e [IMP] - store last_date_invoiced on contract_line
Improve CRITERIA_ALLOWED_DICT

[IMP] - code improvement

[IMP] - Use last_date_invoiced to set marker in invoice description

[IMP] - add migration script to init last_day_invoiced and some other improvement

[FIX] - a contract line suspended should start a day after the suspension end
2019-09-14 14:34:02 +02:00
sbejaoui
f217be4f19 [IMP] - hide recurring_invoicing_type if recurring_rule_type is monthlylastday
for the monthlylastday case, pre-paid is logicly impossible,
if monthlylastday is set, we consider only post-paid case

[IMP] - Improve unit tests
2019-09-14 14:34:02 +02:00