fixes report shipment detailed and adds fields for create inventory wizard
This commit is contained in:
parent
0643296a97
commit
2d807f06ca
|
@ -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,
|
||||
|
|
|
@ -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)
|
|
@ -0,0 +1,26 @@
|
|||
<?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. -->
|
||||
<tryton>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="inventory_create_start_view_form">
|
||||
<field name="model">stock.inventory.create.start</field>
|
||||
<field name="inherit" ref="stock_inventory_location.inventory_create_start_view_form"/>
|
||||
<field name="name">inventory_create_start_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="inventory_view_form">
|
||||
<field name="model">stock.inventory</field>
|
||||
<field name="inherit" ref="stock.inventory_view_form"/>
|
||||
<field name="name">inventory_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.keyword" id="action_inventory_create_start_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">stock.inventory,-1</field>
|
||||
<field name="action" ref="stock_inventory_location.wizard_create_inventory"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
29
shipment.py
29
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name='empty_quantity']" position="after">
|
||||
<label name="assign_to"/>
|
||||
<field name="assign_to"/>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="/form/field[@name='complete_lines']" position="after">
|
||||
<newline/>
|
||||
<field name="categories" colspan="4"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,24 @@
|
|||
<?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. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/field[@name='lines']" position="after">
|
||||
<label name="assign_to"/>
|
||||
<field name="assign_to"/>
|
||||
<label name="approved_by"/>
|
||||
<field name="approved_by"/>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="/form/field[@name='lines']" position="replace">
|
||||
<notebook colspan="4">
|
||||
<page string="Inventory" id="inventory">
|
||||
<field name="lines" colspan="4" view_ids="stock.inventory_line_view_list_simple"/>
|
||||
</page>
|
||||
<page string="Other Info" id="info">
|
||||
<field name="categories" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</xpath>
|
||||
|
||||
</data>
|
Loading…
Reference in New Issue