Deprecate stock_external_party.

This commit is contained in:
Albert Cervera i Areny 2021-10-24 16:21:06 +02:00
parent f3a8c38822
commit b2c468647e
7 changed files with 1 additions and 314 deletions

View File

@ -348,21 +348,4 @@
<field name="plan_field_name">products_cost</field>
</record>
</data>
<data depends="production_external_party">
<record model="ir.ui.view"
id="cost_plan_product_line_view_form_external_party">
<field name="model">product.cost.plan.product_line</field>
<field name="inherit"
ref="product_cost_plan.product_cost_plan_product_line_view_form"/>
<field name="name">cost_plan_product_line_form_external_party</field>
</record>
<record model="ir.ui.view"
id="cost_plan_product_line_view_tree_external_party">
<field name="model">product.cost.plan.product_line</field>
<field name="inherit"
ref="product_cost_plan.product_cost_plan_product_line_view_list"/>
<field name="name">cost_plan_product_line_tree_external_party</field>
</record>
</data>
</tryton>

View File

@ -10,7 +10,6 @@ from configparser import ConfigParser
MODULE = 'product_cost_plan'
PREFIX = 'nantic'
MODULE2PREFIX = {
'production_external_party': 'nantic',
}
@ -42,7 +41,7 @@ major_version = int(major_version)
minor_version = int(minor_version)
requires = []
for dep in info.get('depends', []) + ['production_external_party']:
for dep in info.get('depends', []):
if not re.match(r'(ir|res)(\W|$)', dep):
prefix = MODULE2PREFIX.get(dep, 'trytond')
requires.append(get_require_version('%s_%s' % (prefix, dep)))
@ -50,7 +49,6 @@ requires.append(get_require_version('trytond'))
tests_require = [
get_require_version('proteus'),
get_require_version('nantic-production_external_party')
]
series = '%s.%s' % (major_version, minor_version)
@ -60,12 +58,6 @@ else:
branch = series
dependency_links = [
('hg+https://bitbucket.org/nantic/'
'trytond-production_external_party@%(branch)s'
'#egg=nantic-production_external_party-%(series)s' % {
'branch': branch,
'series': series,
}),
]
if minor_version % 2:

View File

@ -1,262 +0,0 @@
========================================
Product Cost Plan Extras Depend Scenario
========================================
=============
General Setup
=============
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from proteus import config, Model, Wizard
>>> from trytond.tests.tools import activate_modules
>>> today = datetime.date.today()
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> today = datetime.date.today()
Install product_cost_plan Module::
>>> config = activate_modules(['product_cost_plan', 'production_external_party'])
Create company::
>>> _ = create_company()
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'BE0897290877'
>>> company.party.save()
Reload the context::
>>> User = Model.get('res.user')
>>> config._context = User.get_preferences(True, config.context)
Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(30)
>>> template.producible = True
>>> template.save()
>>> product, = template.products
>>> product.cost_price = Decimal(20)
>>> product.save()
>>> template = ProductTemplate()
>>> template.name = 'product 2'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(30)
>>> template.producible = True
>>> template.save()
>>> product2, = template.products
>>> template = ProductTemplate()
>>> template.name = 'product 3'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(15)
>>> template.producible = True
>>> template.save()
>>> product3, = template.products
Create Components::
>>> meter, = ProductUom.find([('name', '=', 'Meter')])
>>> centimeter, = ProductUom.find([('name', '=', 'centimeter')])
>>> template1 = ProductTemplate()
>>> template1.name = 'component 1'
>>> template1.default_uom = unit
>>> template1.type = 'goods'
>>> template1.list_price = Decimal(5)
>>> template1.may_belong_to_party = True
>>> template1.save()
>>> component1, = template1.products
>>> component1.cost_price = Decimal(2)
>>> component1.save()
>>> template2 = ProductTemplate()
>>> template2.name = 'component 2'
>>> template2.default_uom = meter
>>> template2.type = 'goods'
>>> template2.list_price = Decimal(7)
>>> template2.save()
>>> component2, = template2.products
>>> component2.cost_price = Decimal(5)
>>> component2.save()
Create Bill of Material with party stock for component 1::
>>> BOM = Model.get('production.bom')
>>> bom = BOM(name='product')
>>> input1 = bom.inputs.new()
>>> input1.product = component1
>>> input1.party_stock
1
>>> input1.quantity = 5
>>> input2 = bom.inputs.new()
>>> input2.product = component2
>>> input2.quantity = 150
>>> input2.uom = centimeter
>>> output = bom.outputs.new()
>>> output.product = product
>>> output.quantity = 1
>>> bom.save()
>>> ProductBom = Model.get('product.product-production.bom')
>>> product.boms.append(ProductBom(bom=bom))
>>> product.save()
Create a cost plan from BoM::
>>> CostPlan = Model.get('product.cost.plan')
>>> plan = CostPlan()
>>> plan.number = '1'
>>> plan.product = product
>>> plan.bom == bom
True
>>> plan.quantity = 1
>>> plan.save()
>>> plan.click('compute')
>>> plan.reload()
>>> len(plan.products)
2
>>> sorted([(p.quantity, p.product.rec_name, bool(p.party_stock), p.cost_price)
... for p in plan.products])
[(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
>>> cost.cost
Decimal('7.5000')
>>> plan.cost_price
Decimal('7.5000')
Duplicate cost plan and change plan's product::
>>> plan2_id, = CostPlan.copy([plan.id], config.context)
>>> plan2 = CostPlan(plan2_id)
>>> plan2.bom == None
True
>>> plan2.product = product2
>>> plan2.save()
>>> len(plan2.products)
2
Set party stock also for second component::
>>> for product_line in plan2.products:
... if product_line.product == component2:
... product_line.party_stock = True
>>> plan2.save()
>>> plan2.reload()
>>> sorted([(p.quantity, p.product.rec_name, bool(p.party_stock), p.cost_price)
... for p in plan2.products])
[(5.0, 'component 1', True, Decimal('0.0000')), (150.0, 'component 2', True, Decimal('0.0'))]
>>> plan2.cost_price == Decimal(0)
True
Create BoM from cost plan::
>>> create_bom = Wizard('product.cost.plan.create_bom', [plan2])
>>> create_bom.execute('bom')
>>> plan2.reload()
>>> product2.reload()
>>> product2.boms[0].bom == plan2.bom
True
>>> len(plan2.bom.inputs)
2
>>> sorted([(i.quantity, i.product.rec_name, bool(i.party_stock), i.uom.symbol)
... for i in plan2.bom.inputs])
[(5.0, 'component 1', True, 'u'), (150.0, 'component 2', True, 'cm')]
>>> len(plan2.bom.outputs)
1
>>> plan2.bom.outputs[0].product == product2
True
>>> plan2.bom.outputs[0].uom == plan2.uom
True
>>> plan2.bom.outputs[0].quantity == plan2.quantity
True
Create plan from scratch::
>>> plan3 = CostPlan()
>>> plan3.product = product3
>>> plan3.uom.symbol
'u'
>>> plan3.bom
>>> plan3.quantity = 2
>>> plan3.click('compute')
>>> plan3.reload()
>>> len(plan3.products)
0
>>> len(plan3.costs)
1
>>> product_line = plan3.products_tree.new()
>>> product_line.product = component1
>>> bool(product_line.party_stock)
True
>>> product_line.cost_price
Decimal('0.0')
>>> product_line.quantity = 14
>>> product_line.uom.symbol
'u'
>>> product_line2 = product_line.children.new()
>>> product_line2.plan = plan3
>>> product_line2.product = component2
>>> product_line2.cost_price
Decimal('5.0000')
>>> product_line2.quantity = 4
>>> product_line2.uom.symbol
'm'
>>> product_line2.uom = centimeter
>>> product_line2.cost_price
Decimal('0.0500')
>>> product_line2.cost_price = Decimal('0.0450')
>>> product_line2.uom.symbol
'cm'
>>> plan3.save()
>>> product_line, = plan3.products_tree
>>> product_line2, = product_line.children
>>> product_line2.unit_cost
Decimal('1.2600')
>>> product_line2.total_cost
Decimal('2.5200')
>>> cost, = plan3.costs
>>> cost.rec_name == 'Raw materials'
True
>>> cost.cost
Decimal('1.2600')
>>> plan3.cost_price
Decimal('1.2600')
Create BoM from Cost Plan::
>>> create_bom = Wizard('product.cost.plan.create_bom', [plan3])
>>> create_bom.execute('bom')
>>> plan3.reload()
>>> product3.reload()
>>> plan3.bom == product3.boms[0].bom
True
>>> len(plan3.bom.inputs)
2
>>> sorted([(i.quantity, i.product.rec_name, bool(i.party_stock), i.uom.symbol)
... for i in plan3.bom.inputs])
[(14.0, 'component 1', True, 'u'), (56.0, 'component 2', False, 'cm')]
>>> len(plan3.bom.outputs)
1
>>> plan3.bom.outputs[0].product == product3
True
>>> plan3.bom.outputs[0].quantity
2.0

View File

@ -22,9 +22,4 @@ def suite():
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
suite.addTests(
doctest.DocFileSuite('scenario_product_cost_plan_extras_depend.rst',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite

View File

@ -1,10 +1,7 @@
[tryton]
version=6.1.0
depends:
production
extras_depend:
production_external_party
xml:
plan.xml
configuration.xml

View File

@ -1,10 +0,0 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='uom']" position="after">
<label name="party_stock"/>
<field name="party_stock"/>
<newline/>
</xpath>
</data>

View File

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='uom']" position="after">
<field name="party_stock"/>
</xpath>
</data>