Commit Graph
38 Commits
Author SHA1 Message Date
Christophe Simonis 58a83d1222 [MERGE] forward port branch saas-12.4 up to 4a1321bc99
closes odoo/odoo#37127

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-20 14:33:54 +00:00
Christophe Simonis 080f8b1f96 [MERGE] forward port branch saas-12.3 up to d8ce75466e 2019-09-17 17:49:09 +02:00
Rémi Rahir 3f401e3e2f [FIX] snailmail: do not decode null objects
Prior to this commit, we would try to decode the logo of a company
without any verification on its presence. If the logo was not set, we'd
try to decode nothing which caused a crash.

This commit ensure that we asert that the field is set before trying to
encode it for a JSON payload.

closes odoo/odoo#36784

X-original-commit: f40f763831bace8c499072ea81ef9bbd5fc910e4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-09-12 13:21:48 +00:00
Vincent Schippefilt cc9467b750 [FIX] snailmail: support write with multiple records 2019-09-18 11:31:43 +00:00
Christophe Simonis 5b2f64fd5d [MERGE] forward port branch 12.0 up to 4870251f0b 2019-06-14 10:15:49 +02:00
Christophe Simonis 25e3f27062 [MERGE] forward port branch saas-12.3 up to 48a9f5a633 2019-06-17 13:20:35 +02:00
Pierre Rousseau 4c7f236fb5 [FIX] snailmail: re-render report when using snailmail
If the option 'Reload from attachment' is checked for a report, it will be generated from the existing attachments.
However, for snailmail, we have to force the re-rendering to apply specific css rules to match the layout of a A4 letter.

Task-ID: 2008896

closes odoo/odoo#34053

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
2019-06-12 11:31:26 +00:00
Christophe Simonis 71a50a2214 [MERGE] forward port branch saas-12.3 up to 409679866b 2019-06-06 11:54:35 +02:00
Pierre Rousseau 743434cb2e [FIX] snailmail: send the contact_address
Before this commit, the param contact_address was not sent to the service. However, the service need it to correctly send the letter if the format is wrong.

OPW-1981168

closes odoo/odoo#33855

Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
2019-06-04 07:03:36 +00:00
Thanh Dodeur c212cfe899 [REF] *: removes datas_fname from ir.attachment
This commit removes the field `datas_fname` from `ir.attachment` as
it was unnecessary and most of the time the duplicate of `name` or
`url`.

Task #1909865

closes odoo/odoo#32976

Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-06-05 09:12:13 +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
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Pierre Rousseau 05150281db [FIX] snailmail, snailmail_account: do not make RPC call to compute the price
Since c2b55f3e0c, a letter = 1 stamp, so we do not need to make RPC call anymore.

closes odoo/odoo#33417

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
2019-05-16 08:46:49 +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
Pierre Rousseau 7aa74c0f22 FIX] snailmail, snailmail_account: do not make RPC call to compute the price
Since c2b55f3, a letter = 1 stamp, so we do not need to make RPC call anymore.

closes odoo/odoo#33423

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
2019-05-16 09:52:22 +00:00
Antoine Prieels (ANP) 8f486db52d [IMP] mail, snailmail, snailmail_account: improve error management
When a letter is sent through snailmail and encounter an error, it used
to create an activity to the user to notify him that there was an error
with its letter.

When a user had this activity, he didn't have any clues of what was the
error and how to manage it. So we decided to better handle snailmail
errors and give the possibility to the user to easily fix the source of
the snailmail errors.

First to give a better feedback on the letters in errors, we've made
features similar to ones existing for emails:
 - We add a mail message on the document that sent the letter, and put a
   small paper plane icon, which is red when an error occurs (like the
   envelope for email)
 - As letters can be sent in batch, we've also added an entry in the
   systray to easily manage the different documents having snailmail
   errors like for emails.

Then we identified, the most common errors encountered with the
snailmail letters and give proper way to let the user fix them:
 - Missing Required Field:
    - The address is not complete, some of the fields are empty.
    - We open a wizard allowing the user to modify the partner address
      and we try to resend all letters having this error on the modified
      partner.
    - We also try to avoid this error, by opening the wizard before
      sending the letter, but it only works for single documents, not
      for batch.
 - Trial/Credit Error:
    - The user has not enough credits to send letters anymore.
    - We open a wizard that give a redirection lnk to add credits on its
      iap account.
 - No Price Available:
    - The destination country is not supported by any of our providers,
      and we cannot do anything to send this letter.
 - Format Error:
    - The format of the pdf report send by the user is refused by our
      providers, because some visual stuffs are not respected, for
      example blank zone to print barcode or margins.
    - We show a wizard to the user letting him check a setting option
      that add a cover page in the envelope and the documents will be
      send with this extra page containing the address.
 - Unknown Error:
    - This is not one of the listed error above.
    - A wizard suggesting the user to contact support is displayed.

The cron that try to resend letters on error, has been addapted to only
try to send the error of type Trial/No Credit, because the account might
have been reloaded, and other errors, won't change if they have not been
fixed locally.

closes odoo/odoo#29685
2019-01-24 13:36:51 +00:00
Christophe Simonis 8aa8548d8a [MERGE] forward port branch 12.0 up to 3e4138deaa
closes odoo/odoo#30045
2019-01-09 15:56:53 +00:00
Antoine Prieels 62221bc3f9 [FIX] snailmail: Object of type bytes is not JSON serializable
Sending a letter resulted systematically in an error due to the insertion of the binary of the PDF in the JSON sent to IAP-services.

closes odoo/odoo#29880
2019-01-03 12:56:52 +00:00
Antoine Prieels (ANP) e81ef3a603 [FIX] snailmail: Do not resend letters in state 'error' in cron
closes odoo/odoo#29456
2018-12-12 09:36:36 +00:00
Antoine Prieels (ANP) f68df47ddf [IMP] snailmail: Show the price in terms of stamps
- The price of sending a letter was displayed in the currency of the company, now we express the price in terms of stamps
- Show a different message in the modal depending on the validity of the address
2018-11-22 15:38:42 +00:00
Antoine Prieels (ANP) d5ca268438 [IMP] snailmail: Change order of settings and default values
Task #1892473
2018-11-22 15:38:42 +00:00
Antoine Prieels (ANP) 2dfa7cd597 [IMP] snailmail: Add form and tree views for snailmail.letter
Add new form and tree views for snailmail.letter available in Accounting > Configuration > Management > Snailmail Letters
Add a many2one field to snailmail.letter to link to a mail.activity in case of an error with snailmail

Task #1892473
2018-11-22 15:38:42 +00:00
Rémi Rahir 235811d468 [FIX] snailmail: avoid spam on user mailbox
the fix merged in cb8bd299fc
was only tackling half the problem. When you assign a user to an
activity, the said user will be notified by email. This also occur if
you change the assignee to the next activity even if you change it to
the same user.

This commit ensures that we only write on the user_id field when we
create the next activity and not during the update.
2018-11-05 09:32:33 +00:00
Rémi Rahir 9988ce3f3b [IMP] snailmail: add new error message to help the user 2018-11-05 09:31:52 +00:00
Rémi Rahir 5032828d5a [FIX] snailmail: instable behaviour on print
Since commit b6a981405e we require a
certain key in the context to apply the custom snailmail report layout.
This was badly managed and would eventually confilt inside the modal
that links snailmail and the mail composer.

This fix stabilises the biehaviour by properly propagating the context
key.
2018-10-19 08:36:16 +00:00
Antoine Prieels (ANP) 218fbaf90b [IMP] snailmail: Change formatting of address in snailmail
The previos format displayed the fields 'street' and 'street2' on two different line, making the address too big for the address area allowed by Pingen.
2018-10-19 08:36:16 +00:00
Antoine Prieels (ANP) a5b3246dcd [FIX] Convert the estimated price for snailmail server-side
Currency rates were not updated client-side so we moved to make the convertion happen server-side, where rates are updated daily

closes odoo/odoo#27688
2018-10-11 14:48:25 +00:00
Rémi Rahir cb8bd299fc [FIX] snailmail: avoid next activity spamming
closes odoo/odoo#27665
2018-10-11 11:11:42 +00:00
Rémi Rahir e12ac2b91b [IMP] snailmail(_account): smoothe the etimation of price
Up until now, when we wanted to post a single document, it's base64 blob
was uploaded to the snailmail server to estimate the cost of the
transaction.  We now use the 'batch' apporach that will estimate the
price based on 1 page per document.
2018-09-29 11:12:39 +02:00
Rémi Rahir b6a981405e [IMP] snailmail: adding special map for the country names 2018-09-29 11:12:38 +02:00
Adrian Torres 3f4f77fd9d [REF] *: adapt code to new related default behaviour
This commit adapts the business code to changes introduced by
the parent commit in order to keep the same behaviour as before.

All readonly=False fields will have to be checked afterwards to confirm
that the business case requires write access to the source field.
2018-09-27 12:10:23 +02:00
Rémi Rahir 49695b0088 [FIX] snailmail: use the correct activity type
The activity generated by the snailmail sending is actually an exception
and should therefore use the corresponding activity type.
2018-09-27 11:30:16 +02:00
Rémi Rahir 0df593f2fe [IMP] snailmail: adding dbuuid to the request for free credits
change the payload of a request to adapt to 2cd0b6acf1e22642607edf05a220f5ab8af12164.
2018-09-21 13:48:56 +02:00
Nimesh Jethva 2c1549cc59 [IMP]tools, technial modules: Improvement in model description
Purpose of this commit is to give description more "business oriented"
because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers.

Related Task ID : 37311
2018-09-21 11:45:15 +02:00
Rémi Rahir 46dc8ceef9 [IMP] snailmail: adapt reports for snailmail
In order to ease the integration with the snailmail posting service provider,
We will generate specific reports with a layout that fits their
criteria.
In short,
* we specify the postition of the recipient's address on the
document
* we force the A4 format

This also support the din5008 type B report.
2018-09-19 17:58:35 +02:00
Rémi Rahir 0354579c98 [IMP] iap,snailmail: support new trial system 2018-09-17 12:45:05 +02:00
Rémi Rahir 53cdd68e7c [IMP] account,snailmail: support batch calls
- reworked the multi.compose.message model to manage
   several documents simultaneously
 - Added a letter model for asynchronous processing
 - usability improvement of the modal
2018-08-10 18:41:00 +02:00
Rémi Rahir 4cb9194275 [ADD] snailmail: new iap module to send letters by post 2018-07-19 15:54:00 +02:00