add colum imp consumo in report warehouse
This commit is contained in:
parent
0aa38ab700
commit
174b72b1d4
29
inventory.py
29
inventory.py
|
@ -1,7 +1,7 @@
|
|||
# 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, ModelView, Workflow
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import fields, ModelView, Workflow
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.modules.company.model import employee_field
|
||||
from trytond.pyson import Eval, If
|
||||
|
||||
|
@ -12,8 +12,12 @@ class CreateInventoriesStart(metaclass=PoolMeta):
|
|||
assign_to = employee_field('Assing To')
|
||||
category = fields.Many2One('product.category', 'Category', 'Product Categories')
|
||||
products = fields.Many2Many('product.product', None, None, 'Products',
|
||||
domain=[If(Eval('category'),
|
||||
('template.categories', '=', Eval('category')), ())],
|
||||
domain=[
|
||||
If(
|
||||
Eval('category'),
|
||||
('template.categories', '=', Eval('category')),
|
||||
())
|
||||
],
|
||||
depends=['categories'])
|
||||
|
||||
|
||||
|
@ -21,7 +25,8 @@ class CreateInventories(metaclass=PoolMeta):
|
|||
__name__ = 'stock.inventory.create'
|
||||
|
||||
def get_inventory(self, location, Inventory):
|
||||
inventory = super(CreateInventories, self).get_inventory(location, Inventory)
|
||||
inventory = super(CreateInventories, self).get_inventory(
|
||||
location, Inventory)
|
||||
if self.start.products:
|
||||
self.start.complete_lines = False
|
||||
products = [s.id for s in self.start.products]
|
||||
|
@ -40,10 +45,12 @@ class InventoryLine(metaclass=PoolMeta):
|
|||
def __setup__(cls):
|
||||
super(InventoryLine, cls).__setup__()
|
||||
cls._states = {
|
||||
'readonly': ~Eval('inventory_state').in_(["draft", "checkup", "pre_count"])
|
||||
'readonly': ~Eval('inventory_state').in_([
|
||||
"draft", "checkup", "pre_count"])
|
||||
}
|
||||
cls.quantity.states = cls._states
|
||||
|
||||
|
||||
|
||||
class Inventory(metaclass=PoolMeta):
|
||||
'Stock Inventory'
|
||||
__name__ = 'stock.inventory'
|
||||
|
@ -58,9 +65,13 @@ class Inventory(metaclass=PoolMeta):
|
|||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Inventory, cls).__setup__()
|
||||
cls.state.selection.extend([('pre_count', 'Pre-count'), ('checkup', 'Checkup')])
|
||||
cls.state.selection.extend([
|
||||
('pre_count', 'Pre-count'),
|
||||
('checkup', 'Checkup')])
|
||||
cls._states = {
|
||||
'readonly': (~Eval('state').in_(["draft", "checkup", "pre_count"]) | ~Eval('location')
|
||||
'readonly': (
|
||||
~Eval('state').in_(["draft", "checkup", "pre_count"])
|
||||
| ~Eval('location')
|
||||
| ~Eval('date')),
|
||||
}
|
||||
cls.lines.states = cls._states
|
||||
|
|
12
position.py
12
position.py
|
@ -31,14 +31,16 @@ class ProductTemplatePosition(ModelSQL, ModelView):
|
|||
__name__ = 'product_template.position'
|
||||
|
||||
# _rec_name = 'position'
|
||||
position = fields.Many2One('product.position', 'Position', required=True, ondelete='CASCADE')
|
||||
template = fields.Many2One('product.template', 'Template', required=True, ondelete='RESTRICT')
|
||||
warehouse =fields.Function(fields.Many2One('stock.location', 'Warehouse'), 'on_change_with_warehouse')
|
||||
|
||||
position = fields.Many2One('product.position', 'Position', required=True,
|
||||
ondelete='CASCADE')
|
||||
template = fields.Many2One('product.template', 'Template', required=True,
|
||||
ondelete='RESTRICT')
|
||||
warehouse = fields.Function(fields.Many2One('stock.location', 'Warehouse'),
|
||||
'on_change_with_warehouse')
|
||||
|
||||
@fields.depends('position')
|
||||
def on_change_with_warehouse(self, name=None):
|
||||
warehouse = None
|
||||
if self.position:
|
||||
warehouse = self.position.warehouse.id
|
||||
return warehouse
|
||||
return warehouse
|
||||
|
|
|
@ -49,7 +49,6 @@ class Product(metaclass=PoolMeta):
|
|||
('product', '=', self.id),
|
||||
('effective_date', '<=', target_date),
|
||||
], order=[('effective_date', 'DESC')], limit=1)
|
||||
print(' product >>>> ', avg_product)
|
||||
if avg_product:
|
||||
return avg_product[0].cost_price
|
||||
else:
|
||||
|
|
27
shipment.py
27
shipment.py
|
@ -7,7 +7,9 @@ from sql import Table
|
|||
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button, StateReport
|
||||
from trytond.wizard import (
|
||||
Wizard, StateTransition, StateView,
|
||||
Button, StateReport)
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.report import Report
|
||||
|
@ -413,11 +415,13 @@ class ShipmentDetailedStart(ModelView):
|
|||
('internal', 'Internal'),
|
||||
], 'Type Shipment', required=True)
|
||||
grouped = fields.Boolean('Grouped')
|
||||
from_locations = fields.Many2Many('stock.location', None, None, 'From Location', domain=[
|
||||
from_locations = fields.Many2Many('stock.location', None, None, 'From Location',
|
||||
domain=[
|
||||
('name', 'ilike', 'ZA%'),
|
||||
('active', '=', True)
|
||||
])
|
||||
to_locations = fields.Many2Many('stock.location', None, None, 'To Location', domain=[
|
||||
to_locations = fields.Many2Many('stock.location', None, None, 'To Location',
|
||||
domain=[
|
||||
('name', 'ilike', 'ZA%'),
|
||||
('active', '=', True)
|
||||
])
|
||||
|
@ -439,12 +443,12 @@ class ShipmentDetailed(Wizard):
|
|||
print_ = StateReport('stock.shipment.shipment_detailed.report')
|
||||
|
||||
def do_print_(self, action):
|
||||
from_locations=None
|
||||
to_locations=None
|
||||
from_locations = None
|
||||
to_locations = None
|
||||
if self.start.from_locations:
|
||||
from_locations= [l.id for l in self.start.from_locations]
|
||||
from_locations = [n.id for n in self.start.from_locations]
|
||||
if self.start.to_locations:
|
||||
to_locations= [l.id for l in self.start.to_locations]
|
||||
to_locations = [n.id for n in self.start.to_locations]
|
||||
|
||||
data = {
|
||||
'company': self.start.company.id,
|
||||
|
@ -494,11 +498,14 @@ class ShipmentDetailedReport(Report):
|
|||
)
|
||||
shipments_id = [model + ',' + str(sh['id']) for sh in shipments]
|
||||
fields_names = [
|
||||
'product.account_category.name', 'product.name', 'product.code', 'product.cost_price',
|
||||
'quantity', 'to_location.name', 'from_location.name', 'shipment.reference',
|
||||
'product.account_category.name', 'product.name', 'product.code',
|
||||
'product.cost_price', 'quantity', 'to_location.name',
|
||||
'from_location.name', 'shipment.reference',
|
||||
'effective_date', 'shipment.number'
|
||||
]
|
||||
fields = ModelShipment.fields_get(fields_names=['operation_center', 'customer', 'supplier', 'incoming_moves', 'analytic_account'])
|
||||
fields = ModelShipment.fields_get(fields_names=[
|
||||
'operation_center', 'customer', 'supplier',
|
||||
'incoming_moves', 'analytic_account'])
|
||||
if 'operation_center' in fields.keys():
|
||||
fields_names.append('shipment.operation_center.rec_name')
|
||||
|
||||
|
|
11
stock.py
11
stock.py
|
@ -417,6 +417,7 @@ class WarehouseReport(Report):
|
|||
dom_products.append([('template.product_suppliers.party', 'in', data['suppliers'])])
|
||||
|
||||
total_amount = 0
|
||||
total_amount_imp = 0
|
||||
values = {}
|
||||
products = []
|
||||
if data['group_by_location']:
|
||||
|
@ -434,17 +435,21 @@ class WarehouseReport(Report):
|
|||
try:
|
||||
suppliers[sup_id]['products'].append(p)
|
||||
suppliers[sup_id]['total_amount'].append(p.amount_cost if p.amount_cost else 0)
|
||||
suppliers[sup_id]['total_amount_imp'].append(p.extra_tax * Deciaml(p.quantity) if p.extra_tax else 0)
|
||||
except:
|
||||
suppliers[sup_id] = {}
|
||||
suppliers[sup_id]['products'] = [p]
|
||||
suppliers[sup_id]['party'] = prod_sup.party
|
||||
suppliers[sup_id]['total_amount'] = [p.amount_cost if p.amount_cost else 0]
|
||||
suppliers[sup_id]['total_amount_imp'] = [p.extra_tax * Decimal(p.quantity) if p.extra_tax else 0]
|
||||
total_amount = sum([p.amount_cost for p in prdts if p.amount_cost])
|
||||
total_amount_imp = sum([p.extra_tax * Decimal(p.quantity) for p in prdts if p.extra_tax])
|
||||
values[l.id] = {
|
||||
'name': l.name,
|
||||
'products': prdts,
|
||||
'suppliers': suppliers.values(),
|
||||
'total_amount': total_amount
|
||||
'total_amount': total_amount,
|
||||
'total_amount_imp': total_amount_imp
|
||||
}
|
||||
products = values.values()
|
||||
else:
|
||||
|
@ -454,6 +459,7 @@ class WarehouseReport(Report):
|
|||
if data['only_minimal_level']:
|
||||
products = [p for p in products if p.quantity <= min_quantities[p.id]]
|
||||
total_amount = sum([p.amount_cost for p in products if p.amount_cost])
|
||||
total_amount_imp = sum([p.extra_tax * Decimal(p.quantity) for p in products if p.extra_tax])
|
||||
suppliers = {}
|
||||
if data['group_by_supplier']:
|
||||
for p in products:
|
||||
|
@ -464,11 +470,13 @@ class WarehouseReport(Report):
|
|||
try:
|
||||
suppliers[sup_id]['products'].append(p)
|
||||
suppliers[sup_id]['total_amount'].append(p.amount_cost if p.amount_cost else 0)
|
||||
suppliers[sup_id]['total_amount_imp'].append(p.extra_tax * Decimal(p.quantity) if p.extra_tax else 0)
|
||||
except:
|
||||
suppliers[sup_id] = {}
|
||||
suppliers[sup_id]['products'] = [p]
|
||||
suppliers[sup_id]['party'] = prod_sup.party
|
||||
suppliers[sup_id]['total_amount'] = [p.amount_cost if p.amount_cost else 0]
|
||||
suppliers[sup_id]['total_amount_imp'] = [p.extra_tax * Decimal(p.quantity) if p.extra_tax else 0]
|
||||
products = suppliers.values()
|
||||
|
||||
cursor = Transaction().connection.cursor()
|
||||
|
@ -488,6 +496,7 @@ class WarehouseReport(Report):
|
|||
report_context['group_by_supplier'] = data['group_by_supplier']
|
||||
report_context['records'] = products
|
||||
report_context['total_amount'] = total_amount
|
||||
report_context['total_amount_imp'] = total_amount_imp
|
||||
report_context['last_purchase'] = last_purchase
|
||||
report_context['location'] = data['location_names']
|
||||
report_context['stock_date_end'] = data['to_date']
|
||||
|
|
BIN
warehouse.fods
BIN
warehouse.fods
Binary file not shown.
Loading…
Reference in New Issue