fix pyflakes errors and and coding style

This commit is contained in:
Adrián Bernardi 2020-08-06 18:36:35 -03:00
parent 7f3a7c7f12
commit ef59cc0c51
66 changed files with 134 additions and 87 deletions

View File

@ -102,6 +102,7 @@ def setup(database, language, industry):
'execute "kalenis-cli run" to start Kalenis LIMS server'.format(
OK_COLOR), fg=OK_COLOR))
@cli.command()
@click.option('-d', '--database', default='kalenislims', show_default=True)
def run(database):

View File

@ -2,6 +2,7 @@
# This file is part of lims module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields, Unique
from trytond.wizard import Wizard, StateTransition, StateView, Button
from trytond.pyson import Eval

View File

@ -865,7 +865,8 @@ class EntryDetailAnalysis(ModelSQL, ModelView):
return super().view_attributes() + [
('//group[@id="cie"]', 'states', {
'invisible': ~Eval('cie_fraction_type'),
})]
}),
]
@classmethod
def create(cls, vlist):

View File

@ -7,7 +7,6 @@ import operator
from datetime import datetime
from dateutil.relativedelta import relativedelta
from decimal import Decimal
from sql.conditionals import Case
from trytond.model import ModelView, ModelSQL, fields, Unique, DictSchemaMixin
@ -1486,7 +1485,8 @@ class Fraction(ModelSQL, ModelView):
}),
('//page[@id="con"]', 'states', {
'invisible': Not(Bool(Equal(Eval('special_type'), 'con'))),
})]
}),
]
@classmethod
def copy(cls, fractions, default=None):

View File

@ -3,6 +3,7 @@
# the full copyright notices and license terms.
import unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import doctest_teardown

View File

@ -2,6 +2,7 @@
# This file is part of lims module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields, Unique
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval

View File

@ -2,7 +2,6 @@
# This file is part of lims_account_invoice module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from datetime import datetime
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -1,6 +1,4 @@
<?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="/tree/field[@name='amount']"

View File

@ -2,8 +2,8 @@
# This file is part of lims_analytic module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from decimal import Decimal
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<calendar dtstart="date" dtend="date" mode="month" background_color="color">
<field name="device"/>
<field name="activity"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="name"/>
<field name="name"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree>
<field name="name"/>
</tree>

View File

@ -202,11 +202,13 @@ class ResultsReport(metaclass=PoolMeta):
for version in self.versions:
for detail in version.details:
for line in detail.notebook_lines:
entry = line.notebook_line.fraction.entry
to_addrs.extend([c.contact.email for c
in line.notebook_line.fraction.entry.report_contacts
in entry.report_contacts
if c.contact.report_contact and not
c.entry.invoice_party.block_reports_automatic_sending])
entries.append(line.notebook_line.fraction.entry.number) # TODO: Debug line
# TODO: Debug line
entries.append(entry.number)
# TODO: Debug line
logger.info(
'Cron - Digital Signs:results_report.number:%s:to_addrs:%s'

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -1,6 +1,4 @@
<?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. -->
<form>
<image name="tryton-warning" xexpand="0" xfill="0"/>
<label string="Digital Sign Failed! Solve the problem and try again."

View File

@ -1,6 +1,4 @@
<?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. -->
<form col="2">
<image name="tryton-info" xexpand="0" xfill="0"/>
<label string="Digital Sign reports?" id="synchronize"

View File

@ -1,6 +1,4 @@
<?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. -->
<form>
<image name="tryton-info" xexpand="0" xfill="0"/>
<label string="Digital Sign Succeed!" id="succeed"

View File

@ -38,10 +38,10 @@ class ResultsReportVersionDetailSample(metaclass=PoolMeta):
@classmethod
def view_attributes(cls):
missing_diagnosis = True if 'diagnosis' not in cls._fields else False
return [
return super().view_attributes() + [
('//group[@id="diagnosis"]', 'states', {
'invisible': missing_diagnosis,
}),
'invisible': missing_diagnosis,
}),
]
@fields.depends('precedent1')

View File

@ -68,7 +68,8 @@ class ResultsImport(ModelSQL, ModelView):
return description
def loadController(self):
raise UserError(gettext('lims_instrument.msg_not_module', module=self.name))
raise UserError(gettext('lims_instrument.msg_not_module',
module=self.name))
def getInputFile(self):
return self._infile
@ -83,7 +84,8 @@ class ResultsImport(ModelSQL, ModelView):
return self.controller.parse(self, infile)
except AttributeError:
traceback.print_exc()
raise UserError(gettext('lims_instrument.msg_not_implemented', function='parse'))
raise UserError(gettext('lims_instrument.msg_not_implemented',
function='parse'))
def exportResults(self):
'''
@ -467,11 +469,13 @@ class NotebookLoadResultsFile(Wizard):
elif (line.imported_end_date and line.start_date and
line.start_date > line.imported_end_date):
prevent_line = True
outcome = gettext('lims_instrument.msg_end_date_start_date')
outcome = gettext(
'lims_instrument.msg_end_date_start_date')
elif (line.imported_inj_date and line.start_date and
line.start_date > line.imported_inj_date):
prevent_line = True
outcome = gettext('lims_instrument.msg_inj_date_start_date')
outcome = gettext(
'lims_instrument.msg_inj_date_start_date')
elif (line.imported_end_date and line.imported_inj_date and
line.imported_inj_date > line.imported_end_date):
prevent_line = True

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -4,4 +4,4 @@ depends:
lims
xml:
resultsimport.xml
message.xml
message.xml

View File

@ -98,7 +98,7 @@ def parse(self, infile):
repetition] = values
else:
self.rawresults[fraction][self.analysis_code] = {
repetition: values,
repetition: values,
}
else:
self.rawresults[fraction] = {

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -2,4 +2,3 @@
version=5.4.0
depends:
lims_instrument

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -2,4 +2,3 @@
version=5.4.0
depends:
lims_instrument

View File

@ -48,7 +48,7 @@ def parse(self, infile):
chromatogram = row2nd[COL['G']].value if (
row2nd[COL['G']].ctype == xlrd.XL_CELL_TEXT) else None
# 3rd row: injection date
# 3rd row: injection date
row3nd = worksheet.row(2)
inj_date_raw = row3nd[COL['E']].value
if row3nd[COL['E']].ctype == xlrd.XL_CELL_TEXT:

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -2,4 +2,3 @@
version=5.4.0
depends:
lims_instrument

View File

@ -152,14 +152,15 @@ class Interface(Workflow, ModelSQL, ModelView):
name = fields.Char('Name', required=True)
revision = fields.Integer('Revision', required=True, readonly=True)
language = fields.Many2One('ir.lang', 'Language',
states={'readonly': Eval('state') != 'draft'}, depends=['state'],
domain=[('translatable', '=', True)])
domain=[('translatable', '=', True)],
states={'readonly': Eval('state') != 'draft'},
depends=['state'])
kind = fields.Selection([
('template', 'Template'),
('controller', 'Controller'),
], 'Kind', required=True, states={
'readonly': Eval('state') != 'draft',
}, depends=['state'])
], 'Kind', required=True,
states={'readonly': Eval('state') != 'draft'},
depends=['state'])
state = fields.Selection([
('draft', 'Draft'),
('active', 'Active'),
@ -171,7 +172,8 @@ class Interface(Workflow, ModelSQL, ModelView):
states={
'readonly': Eval('state') != 'draft',
'invisible': Eval('kind') != 'template',
}, depends=_depends)
},
depends=_depends)
table = fields.Many2One('lims.interface.table', 'Table', readonly=True)
template_type = fields.Selection([
(None, ''),
@ -188,15 +190,16 @@ class Interface(Workflow, ModelSQL, ModelView):
('semicolon', 'Semicolon (;)'),
('tab', 'Tab'),
('space', 'Space'),
('other', 'Other')],
'Field separator',
('other', 'Other'),
], 'Field separator',
states={
'required': And(Eval('kind') == 'template',
Eval('template_type') == 'csv'),
'invisible': Or(Eval('kind') != 'template',
Eval('template_type') != 'csv'),
'readonly': Eval('state') != 'draft',
}, depends=['kind', 'template_type', 'state'])
},
depends=['kind', 'template_type', 'state'])
field_separator_other = fields.Char('Other',
states={
'required': And(Eval('template_type') == 'csv',
@ -204,7 +207,8 @@ class Interface(Workflow, ModelSQL, ModelView):
'invisible': Or(Eval('template_type') != 'csv',
Eval('field_separator') != 'other'),
'readonly': Eval('state') != 'draft',
}, depends=['template_type', 'field_separator', 'state'])
},
depends=['template_type', 'field_separator', 'state'])
analysis_field = fields.Many2One('lims.interface.column',
'Analysis field', depends=['state', 'id'],
domain=[('interface', '=', Eval('id')), ('grouped', '=', False)],
@ -653,19 +657,19 @@ class Column(sequence_ordered(), ModelSQL, ModelView):
('reference', 'Reference'),
], 'Field Type')
related_model = fields.Many2One('ir.model', 'Related Model',
states={
depends=['type_'], states={
'required': Eval('type_') == 'many2one',
'invisible': Eval('type_') != 'many2one',
}, depends=['type_'])
})
default_value = fields.Char('Default value',
states={'readonly': Bool(Eval('expression'))},
depends=['expression'])
readonly = fields.Boolean('Read only')
digits = fields.Integer('Digits',
states={
depends=['type_'], states={
'required': Eval('type_').in_(['float', 'numeric']),
'invisible': ~Eval('type_').in_(['float', 'numeric']),
}, depends=['type_'])
})
source_start = fields.Integer('Field start',
states={
'required': Eval('_parent_interface', {}).get(
@ -704,10 +708,10 @@ class Column(sequence_ordered(), ModelSQL, ModelView):
help='Check if value have to be transferred to notebook line')
related_line_field = fields.Many2One('ir.model.field', 'Related field',
domain=[('model.model', '=', 'lims.notebook.line')],
states={
depends=['transfer_field'], states={
'required': Bool(Eval('transfer_field')),
'invisible': Not(Eval('transfer_field'))
}, depends=['transfer_field'])
})
interface_state = fields.Function(fields.Selection([
('draft', 'Draft'),
('active', 'Active'),
@ -938,9 +942,8 @@ class Compilation(Workflow, ModelSQL, ModelView):
date_time = fields.DateTime('Date', required=True, select=True)
interface = fields.Many2One('lims.interface', 'Device Interface',
domain=[('state', '=', 'active')])
revision = fields.Integer('Revision', states={
'readonly': Eval('state') != 'draft',
}, depends=['state'])
revision = fields.Integer('Revision',
states={'readonly': Eval('state') != 'draft'}, depends=['state'])
table = fields.Many2One('lims.interface.table', 'Table')
device = fields.Many2One('lims.lab.device', 'Device')
origins = fields.One2Many('lims.interface.compilation.origin',

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -11,4 +11,4 @@ xml:
stock.xml
production.xml
configuration.xml
message.xml
message.xml

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -35,7 +35,8 @@ class Project(metaclass=PoolMeta):
return super().view_attributes() + [
('//group[@id="itl"]', 'states', {
'invisible': Not(Bool(Equal(Eval('type'), 'itl'))),
})]
}),
]
class Entry(metaclass=PoolMeta):

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -2,8 +2,8 @@
# This file is part of lims_project_study_plan module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from datetime import datetime
from trytond.model import ModelSQL, ModelView, fields, Unique
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Equal, Bool, Not, And, Or
@ -214,7 +214,8 @@ class Project(metaclass=PoolMeta):
return super().view_attributes() + [
('//group[@id="study_plan"]', 'states', {
'invisible': Not(Bool(Equal(Eval('type'), 'study_plan'))),
})]
}),
]
@classmethod
def create(cls, vlist):
@ -794,7 +795,8 @@ class Sample(metaclass=PoolMeta):
('//page[@id="study_plan"]', 'states', {
'invisible': Not(Bool(Equal(
Eval('project_type'), 'study_plan'))),
})]
}),
]
class CreateSampleStart(metaclass=PoolMeta):
@ -828,7 +830,8 @@ class CreateSampleStart(metaclass=PoolMeta):
('//page[@id="study_plan"]', 'states', {
'invisible': Not(Bool(Equal(
Eval('project_type'), 'study_plan'))),
})]
}),
]
class CreateSample(metaclass=PoolMeta):

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -49,7 +49,8 @@ class Project(metaclass=PoolMeta):
return super().view_attributes() + [
('//group[@id="tas"]', 'states', {
'invisible': Not(Bool(Equal(Eval('type'), 'tas'))),
})]
}),
]
@fields.depends('client', 'tas_invoice_party')
def on_change_client(self):

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -29,7 +29,8 @@ class Project(metaclass=PoolMeta):
return super().view_attributes() + [
('//group[@id="water"]', 'states', {
'invisible': Not(Bool(Equal(Eval('type'), 'water'))),
})]
}),
]
class Entry(metaclass=PoolMeta):
@ -66,7 +67,8 @@ class Sample(metaclass=PoolMeta):
('//page[@id="water_sampling"]', 'states', {
'invisible': Not(Bool(
Equal(Eval('project_type'), 'water'))),
})]
}),
]
class CreateSampleStart(metaclass=PoolMeta):
@ -92,7 +94,8 @@ class CreateSampleStart(metaclass=PoolMeta):
('//page[@id="water_sampling"]', 'states', {
'invisible': Not(Bool(
Equal(Eval('project_type'), 'water'))),
})]
}),
]
class CreateSample(metaclass=PoolMeta):

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase

View File

@ -5,4 +5,3 @@ depends:
xml:
project.xml
message.xml

View File

@ -1,6 +1,7 @@
# This file is part of lims_quality_control module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields, ModelSingleton

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from datetime import datetime
from trytond.model import fields
from trytond.pyson import Eval, Equal
from trytond.transaction import Transaction
@ -23,11 +24,13 @@ class Configuration(metaclass=PoolMeta):
class Method(metaclass=PoolMeta):
__name__ = 'lims.lab.method'
specification = fields.Text('Specification')
class Analysis(metaclass=PoolMeta):
__name__ = 'lims.analysis'
quality_type = fields.Selection([
('qualitative', 'Qualitative'),
('quantitative', 'Quantitative'),
@ -91,7 +94,6 @@ class Typification(metaclass=PoolMeta):
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
table.drop_constraint('product_matrix_analysis_method_uniq')
@fields.depends('analysis')
@ -432,7 +434,6 @@ class EntryDetailAnalysis(metaclass=PoolMeta):
class ResultReport(metaclass=PoolMeta):
__name__ = 'lims.result_report'
@classmethod
def get_reference(cls, range_type, notebook_line, language,
report_section):
@ -469,6 +470,7 @@ class ResultReport(metaclass=PoolMeta):
class NotebookLoadResultsManualLine(metaclass=PoolMeta):
__name__ = 'lims.notebook.load_results_manual.line'
qualitative_value = fields.Many2One('lims.quality.qualitative.value',
'Qualitative Value',
domain=[

View File

@ -1,6 +1,7 @@
# This file is part of lims_quality_control module for 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

View File

@ -2,6 +2,7 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import datetime
from trytond.model import Workflow, ModelView, ModelSQL, DeactivableMixin, \
fields
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
@ -156,7 +157,6 @@ class Template(Workflow, ModelSQL, ModelView):
raise UserError(gettext(
'lims_quality_control.msg_missing_template_lines'))
@classmethod
@ModelView.button
@Workflow.transition('not_active')

View File

@ -3,6 +3,7 @@
# the full copyright notices and license terms.
from datetime import datetime
from dateutil.relativedelta import relativedelta
from trytond.model import fields, ModelView
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, \
Button
@ -16,12 +17,14 @@ from trytond.i18n import gettext
class LabWorkYear(metaclass=PoolMeta):
__name__ = 'lims.lab.workyear'
default_entry_quality = fields.Many2One('lims.entry',
'Default entry quality')
class Sample(metaclass=PoolMeta):
__name__ = 'lims.sample'
quality = fields.Boolean('Quality')
lot = fields.Many2One('stock.lot', 'Lot', readonly=True)
test_state = fields.Selection([

View File

@ -1,8 +1,9 @@
#!/usr/bin/env python
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
# This file is part of lims_quality_control module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import doctest_teardown

View File

@ -62,14 +62,14 @@ class ReportTemplate(ModelSQL, ModelView):
def view_attributes(cls):
return super().view_attributes() + [
('//page[@id="header_footer"]', 'states', {
'invisible': Eval('type') != 'base',
}),
'invisible': Eval('type') != 'base',
}),
('//page[@name="sections"]', 'states', {
'invisible': Eval('type') != 'base',
}),
'invisible': Eval('type') != 'base',
}),
('//page[@name="trend_charts"]', 'states', {
'invisible': Eval('type') != 'base',
}),
'invisible': Eval('type') != 'base',
}),
]
@classmethod

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="chart"/>
<field name="chart"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree sequence="order">
<field name="chart" expand="1"/>
</tree>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="name"/>
<field name="data" filename_visible="1"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree editable="bottom">
<field name="data"/>
<field name="name" expand="2"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="name"/>
<field name="name"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree>
<field name="name" expand="2"/>
<field name="type"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="name"/>
<field name="data" filename_visible="1"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree editable="bottom">
<field name="data"/>
<field name="name" expand="2"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="template"/>
<field name="template"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree editable="top">
<field name="template"/>
<field name="lang"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<form>
<label name="chart"/>
<field name="chart"/>

View File

@ -1,3 +1,4 @@
<?xml version="1.0"?>
<tree sequence="order">
<field name="chart" expand="1"/>
</tree>

View File

@ -511,22 +511,22 @@ class SaleLoadAnalysis(Wizard):
sale_id = Transaction().context['active_id']
def get_sale_services(analysis, sale_services={}):
if analysis.included_analysis:
for ia in analysis.included_analysis:
if not ia.included_analysis.product:
continue
if ia.included_analysis.id not in sale_services.keys():
if ia.included_analysis.type != 'set':
sale_services[ia.included_analysis.id] = {
'quantity': 1,
'unit':
ia.included_analysis.product.default_uom.id,
'product': ia.included_analysis.product.id,
'method': ia.method.id if ia.method else None,
'description': ia.included_analysis.rec_name,
}
sale_services = get_sale_services(
ia.included_analysis, sale_services)
if not analysis.included_analysis:
return sale_services
for ia in analysis.included_analysis:
included = ia.included_analysis
if not included.product:
continue
if included.id not in sale_services.keys():
if included.type != 'set':
sale_services[included.id] = {
'quantity': 1,
'unit': included.product.default_uom.id,
'product': included.product.id,
'method': ia.method.id if ia.method else None,
'description': included.rec_name,
}
sale_services = get_sale_services(included, sale_services)
return sale_services
sale_services = get_sale_services(self.start.analysis)

View File

@ -123,7 +123,8 @@ if __name__ == '__main__':
'Intended Audience :: Manufacturing',
'Intended Audience :: Science/Research',
'Intended Audience :: Other Audience',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'License :: OSI Approved :: '
'GNU General Public License v3 or later (GPLv3+)',
'Natural Language :: English',
'Natural Language :: Spanish',
'Operating System :: OS Independent',