Open product quantities by warehouse to show moves
We add also a custom rec_name for stock.product_quantities_warehouse to use as action name. issue8350 review253511002
This commit is contained in:
1 parent
2246519c97
commit
802c014e1e
5 files changed
+135
-43
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Open product quantities by warehouse to show moves
|
||||
|
||||
Version 5.2.0 - 2019-05-06
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Don't set default unit price on stock move
|
||||
|
||||
+45
-40
@@ -2,61 +2,66 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from .location import *
|
||||
from .shipment import *
|
||||
from .period import *
|
||||
from .move import *
|
||||
from .product import *
|
||||
from . import location
|
||||
from . import shipment
|
||||
from . import period
|
||||
from . import move
|
||||
from . import product
|
||||
from . import inventory
|
||||
from .configuration import *
|
||||
from . import configuration
|
||||
from . import party
|
||||
|
||||
from .move import StockMixin
|
||||
|
||||
__all__ = ['StockMixin', 'register']
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Location,
|
||||
Party,
|
||||
PartyLocation,
|
||||
ProductsByLocationsContext,
|
||||
LocationLeadTime,
|
||||
Move,
|
||||
ShipmentIn,
|
||||
ShipmentInReturn,
|
||||
ShipmentOut,
|
||||
ShipmentOutReturn,
|
||||
AssignShipmentOutAssignFailed,
|
||||
ShipmentInternal,
|
||||
Address,
|
||||
AssignShipmentInternalAssignFailed,
|
||||
AssignShipmentInReturnAssignFailed,
|
||||
Period,
|
||||
Cache,
|
||||
Template,
|
||||
Product,
|
||||
ProductByLocationContext,
|
||||
ProductQuantitiesByWarehouse,
|
||||
ProductQuantitiesByWarehouseContext,
|
||||
location.Location,
|
||||
location.Party,
|
||||
location.PartyLocation,
|
||||
location.ProductsByLocationsContext,
|
||||
location.LocationLeadTime,
|
||||
move.Move,
|
||||
shipment.ShipmentIn,
|
||||
shipment.ShipmentInReturn,
|
||||
shipment.ShipmentOut,
|
||||
shipment.ShipmentOutReturn,
|
||||
shipment.AssignShipmentOutAssignFailed,
|
||||
shipment.ShipmentInternal,
|
||||
shipment.Address,
|
||||
shipment.AssignShipmentInternalAssignFailed,
|
||||
shipment.AssignShipmentInReturnAssignFailed,
|
||||
period.Period,
|
||||
period.Cache,
|
||||
product.Template,
|
||||
product.Product,
|
||||
product.ProductByLocationContext,
|
||||
product.ProductQuantitiesByWarehouse,
|
||||
product.ProductQuantitiesByWarehouseContext,
|
||||
inventory.Inventory,
|
||||
inventory.InventoryLine,
|
||||
inventory.CountSearch,
|
||||
inventory.CountQuantity,
|
||||
Configuration,
|
||||
ConfigurationSequence,
|
||||
ConfigurationLocation,
|
||||
configuration.Configuration,
|
||||
configuration.ConfigurationSequence,
|
||||
configuration.ConfigurationLocation,
|
||||
module='stock', type_='model')
|
||||
Pool.register(
|
||||
AssignShipmentOut,
|
||||
AssignShipmentInternal,
|
||||
AssignShipmentInReturn,
|
||||
RecomputeCostPrice,
|
||||
shipment.AssignShipmentOut,
|
||||
shipment.AssignShipmentInternal,
|
||||
shipment.AssignShipmentInReturn,
|
||||
product.OpenProductQuantitiesByWarehouse,
|
||||
product.RecomputeCostPrice,
|
||||
inventory.Count,
|
||||
party.PartyReplace,
|
||||
party.PartyErase,
|
||||
module='stock', type_='wizard')
|
||||
Pool.register(
|
||||
DeliveryNote,
|
||||
PickingList,
|
||||
SupplierRestockingList,
|
||||
CustomerReturnRestockingList,
|
||||
InteralShipmentReport,
|
||||
shipment.DeliveryNote,
|
||||
shipment.PickingList,
|
||||
shipment.SupplierRestockingList,
|
||||
shipment.CustomerReturnRestockingList,
|
||||
shipment.InteralShipmentReport,
|
||||
module='stock', type_='report')
|
||||
+77
-2
@@ -13,8 +13,8 @@ from sql.conditionals import Coalesce
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import ModelSQL, ModelView, fields
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.wizard import Wizard, StateTransition
|
||||
from trytond.pyson import Eval, Or
|
||||
from trytond.wizard import Wizard, StateTransition, StateAction
|
||||
from trytond.pyson import Eval, Or, PYSONEncoder
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.tools import grouped_slice
|
||||
@@ -426,6 +426,32 @@ class ProductQuantitiesByWarehouse(ModelSQL, ModelView):
|
||||
|
||||
return dict((l.id, quantities[l.date]) for l in lines)
|
||||
|
||||
@classmethod
|
||||
def get_rec_name(cls, records, name):
|
||||
pool = Pool()
|
||||
Lang = pool.get('ir.lang')
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
Location = pool.get('stock.location')
|
||||
context = Transaction().context
|
||||
|
||||
if context.get('product_template'):
|
||||
name = Template(context['product_template']).rec_name
|
||||
elif context.get('product'):
|
||||
name = Product(context['product']).rec_name
|
||||
else:
|
||||
name = ''
|
||||
if context.get('warehouse'):
|
||||
warehouse_name = Location(context['warehouse']).rec_name
|
||||
else:
|
||||
warehouse_name = '-'
|
||||
lang = Lang.get()
|
||||
names = {}
|
||||
for record in records:
|
||||
names[record.id] = '%s (%s) @ %s' % (
|
||||
name, warehouse_name, lang.strftime(record.date))
|
||||
return names
|
||||
|
||||
|
||||
class ProductQuantitiesByWarehouseContext(ModelView):
|
||||
'Product Quantities By Warehouse'
|
||||
@@ -446,6 +472,55 @@ class ProductQuantitiesByWarehouseContext(ModelView):
|
||||
return warehouses[0].id
|
||||
|
||||
|
||||
class OpenProductQuantitiesByWarehouse(Wizard):
|
||||
"Open Product Quantities By Warehouse"
|
||||
__name__ = 'stock.product_quantities_warehouse.open'
|
||||
start_state = 'open_'
|
||||
open_ = StateAction('stock.act_move_form')
|
||||
|
||||
def do_open_(self, action):
|
||||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
ProductQuantitiesByWarehouse = pool.get(
|
||||
'stock.product_quantities_warehouse')
|
||||
context = Transaction().context
|
||||
today = Date.today()
|
||||
|
||||
record = ProductQuantitiesByWarehouse(context['active_id'])
|
||||
warehouse_id = context.get('warehouse', -1)
|
||||
domain = [
|
||||
['OR',
|
||||
[
|
||||
('from_location', 'child_of', [warehouse_id], 'parent'),
|
||||
('to_location', 'not child_of', [warehouse_id], 'parent'),
|
||||
],
|
||||
[
|
||||
('to_location', 'child_of', [warehouse_id], 'parent'),
|
||||
('from_location', 'not child_of',
|
||||
[warehouse_id], 'parent'),
|
||||
],
|
||||
],
|
||||
['OR',
|
||||
('effective_date', '=', record.date),
|
||||
[
|
||||
('effective_date', '=', None),
|
||||
('planned_date', '=', record.date),
|
||||
],
|
||||
],
|
||||
]
|
||||
if record.date < today:
|
||||
domain.append(('state', '=', 'done'))
|
||||
if context.get('product_template'):
|
||||
domain.append(
|
||||
('product.template', '=', context['product_template']))
|
||||
else:
|
||||
domain.append(('product', '=', context.get('product', -1)))
|
||||
action['pyson_domain'] = PYSONEncoder().encode(domain)
|
||||
action['pyson_search_value'] = None
|
||||
action['name'] += ' (' + record.rec_name + ')'
|
||||
return action, {}
|
||||
|
||||
|
||||
class RecomputeCostPrice(Wizard):
|
||||
'Recompute Cost Price'
|
||||
__name__ = 'product.recompute_cost_price'
|
||||
|
||||
+10
@@ -157,6 +157,16 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">product_quantities_warehouse_context_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_open_product_quantities_by_warehouse">
|
||||
<field name="name">Stock Moves</field>
|
||||
<field name="wiz_name">stock.product_quantities_warehouse.open</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="wizard_open_product_quantities_by_warehouse_keyword1">
|
||||
<field name="keyword">tree_open</field>
|
||||
<field name="model">stock.product_quantities_warehouse,-1</field>
|
||||
<field name="action" ref="wizard_open_product_quantities_by_warehouse"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.keyword"
|
||||
id="act_product_quantities_warehouse_keyword1">
|
||||
<field name="keyword">form_relate</field>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<tree keyword_open="1">
|
||||
<field name="date"/>
|
||||
<field name="quantity"/>
|
||||
</tree>
|
||||
Reference in new issue
Block a user