diff --git a/__init__.py b/__init__.py
index 0d53093..66f919f 100644
--- a/__init__.py
+++ b/__init__.py
@@ -5,6 +5,7 @@ from trytond.pool import Pool
from . import product
from . import stock
from . import shipment
+from . import inventory
def register():
@@ -20,6 +21,9 @@ def register():
shipment.InternalShipment,
shipment.ShipmentIn,
shipment.ShipmentDetailedStart,
+ inventory.Inventory,
+ # inventory.CreateInventoriesStart,
+ inventory.InventoryProductCategory,
module='stock_co', type_='model')
Pool.register(
shipment.ShipmentDetailed,
@@ -31,6 +35,7 @@ def register():
shipment.ShipmentOutForceDraft,
shipment.ShipmentInternalForceDraft,
shipment.Assign,
+ # inventory.CreateInventories,
module='stock_co', type_='wizard')
Pool.register(
stock.MoveByProduct,
diff --git a/inventory.py b/inventory.py
new file mode 100644
index 0000000..6fed57f
--- /dev/null
+++ b/inventory.py
@@ -0,0 +1,52 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from trytond.model import fields, ModelSQL
+from trytond.pool import Pool, PoolMeta
+from trytond.modules.company.model import employee_field
+
+
+class CreateInventoriesStart(metaclass=PoolMeta):
+ __name__ = 'stock.inventory.create.start'
+
+ assign_to = employee_field("Assign To")
+ categories = fields.Many2Many('product.category', None, None, 'Product Categories')
+
+
+class CreateInventories(metaclass=PoolMeta):
+ __name__ = 'stock.inventory.create'
+
+ def get_inventory(self, location, Inventory):
+ inventory = super(CreateInventories, self).get_inventory(location, Inventory)
+ if self.start.categories:
+ self.start.complete_lines = False
+ pool = Pool()
+ Product = pool.get('product.product')
+ categories = [s.id for s in self.start.categories]
+ products = Product.search_read([
+ ('template.categories', 'in', categories)
+ ])
+ prd_ids = [{'product': p['id']} for p in products]
+ inventory.assign_to = self.start.assign_to
+ inventory.lines = prd_ids
+
+ return inventory
+
+
+class Inventory(metaclass=PoolMeta):
+ 'Stock Inventory'
+ __name__ = 'stock.inventory'
+
+ assign_to = employee_field("Assign To")
+ approved_by = employee_field("Approved By")
+ categories = fields.Many2Many('stock.inventory.product_category', 'inventory',
+ 'category', 'Product Categories', states={'readonly': True})
+
+
+class InventoryProductCategory(ModelSQL):
+ "Inventory -Product Category"
+ __name__ = "stock.inventory.product_category"
+ _table = 'stock_inventory_product_category_rel'
+ inventory = fields.Many2One('stock.inventory', 'Inventory',
+ ondelete='CASCADE', select=True, required=True)
+ category = fields.Many2One('product.category', 'Product Category',
+ ondelete='CASCADE', select=True, required=True)
diff --git a/inventory.xml b/inventory.xml
new file mode 100644
index 0000000..7bca3a1
--- /dev/null
+++ b/inventory.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ stock.inventory.create.start
+
+ inventory_create_start_form
+
+
+
+ stock.inventory
+
+ inventory_form
+
+
+
+ form_action
+ stock.inventory,-1
+
+
+
+
+
diff --git a/shipment.py b/shipment.py
index da984be..8f5aaac 100644
--- a/shipment.py
+++ b/shipment.py
@@ -310,19 +310,22 @@ class ShipmentDetailedReport(Report):
('effective_date', '>=', data['start_date']),
('effective_date', '<=', data['end_date'])
]
- fields_names = ['id']
+ fields_names = ['id', 'operation_center.rec_name']
shipments = ModelShipment.search_read(dom_shipment,
fields_names=fields_names,
order=[('effective_date', 'ASC')]
)
- shipments = [model + ',' + str(sh['id']) for sh in shipments]
-
+ shipments_id = [model + ',' + str(sh['id']) for sh in shipments]
fields_names = [
'product.account_category.name', 'product.name', 'product.cost_price',
- 'quantity', 'to_location.name'
+ 'quantity', 'to_location.name',
]
+ fields = ModelShipment.fields_get(fields_names=['operation_center'])
+ if 'operation_center' in fields.keys():
+ fields_names.append('shipment.operation_center.rec_name')
+
moves = Move.search_read(
- ('shipment', 'in', shipments),
+ ('shipment', 'in', shipments_id),
fields_names=fields_names,
order=[('to_location', 'DESC'), ('create_date', 'ASC')]
)
@@ -333,9 +336,7 @@ class ShipmentDetailedReport(Report):
product, quantity = dgetter(m)
product_, = product_browse([product['id']])
try:
- # FIXME
- # oc = s.to_location.parent.operation_center.name
- pass
+ oc = m['shipment.']['operation_center.']['rec_name']
except:
oc = ''
@@ -344,14 +345,18 @@ class ShipmentDetailedReport(Report):
if category:
category = category['name']
- m.update({
- 'oc': '',
+ value = {
+ 'oc': oc,
'product': product['name'],
'cost_price': cost_price,
'category': category,
'cost_base': float(cost_price) * quantity,
- 'cost_w_tax': float(product_.cost_price_taxed) * quantity,
- })
+ }
+ if hasattr(product_, 'cost_price_taxed'):
+ value['cost_w_tax'] = float(product_.cost_price_taxed) * quantity
+ else:
+ value['cost_w_tax'] = None
+ m.update(value)
report_context['records'] = moves
report_context['company'] = company
diff --git a/tryton.cfg b/tryton.cfg
index 1c23269..bacd923 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,11 +1,13 @@
[tryton]
-version=6.0.3
+version=6.0.4
depends:
product
stock
stock_supply
stock_lot
+ stock_inventory_location
xml:
product.xml
stock.xml
shipment.xml
+ inventory.xml
diff --git a/view/inventory_create_start_form.xml b/view/inventory_create_start_form.xml
new file mode 100644
index 0000000..d9233f4
--- /dev/null
+++ b/view/inventory_create_start_form.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/view/inventory_form.xml b/view/inventory_form.xml
new file mode 100644
index 0000000..579884b
--- /dev/null
+++ b/view/inventory_form.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+