mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add stock_report
This commit is contained in:
5
app_stock_report/models/__init__.py
Normal file
5
app_stock_report/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import stock_location
|
||||
from . import stock_picking_type
|
||||
|
||||
53
app_stock_report/models/stock_location.py
Normal file
53
app_stock_report/models/stock_location.py
Normal 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
|
||||
26
app_stock_report/models/stock_picking_type.py
Normal file
26
app_stock_report/models/stock_picking_type.py
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user