Add support for filter by location on inventory report and inventory valuation

Refund option enabled by default on Return wizard
This commit is contained in:
Alexis de Lattre
2019-08-12 00:25:20 +02:00
parent 3052d7c905
commit cadbd840d9
15 changed files with 201 additions and 28 deletions

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import stock_quantity_history

View File

@@ -0,0 +1,32 @@
# Copyright 2019 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class StockQuantityHistory(models.TransientModel):
_inherit = 'stock.quantity.history'
location_id = fields.Many2one(
'stock.location', string='Stock Location',
domain=[('usage', '=', 'internal')],
help="If you select a stock location, the inventory report will be "
"for this stock location and its children locations. If you leave "
"this field empty, the inventory report will be for all the internal "
"stock locations.")
def open_table(self):
action = super(StockQuantityHistory, self).open_table()
if self.compute_at_date:
action['domain'] = "[('type', '=', 'product'), ('qty_available', '!=', 0)]"
if self.location_id:
if self.compute_at_date:
# insert "location" in context for qty computation
action['context']['location'] = self.location_id.id
else:
# force search view with child_of for location_id
action = self.env.ref(
'stock_usability.stock_quantity_history_quant_action').read()[0]
action['context'] = {'search_default_location_id': self.location_id.id}
return action

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_stock_quantity_history" model="ir.ui.view">
<field name="name">stock_usability.stock.quantity.history.form</field>
<field name="model">stock.quantity.history</field>
<field name="inherit_id" ref="stock.view_stock_quantity_history"/>
<field name="arch" type="xml">
<field name="date" position="after">
<field name="location_id"/>
</field>
</field>
</record>
</odoo>