Add async subproducts
This commit is contained in:
parent
ecd6cef0ee
commit
6ba94dcf5e
2
PKG-INFO
2
PKG-INFO
|
@ -1,6 +1,6 @@
|
|||
Metadata-Version: 1.0
|
||||
Name: trytond_production_accounting
|
||||
Version: 6.0.0
|
||||
Version: 6.0.9
|
||||
Summary: Tryton module creates account moves for production stock moves.
|
||||
Home-page: http://www.tryton.org/
|
||||
Author: Oscar Alvarez
|
||||
|
|
|
@ -7,14 +7,12 @@ from . import stock
|
|||
from . import ir
|
||||
from . import bom
|
||||
from . import configuration
|
||||
from . import product
|
||||
from . import sale
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
configuration.Configuration,
|
||||
# product.ProductAverageCost,
|
||||
production.Production,
|
||||
production.ProductionDetailedStart,
|
||||
production.ProcessProductionAsyncStart,
|
||||
|
|
|
@ -40,7 +40,7 @@ class SubProduction(ModelSQL, ModelView):
|
|||
('in_progress', 'In progress'),
|
||||
('finished', 'Finished'),
|
||||
('cancelled', 'Canceled'),
|
||||
], 'State', select=True)
|
||||
], 'State')
|
||||
notes = fields.Char('Notes')
|
||||
|
||||
@staticmethod
|
||||
|
@ -757,22 +757,39 @@ class ProcessProductionAsync(Wizard):
|
|||
|
||||
producibles = {}
|
||||
|
||||
for line in lines:
|
||||
product = line.product
|
||||
def _add_producibles(product, qty, sub=False):
|
||||
try:
|
||||
producibles[product]['quantity'].append(line.quantity)
|
||||
producibles[product]['quantity'].append(qty)
|
||||
bom = producibles[product]['bom']
|
||||
output = bom.outputs[0]
|
||||
except:
|
||||
outputs = BOMOutput.search([
|
||||
('product', '=', product.id),
|
||||
('bom.active', '=', True)
|
||||
])
|
||||
if not outputs:
|
||||
continue
|
||||
return
|
||||
bom = outputs[0].bom
|
||||
if sub and not bom.is_subproduction:
|
||||
return
|
||||
output = outputs[0]
|
||||
producibles[product] = {
|
||||
'quantity': [line.quantity],
|
||||
'bom': output.bom,
|
||||
'quantity': [qty],
|
||||
'bom': bom,
|
||||
}
|
||||
# Here we add all subproducts inside inputs too, because is
|
||||
# neccesary for complete its production
|
||||
for input in bom.inputs:
|
||||
in_quantity, in_product = input.quantity, input.product
|
||||
if in_product.template.producible:
|
||||
_add_producibles(
|
||||
in_product,
|
||||
in_quantity * (qty / output.quantity),
|
||||
sub=True)
|
||||
|
||||
for line in lines:
|
||||
_add_producibles(line.product, line.quantity)
|
||||
|
||||
if configuration.production_accounting:
|
||||
self.create_production_moves(producibles, journal, period_id)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.8
|
||||
version=6.0.9
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
@ -13,6 +13,5 @@ xml:
|
|||
message.xml
|
||||
configuration.xml
|
||||
production.xml
|
||||
product.xml
|
||||
bom.xml
|
||||
sale.xml
|
||||
|
|
Loading…
Reference in New Issue