Migrate to python 3.
This commit is contained in:
parent
1983132d05
commit
98e6ca9157
|
@ -9,9 +9,8 @@ from trytond.modules.company.model import (
|
|||
__all__ = ['Configuration', 'ConfigurationProductcostPlan']
|
||||
|
||||
|
||||
class Configuration(CompanyMultiValueMixin):
|
||||
class Configuration(CompanyMultiValueMixin, metaclass=PoolMeta):
|
||||
__name__ = 'production.configuration'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
product_cost_plan_sequence = fields.MultiValue(
|
||||
fields.Many2One('ir.sequence',
|
||||
|
|
8
plan.py
8
plan.py
|
@ -3,7 +3,7 @@
|
|||
from decimal import Decimal
|
||||
|
||||
from trytond.config import config
|
||||
from trytond.model import ModelSQL, ModelView, fields
|
||||
from trytond.model import ModelSQL, ModelView, fields, tree
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, Bool, If
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -413,7 +413,7 @@ class Plan(ModelSQL, ModelView):
|
|||
existing = inputs[input_.product.id]
|
||||
existing.quantity += Uom.compute_qty(input_.uom, input_.quantity,
|
||||
existing.uom)
|
||||
return inputs.values()
|
||||
return list(inputs.values())
|
||||
|
||||
def _get_input_line(self, line):
|
||||
'Return the BOM Input line for a product line'
|
||||
|
@ -439,7 +439,7 @@ class Plan(ModelSQL, ModelView):
|
|||
config = Config(1)
|
||||
for values in vlist:
|
||||
values['number'] = Sequence.get_id(
|
||||
config.product_cost_plan.sequence and
|
||||
config.product_cost_plan_sequence and
|
||||
config.product_cost_plan_sequence.id)
|
||||
return super(Plan, cls).create(vlist)
|
||||
|
||||
|
@ -491,7 +491,7 @@ class PlanBOM(ModelSQL, ModelView):
|
|||
], depends=['product'])
|
||||
|
||||
|
||||
class PlanProductLine(ModelSQL, ModelView):
|
||||
class PlanProductLine(ModelSQL, ModelView, tree(separator='/')):
|
||||
'Product Cost Plan Product Line'
|
||||
__name__ = 'product.cost.plan.product_line'
|
||||
|
||||
|
|
5
setup.py
5
setup.py
|
@ -5,10 +5,7 @@ from setuptools import setup
|
|||
import re
|
||||
import os
|
||||
import io
|
||||
try:
|
||||
from configparser import ConfigParser
|
||||
except ImportError:
|
||||
from ConfigParser import ConfigParser
|
||||
from configparser import ConfigParser
|
||||
|
||||
MODULE = 'product_cost_plan'
|
||||
PREFIX = 'nantic'
|
||||
|
|
|
@ -249,7 +249,7 @@ Create BoM from cost plan::
|
|||
2
|
||||
>>> sorted([(i.quantity, i.product.rec_name, i.uom.symbol)
|
||||
... for i in plan2.bom.inputs])
|
||||
[(5.0, u'component 1', u'u'), (150.0, u'component 2', u'cm')]
|
||||
[(5.0, 'component 1', 'u'), (150.0, 'component 2', 'cm')]
|
||||
>>> len(plan2.bom.outputs)
|
||||
1
|
||||
>>> plan2.bom.outputs[0].product == product2
|
||||
|
@ -264,7 +264,7 @@ Create plan from scratch::
|
|||
>>> plan3 = CostPlan()
|
||||
>>> plan3.product = product3
|
||||
>>> plan3.uom.symbol
|
||||
u'u'
|
||||
'u'
|
||||
>>> plan3.bom
|
||||
>>> plan3.quantity = 2
|
||||
>>> plan3.click('compute')
|
||||
|
@ -279,7 +279,7 @@ Create plan from scratch::
|
|||
Decimal('2.0000')
|
||||
>>> product_line.quantity = 14
|
||||
>>> product_line.uom.symbol
|
||||
u'u'
|
||||
'u'
|
||||
>>> product_line2 = product_line.children.new()
|
||||
>>> product_line2.plan = plan3
|
||||
>>> product_line2.product = component2
|
||||
|
@ -287,13 +287,13 @@ Create plan from scratch::
|
|||
Decimal('5.0000')
|
||||
>>> product_line2.quantity = 4
|
||||
>>> product_line2.uom.symbol
|
||||
u'm'
|
||||
'm'
|
||||
>>> product_line2.uom = centimeter
|
||||
>>> product_line2.cost_price
|
||||
Decimal('0.0500')
|
||||
>>> product_line2.cost_price = Decimal('0.0450')
|
||||
>>> product_line2.uom.symbol
|
||||
u'cm'
|
||||
'cm'
|
||||
>>> plan3.save()
|
||||
>>> product_line, = plan3.products_tree
|
||||
>>> product_line.unit_cost
|
||||
|
@ -325,7 +325,7 @@ Create BoM from Cost Plan::
|
|||
2
|
||||
>>> sorted([(i.quantity, i.product.rec_name, i.uom.symbol)
|
||||
... for i in plan3.bom.inputs])
|
||||
[(14.0, u'component 1', u'u'), (56.0, u'component 2', u'cm')]
|
||||
[(14.0, 'component 1', 'u'), (56.0, 'component 2', 'cm')]
|
||||
>>> len(plan3.bom.outputs)
|
||||
1
|
||||
>>> plan3.bom.outputs[0].product == product3
|
||||
|
|
|
@ -134,7 +134,7 @@ Create a cost plan from BoM::
|
|||
2
|
||||
>>> sorted([(p.quantity, p.product.rec_name, bool(p.party_stock), p.cost_price)
|
||||
... for p in plan.products])
|
||||
[(5.0, u'component 1', True, Decimal('0.0000')), (150.0, u'component 2', False, Decimal('0.0500'))]
|
||||
[(5.0, 'component 1', True, Decimal('0.0000')), (150.0, 'component 2', False, Decimal('0.0500'))]
|
||||
>>> cost, = plan.costs
|
||||
>>> cost.rec_name == 'Raw materials'
|
||||
True
|
||||
|
@ -163,7 +163,7 @@ Set party stock also for second component::
|
|||
>>> plan2.reload()
|
||||
>>> sorted([(p.quantity, p.product.rec_name, bool(p.party_stock), p.cost_price)
|
||||
... for p in plan2.products])
|
||||
[(5.0, u'component 1', True, Decimal('0.0000')), (150.0, u'component 2', True, Decimal('0.0'))]
|
||||
[(5.0, 'component 1', True, Decimal('0.0000')), (150.0, 'component 2', True, Decimal('0.0'))]
|
||||
>>> plan2.cost_price
|
||||
0
|
||||
|
||||
|
@ -179,7 +179,7 @@ Create BoM from cost plan::
|
|||
2
|
||||
>>> sorted([(i.quantity, i.product.rec_name, bool(i.party_stock), i.uom.symbol)
|
||||
... for i in plan2.bom.inputs])
|
||||
[(5.0, u'component 1', True, u'u'), (150.0, u'component 2', True, u'cm')]
|
||||
[(5.0, 'component 1', True, 'u'), (150.0, 'component 2', True, 'cm')]
|
||||
>>> len(plan2.bom.outputs)
|
||||
1
|
||||
>>> plan2.bom.outputs[0].product == product2
|
||||
|
@ -194,7 +194,7 @@ Create plan from scratch::
|
|||
>>> plan3 = CostPlan()
|
||||
>>> plan3.product = product3
|
||||
>>> plan3.uom.symbol
|
||||
u'u'
|
||||
'u'
|
||||
>>> plan3.bom
|
||||
>>> plan3.quantity = 2
|
||||
>>> plan3.click('compute')
|
||||
|
@ -211,7 +211,7 @@ Create plan from scratch::
|
|||
Decimal('0.0')
|
||||
>>> product_line.quantity = 14
|
||||
>>> product_line.uom.symbol
|
||||
u'u'
|
||||
'u'
|
||||
>>> product_line2 = product_line.children.new()
|
||||
>>> product_line2.plan = plan3
|
||||
>>> product_line2.product = component2
|
||||
|
@ -219,13 +219,13 @@ Create plan from scratch::
|
|||
Decimal('5.0000')
|
||||
>>> product_line2.quantity = 4
|
||||
>>> product_line2.uom.symbol
|
||||
u'm'
|
||||
'm'
|
||||
>>> product_line2.uom = centimeter
|
||||
>>> product_line2.cost_price
|
||||
Decimal('0.0500')
|
||||
>>> product_line2.cost_price = Decimal('0.0450')
|
||||
>>> product_line2.uom.symbol
|
||||
u'cm'
|
||||
'cm'
|
||||
>>> plan3.save()
|
||||
>>> product_line, = plan3.products_tree
|
||||
>>> product_line2, = product_line.children
|
||||
|
@ -253,7 +253,7 @@ Create BoM from Cost Plan::
|
|||
2
|
||||
>>> sorted([(i.quantity, i.product.rec_name, bool(i.party_stock), i.uom.symbol)
|
||||
... for i in plan3.bom.inputs])
|
||||
[(14.0, u'component 1', True, u'u'), (56.0, u'component 2', False, u'cm')]
|
||||
[(14.0, 'component 1', True, 'u'), (56.0, 'component 2', False, 'cm')]
|
||||
>>> len(plan3.bom.outputs)
|
||||
1
|
||||
>>> plan3.bom.outputs[0].product == product3
|
||||
|
|
Loading…
Reference in New Issue