mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[9.0][IMP] stock_cycle_count: enhance views
This commit is contained in:
@@ -32,7 +32,7 @@ class StockInventory(models.Model):
|
||||
ondelete='cascade', readonly=True)
|
||||
inventory_accuracy = fields.Float(
|
||||
string='Accuracy', compute=_compute_inventory_accuracy,
|
||||
digits=(3, 2), store=True)
|
||||
digits=(3, 2), store=True, group_operator="avg")
|
||||
|
||||
@api.multi
|
||||
def action_done(self):
|
||||
|
||||
@@ -91,3 +91,14 @@ class StockLocation(models.Model):
|
||||
'state': 'draft'
|
||||
})
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def action_accuracy_stats(self):
|
||||
self.ensure_one()
|
||||
action = self.env.ref('stock_cycle_count.act_accuracy_stats')
|
||||
result = action.read()[0]
|
||||
result['context'] = {"search_default_location_id": self.id}
|
||||
new_domain = result['domain'][:-1] + \
|
||||
", ('location_id', 'child_of', active_ids)]"
|
||||
result['domain'] = new_domain
|
||||
return result
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import api, fields, models
|
||||
from openerp import api, models
|
||||
|
||||
|
||||
class LocationAccuracyReport(models.AbstractModel):
|
||||
_name = "report.stock_location_accuracy"
|
||||
|
||||
@api.model
|
||||
def _get_inventory_domain(self, loc_id):
|
||||
def _get_inventory_domain(self, loc_id, exclude_sublocation=True):
|
||||
return [('location_id', '=', loc_id),
|
||||
('exclude_sublocation', '=', True),
|
||||
('exclude_sublocation', '=', exclude_sublocation),
|
||||
('state', '=', 'done')]
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<field name="inherit_id" ref="stock.view_inventory_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="date" position="after">
|
||||
<field name="location_id"/>
|
||||
<field name="cycle_count_id"/>
|
||||
<field name="inventory_accuracy"/>
|
||||
</field>
|
||||
@@ -31,4 +32,52 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_inventory_filter" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.filter - stock_cycle_count</field>
|
||||
<field name="model">stock.inventory</field>
|
||||
<field name="inherit_id" ref="stock.view_inventory_filter"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="after">
|
||||
<field name="location_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_inventory_graph" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.graph</field>
|
||||
<field name="model">stock.inventory</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Inventory accuracy evolution" type="line">
|
||||
<field name="cycle_count_id" type="col"/>
|
||||
<field name="inventory_accuracy" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_inventory_pivot" model="ir.ui.view">
|
||||
<field name="name">stock.inventory.pivot</field>
|
||||
<field name="model">stock.inventory</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Inventory Accuracy">
|
||||
<field name="date" type="col"/>
|
||||
<field name="location_id" type="row"/>
|
||||
<field name="inventory_accuracy" type="measure"/>
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="act_accuracy_stats">
|
||||
<field name="domain">[('exclude_sublocation', '=', True),
|
||||
('state', '=', 'done')]</field>
|
||||
<field name="name">Accuracy Stats</field>
|
||||
<field name="res_model">stock.inventory</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">pivot,tree,form,graph</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_report_accuracy_stats"
|
||||
name="Cycle Count Accuracy"
|
||||
parent="stock.menu_warehouse_report"
|
||||
action="act_accuracy_stats" />
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -4,16 +4,6 @@
|
||||
|
||||
<odoo>
|
||||
|
||||
<record model="ir.actions.act_window" id="act_accuracy_stats">
|
||||
<field name="domain">[('location_id', '=', active_ids),
|
||||
('exclude_sublocation', '=', True),
|
||||
('state', '=', 'done')]</field>
|
||||
<field name="name">Accuracy Stats</field>
|
||||
<field name="res_model">stock.inventory</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,pivot</field>
|
||||
</record>
|
||||
|
||||
<record id="view_location_form" model="ir.ui.view">
|
||||
<field name="name">Location form - cycle count extension</field>
|
||||
<field name="model">stock.location</field>
|
||||
@@ -21,8 +11,9 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button string="Accuracy Stats" class="oe_stat_button"
|
||||
icon="fa-line-chart" name="%(act_accuracy_stats)d"
|
||||
type="action"/>
|
||||
icon="fa-line-chart" name="action_accuracy_stats"
|
||||
context="{'location_id': active_ids}"
|
||||
type="object"/>
|
||||
</xpath>
|
||||
<field name="active" position="after">
|
||||
<field name="zero_confirmation_disabled"/>
|
||||
|
||||
Reference in New Issue
Block a user