changeset f9b4c7fcdd86 in modules/production:default
details:
https://hg.tryton.org/modules/production?cmd=changeset&node=f9b4c7fcdd86
description:
Add lot traceability
issue10792
review387871002
diffstat:
__init__.py | 3 +++
stock.py | 43 ++++++++++++++++++++++++++++++++++++++++++-
tryton.cfg | 2 ++
3 files changed, 47 insertions(+), 1 deletions(-)
diffs (81 lines):
diff -r 85b742e89d15 -r f9b4c7fcdd86 __init__.py
--- a/__init__.py Tue Feb 15 00:08:47 2022 +0100
+++ b/__init__.py Sat Mar 19 22:44:15 2022 +0100
@@ -27,5 +27,8 @@
ir.Cron,
module='production', type_='model')
Pool.register(
+ stock.LotTrace,
+ module='production', type_='model', depends=['stock_lot'])
+ Pool.register(
bom.OpenBOMTree,
module='production', type_='wizard')
diff -r 85b742e89d15 -r f9b4c7fcdd86 stock.py
--- a/stock.py Tue Feb 15 00:08:47 2022 +0100
+++ b/stock.py Sat Mar 19 22:44:15 2022 +0100
@@ -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
-from trytond.pool import PoolMeta
+from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
@@ -96,3 +96,44 @@
if self.move.production_output:
document = str(self.move.production_output)
return document
+
+
+class LotTrace(metaclass=PoolMeta):
+ __name__ = 'stock.lot.trace'
+
+ production_input = fields.Many2One('production', "Production Input")
+ production_output = fields.Many2One('production', "Production Output")
+
+ @classmethod
+ def _columns(cls, move):
+ return super()._columns(move) + [
+ move.production_input.as_('production_input'),
+ move.production_output.as_('production_output'),
+ ]
+
+ @classmethod
+ def get_documents(cls):
+ pool = Pool()
+ Model = pool.get('ir.model')
+ return super().get_documents() + [
+ ('production', Model.get_name('production'))]
+
+ def get_document(self, name):
+ document = super().get_document(name)
+ if self.production_input:
+ document = str(self.production_input)
+ elif self.production_output:
+ document = str(self.production_output)
+ return document
+
+ def _get_upward_traces(self):
+ traces = super()._get_upward_traces()
+ if self.production_input:
+ traces.update(self.production_input.outputs)
+ return traces
+
+ def _get_downward_traces(self):
+ traces = super()._get_downward_traces()
+ if self.production_output:
+ traces.update(self.production_output.inputs)
+ return traces
diff -r 85b742e89d15 -r f9b4c7fcdd86 tryton.cfg
--- a/tryton.cfg Tue Feb 15 00:08:47 2022 +0100
+++ b/tryton.cfg Sat Mar 19 22:44:15 2022 +0100
@@ -6,6 +6,8 @@
product
res
stock
+extras_depend:
+ stock_lot
xml:
production.xml
configuration.xml