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

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