[FIX] stock: inventory report form editable

In inventory report, when groupby setted and no data, the create button
will open a new form instead of create a new line. Since now our form
view is not editable, no record can be created.

In this commit, add a new editable form view to solve it.

Task 2310494
PR #55910

closes odoo/odoo#57344

X-original-commit: 4a4e60c65049082855414941642dadce8b413475
Related: odoo/enterprise#13067
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
yhu-odoo
2020-09-09 10:15:32 +00:00
parent 81f86adf1f
commit f20dded993
2 changed files with 47 additions and 10 deletions
+10 -10
View File
@@ -610,7 +610,7 @@ class StockQuant(models.Model):
action = {
'name': _('Stock On Hand'),
'view_type': 'tree',
'view_mode': 'list',
'view_mode': 'list,form',
'res_model': 'stock.quant',
'type': 'ir.actions.act_window',
'context': ctx,
@@ -624,22 +624,22 @@ class StockQuant(models.Model):
if self._is_inventory_mode():
action['view_id'] = self.env.ref('stock.view_stock_quant_tree_editable').id
form_view = self.env.ref('stock.view_stock_quant_form_editable').id
else:
action['view_id'] = self.env.ref('stock.view_stock_quant_tree').id
# Enables form view in readonly list
action.update({
'view_mode': 'tree,form',
'views': [
(action['view_id'], 'list'),
(self.env.ref('stock.view_stock_quant_form').id, 'form'),
],
})
form_view = self.env.ref('stock.view_stock_quant_form').id
action.update({
'views': [
(action['view_id'], 'list'),
(form_view, 'form'),
],
})
if extend:
action.update({
'view_mode': 'tree,form,pivot,graph',
'views': [
(action['view_id'], 'list'),
(self.env.ref('stock.view_stock_quant_form').id, 'form'),
(form_view, 'form'),
(self.env.ref('stock.view_stock_quant_pivot').id, 'pivot'),
(self.env.ref('stock.stock_quant_view_graph').id, 'graph'),
],
+37
View File
@@ -35,6 +35,43 @@
</field>
</record>
<record model="ir.ui.view" id="view_stock_quant_form_editable">
<field name="name">stock.quant.form.editable</field>
<field name="model">stock.quant</field>
<field eval="11" name="priority"/>
<field name="arch" type="xml">
<form string="Inventory Valuation" create="false" edit="false" delete="false">
<sheet>
<group>
<group>
<field name="tracking" invisible="1"/>
<field name="product_id" readonly="0" options="{'no_create': True}"/>
<field name="location_id" readonly="0" options="{'no_create': True}"/>
<field name="lot_id" groups="stock.group_production_lot"
attrs="{'readonly': [('tracking', 'not in', ['serial', 'lot'])], 'required': [('tracking', '!=', 'none')]}"
context="{'default_product_id': product_id, 'default_company_id': company_id}"/>
<field name="package_id" readonly="0" groups="stock.group_tracking_lot"/>
<field name="owner_id" readonly="0" groups="stock.group_tracking_owner" options="{'no_create': True}"/>
<field name='company_id' groups="base.group_multi_company"/>
</group>
<group>
<label for="inventory_quantity" string="Quantity On Hand"/>
<div class="o_row">
<field name="inventory_quantity"/>
<field name="product_uom_id" groups="uom.group_uom"/>
</div>
<label for="reserved_quantity" string="Quantity Reserved"/>
<div class="o_row">
<field name="reserved_quantity"/>
<field name="product_uom_id" groups="uom.group_uom"/>
</div>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_stock_quant_form">
<field name="name">stock.quant.form</field>
<field name="model">stock.quant</field>