Files
odoo_source/addons/sale_timesheet/tests
sbel-odoo 03d7e0eb18 [FIX] sale_expense: compute expense policy for expense products
Currently, an analytic account is created when confirming a quotation for a product created as follow:
1. Enable `Can be Expensed`
2. Select `At cost` for Re-invoice expenses
3. Disable `Can be expensed`

Steps to reproduce:
-------------------
* Install **sale_management** and **hr_expense**
* Go to **Settings**
* Under `Customer Invoices`, enable `Intrastat` -> Save
* Under `Analytics`, enable `Analytic Accounting`
* Go to **Sales**
* Create 3 products
  * Product 1: Default
  * Product 2:
    * Enable `Can be Expensed`
    * Select `At cost` for Re-invoice expenses
  * Product 3:
    * Enable `Can be Expensed`
    * Select `At cost` for Re-invoice expenses
    * Disable `Can be expensed`
* For each product, repeat:
  * Create a quotation, select a customer
  * Add the product
  * Confirm
  * Select tab `Other Info`
  * Check the analytic account

**Observations:**
* Product 1: No analytic account created
* Product 2: Analytic account created
* Product 3: Analytic account created

Why the fix:
------------

The creation of the analytic account depends on the value of `expense_policy`. When the value is `no`, no analytic account is created. Whereas when the value is `cost`, an analytic account is created.

https://github.com/odoo/odoo/blob/57ad9c05014ca0219d7892c1ff8a2e949fab3c49/addons/sale/models/sale_order.py#L853-L856

In this workflow, `expense_policy` is visible only when `Can be expensed` is enabled. If you select an `expense_policy` then disable `Can be expensed`, the value for the `expense_policy` stays as previously selected.

https://github.com/odoo/odoo/blob/3e320ffe0ff4d1c6bb7d0314f36dd13ad1cf23f4/addons/sale_expense/models/product_template.py#L33-L41

opw-3706305

closes odoo/odoo#159084

X-original-commit: 4b8e0559248d75ef27f47903041e5cca2059fa80
Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) <jbw@odoo.com>
Signed-off-by: Sarah Bellefroid (sbel) <sbel@odoo.com>
2024-03-26 08:20:21 +00:00
..
…