[FIX] sale_expense: fields consistency

Use case to reproduce:
- Set a product to be expensed
- Set the expense_policy to something else than no
- Do a delivery order with a picking
- Validate the picking
-> Delivered quantity to 0 and impossible to create an invoice
if the invoice_policy is delivered_quantity

It happens due to this commit 48ea59d
What does it do:
- The move could be generated by an expense.
- If the move has 'no' as expense policy thus we won't add it in the invoice
Problem we can't guess if the move come from an expense or not (limitation).

This commit add an onchange on can_be_expense is order to set the expense
policy back to 'no' when the user uncheck it.

Courtesy of amoyaux

opw-777139
This commit is contained in:
Nicolas Martinelli
2017-11-06 13:05:37 +01:00
parent 6c1c1f6e9e
commit 08ab28a66c
3 changed files with 19 additions and 0 deletions
+2
View File
@@ -1,2 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import product_template
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class ProductTemplate(models.Model):
_inherit = "product.template"
@api.onchange('can_be_expensed')
def _onchange_can_be_expensed(self):
if not self.can_be_expensed:
self.expense_policy = 'no'