Adrien Widart c6e538e727 [FIX] sale: define team_id with same company than user
When creating a journal entry in company C01, if user's sales team
belongs to another company CXX, the default sales team of the journal
entry is still the user's sales team.

To reproduce the error:
(Use demo data. Let C01 be the current company)
1. Add the `team_id` field to `account_move` form view:
    - With web_studio
    - Directly in the code:
```diff
diff --git a/addons/sale/views/sale_views.xml
b/addons/sale/views/sale_views.xml
index 92cb2a72c4d..acc0e91e890 100644
--- a/addons/sale/views/sale_views.xml
+++ b/addons/sale/views/sale_views.xml
@@ -1154,6 +1154,17 @@
             </field>
         </record>

+        <record id="account_invoice_view_form" model="ir.ui.view">
+            <field name="name">account.move.form.inherit.sale</field>
+            <field name="model">account.move</field>
+            <field name="inherit_id" ref="account.view_move_form"/>
+            <field name="arch" type="xml">
+                <field name="ref" position="after">
+                    <field name="team_id" />
+                </field>
+            </field>
+        </record>
+
         <!-- Update account invoice !-->
         <record model="ir.ui.view" id="account_invoice_form">
             <field name="name">Account Invoice</field>
```
2. Create a second Company C02
3. Edit the Sales Team 'Europe':
    - Company: C02
4. Go to Accounting > Accounting > Journal Entries
5. Click on "Create"

Error: the default Sales Team is 'Europe'. However, this team belongs to
C02 and the user is creating a new JE in C01.

When creating a new journal entry, an `onchange` method uses the user's
sales team to define the JE's sales team.
However, the current user belongs to 'Europe', and the company of
'Europe' is now C02. Therefore, 'Europe' should not be used.

OPW-2375444

closes odoo/odoo#67733

X-original-commit: 67cd2ca3d80e5fc53f6c0f3ec73a0f90765dda73
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-12 08:17:37 +00:00
2021-03-11 18:06:30 +00:00
2015-09-08 15:45:09 +02:00
2015-09-08 17:58:38 +02:00
2019-11-08 11:24:04 +00:00
2020-09-28 14:07:25 +00:00

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%