add stock_report

This commit is contained in:
ivan deng
2018-05-15 18:08:42 +08:00
parent bde1bbe872
commit be97c04357
14 changed files with 381 additions and 0 deletions

1
.gitignore vendored
View File

@@ -5,5 +5,6 @@
/app_odoo_customize/_resource
/app_web_studio
/web_studio
/ref
.conf
.pyc

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
from . import models
from . import ir
from . import res

View File

@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
# Created on 2017-11-05
# author: 广州尚鹏http://www.sunpop.cn
# email: 75695762@qq.com
# resource of Sunpop
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Odoo在线中文用户手册长期更新
# http://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# http://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# http://www.sunpop.cn/odoo10_developer_document_offline/
# description:
{
'name': "App Warehouse Management Stock Report",
'version': '10.0.1',
'summary': """仓库盘点与报表增强""",
'description': """
扫码面板
""",
'author': 'Sunpop.cn',
'website': 'http://www.sunpop.cn',
'license': 'LGPL-3',
'category': 'Warehouse',
'sequence': 0,
'price': 98.00,
'currency': 'EUR',
'depends': ['stock'],
'data': [
'views/stock_location_views.xml',
'views/stock_picking_views.xml',
'views/menus.xml',
],
'demo': [
],
'test': [
],
'css': [
],
'qweb': [
],
'js': [
],
'images': [
],
'installable': True,
'auto_install': False,
'application': True,
}

View File

@@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * app_stock_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0+e-20180326\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-22 15:54+0000\n"
"PO-Revision-Date: 2018-04-22 15:54+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "Current Stock"
msgstr "当前库存"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.app_view_location_form
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "All Move"
msgstr "出入库明细"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.app_stock_picking_type_kanban
msgid "All Move Report"
msgstr "出入库明细"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.app_view_location_form
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "Move In"
msgstr "入库明细"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.app_view_location_form
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "Move Out"
msgstr "出库明细"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "Products"
msgstr "库存产品"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "Stock Location"
msgstr "库存位置"
#. module: app_stock_report
#: model:ir.ui.menu,name:app_stock_report.app_menu_stock_move_report
msgid "Locations"
msgstr "按库位统计"
#. module: app_stock_report
#: model:ir.actions.act_window,name:app_stock_report.act_move_in_location_open
msgid "Stock Move In"
msgstr "查看入库明细"
#. module: app_stock_report
#: model:ir.actions.act_window,name:app_stock_report.act_move_out_location_open
msgid "Stock Move Out"
msgstr "查看出库明细"
#. module: app_stock_report
#: model:ir.ui.view,arch_db:app_stock_report.view_location_kanban
msgid "Recent 30 days"
msgstr "最近 30 天统计"

View File

@@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
from . import stock_location
from . import stock_picking_type

View File

@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
from datetime import datetime, timedelta
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
# 限制时间,数据量不可太大
DAY_LIMIT = 30
class StockLocation(models.Model):
_inherit = "stock.location"
day_limit = fields.Integer(string=u'Day limit in report dashboard', default=DAY_LIMIT)
@api.multi
def act_move_all_location_open(self):
self.ensure_one()
location_id = self.id
stime = datetime.now() - timedelta(days=self.day_limit)
stime_str = stime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if location_id:
action = self.env.ref('stock.stock_move_action').read()[0]
action['name'] = "Stock Move All"
action['domain'] = ['&', ('date_expected', '>', stime_str), '|', ('location_dest_id', '=', location_id), ('location_id', '=', location_id)]
action['context'] = {'search_default_done': True}
return action
@api.multi
def act_move_in_location_open(self):
self.ensure_one()
location_id = self.id
stime = datetime.now() - timedelta(days=self.day_limit)
stime_str = stime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if location_id:
action = self.env.ref('stock.stock_move_action').read()[0]
action['name'] = "Stock Move In"
action['domain'] = ['&', ('date_expected', '>', stime_str), ('location_dest_id', '=', location_id)]
action['context'] = {'search_default_done': True}
return action
@api.multi
def act_move_out_location_open(self):
self.ensure_one()
location_id = self.id
stime = datetime.now() - timedelta(days=self.day_limit)
stime_str = stime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if location_id:
action = self.env.ref('stock.stock_move_action').read()[0]
action['name'] = "Stock Move Out"
action['domain'] = ['&', ('date_expected', '>', stime_str), ('location_id', '=', location_id)]
action['context'] = {'search_default_done': True}
return action

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api, _
from datetime import datetime, timedelta
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
# 限制时间,数据量不可太大
DAY_LIMIT = 30
class StockPickingType(models.Model):
_inherit = "stock.picking.type"
@api.multi
def act_move_all_picking_open(self):
self.ensure_one()
picking_id = self.id
stime = datetime.now() - timedelta(days=DAY_LIMIT)
stime_str = stime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
if picking_id:
action = self.env.ref('stock.stock_move_action').read()[0]
action['name'] = "Stock Move All"
action['domain'] = ['&', ('date_expected', '>', stime_str), ('picking_type_id', '=', picking_id)]
action['context'] = {'search_default_done': True}
return action

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1 @@
# -*- coding: utf-8 -*-

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem id="app_menu_stock_move_report"
parent="stock.menu_warehouse_report" action="stock.action_location_form"
sequence="3"/>
</data>
</odoo>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="app_view_location_form" model="ir.ui.view">
<field name="name">app.stock.location.form</field>
<field name="model">stock.location</field>
<field name="inherit_id" ref="stock.view_location_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button string="All Move"
class="oe_stat_button"
icon="fa-list-ul" name="act_move_all_location_open" type="object"
/>
<button string="Move In"
class="oe_stat_button"
icon="fa-plus" name="act_move_in_location_open" type="object"
/>
<button string="Move Out"
class="oe_stat_button"
icon="fa-minus" name="act_move_out_location_open" type="object"
/>
</xpath>
<xpath expr="//field[@name='partner_id']" position="after">
<field name="day_limit"/>
</xpath>
</field>
</record>
{# 增加看板#}
<record id="view_location_kanban" model="ir.ui.view">
<field name="name">stock.location.kanban</field>
<field name="model">stock.location</field>
<field name="arch" type="xml">
<kanban string="Stock Location" class="oe_background_grey o_kanban_dashboard o_stock_kanban" create="0">
<field name="active"/>
<field name="display_name"/>
<field name="name"/>
<field name="usage"/>
<field name="day_limit"/>
<field name="company_id"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card">
<div class="o_kanban_card_header">
<a class="o_kanban_card_header_title" type="edit">
<div class="o_primary">
<field name="display_name"/>
</div>
<div class="o_secondary">
<field class="o_secondary" name="usage"/>
</div>
</a>
</div>
<div class="container o_kanban_card_content o_visible">
<div class="row">
<div class="col-xs-6 o_kanban_primary_left">
<div>
<button class="btn btn-primary mt8 mb4"
name="%(stock.location_open_quants)d" type="action"
context="{'search_default_internal_loc': 1}">Current Stock
</button>
</div>
<div>
<button class="btn btn-primary"
name="%(stock.act_product_location_open)d" type="action"
context="{'location_id': active_id}">Products
</button>
</div>
</div>
<div class="col-xs-6 o_kanban_primary_right">
<div class="o_kanban_card_manage_title">
<h4>Recent <strong><field name="day_limit"/></strong> days</h4>
</div>
<div class="mt8">
<a name="act_move_all_location_open" type="object">All Move</a>
</div>
<div class="mt8">
<a name="act_move_in_location_open" type="object">Move In</a>
</div>
<div class="mt8">
<a name="act_move_out_location_open" type="object">Move Out</a>
</div>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
{# 增加库移透视表#}
<record id="app_view_move_pivot" model="ir.ui.view">
<field name="name">stock.move.pivot</field>
<field name="model">stock.move</field>
<field name="arch" type="xml">
<pivot string="Stock Moves Analysis" disable_linking="True">
<field name="product_id" type="row"/>
<field name="date_expected" interval="month" type="col"/>
<field name="product_uom_qty" type="measure"/>
</pivot>
</field>
</record>
<record id="stock.action_location_form" model="ir.actions.act_window">
<field name="name">Locations</field>
<field name="res_model">stock.location</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="view_id" ref="view_location_kanban"/>
<field name="search_view_id" ref="stock.view_location_search"/>
<field name="context">{'search_default_in_location':1}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a location.
</p><p>
Define your locations to reflect your warehouse structure and
organization. Odoo is able to manage physical locations
(warehouses, shelves, bin, etc), partner locations (customers,
vendors) and virtual locations which are the counterpart of
the stock operations like the manufacturing orders
consumptions, inventories, etc.
</p><p>
Every stock operation in Odoo moves the products from one
location to another one. For instance, if you receive products
from a vendor, Odoo will move products from the Vendor
location to the Stock location. Each report can be performed on
physical, partner or virtual locations.
</p>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="app_stock_picking_type_kanban" model="ir.ui.view">
<field name="name">stock.picking.type.kanban</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.stock_picking_type_kanban"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='get_action_picking_tree_ready']" position="after">
<button class="btn btn-primary mt8"
name="act_move_all_picking_open" type="object">
All Move Report
</button>
</xpath>
</field>
</record>
</data>
</odoo>