first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,152 @@
===============================
Sale Supply Production Scenario
===============================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules, assertEqual
Activate modules::
>>> config = activate_modules(
... 'sale_supply_production', create_company, create_chart)
Get accounts::
>>> accounts = get_accounts()
Create parties::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_revenue = accounts['revenue']
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> template = ProductTemplate()
>>> template.name = "Product"
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.producible = True
>>> template.salable = True
>>> template.supply_on_sale = 'always'
>>> template.list_price = Decimal(30)
>>> template.account_category = account_category
>>> product, = template.products
>>> product.cost_price = Decimal(20)
>>> template.save()
>>> product, = template.products
Create components::
>>> template = ProductTemplate()
>>> template.name = "Component 1"
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal(5)
>>> component, = template.products
>>> component.cost_price = Decimal(1)
>>> template.save()
>>> component, = template.products
Create bill of material::
>>> BOM = Model.get('production.bom')
>>> bom = BOM(name="Product")
>>> input = bom.inputs.new()
>>> input.product = component
>>> input.quantity = 5
>>> output = bom.outputs.new()
>>> output.product = product
>>> output.quantity = 1
>>> bom.save()
>>> product_bom = product.boms.new()
>>> product_bom.bom = bom
>>> product.save()
Sale 10 products::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> line = sale.lines.new()
>>> line.product = product
>>> line.quantity = 10
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'processing'
>>> shipment, = sale.shipments
>>> move, = shipment.outgoing_moves
>>> move.state
'staging'
>>> move, = shipment.inventory_moves
>>> move.state
'staging'
Check the production::
>>> Production = Model.get('production')
>>> production, = Production.find([])
>>> production.state
'request'
>>> assertEqual(production.origin, sale.lines[0])
>>> assertEqual(production.product, product)
>>> assertEqual(production.bom, bom)
>>> production.quantity
10.0
Delete the production, recreate one::
>>> production.delete()
>>> production, = Production.find([])
>>> production.quantity
10.0
Start the production::
>>> production.click('draft')
>>> production.click('wait')
>>> production.click('assign_force')
>>> production.click('run')
>>> production.state
'running'
>>> shipment.reload()
>>> move, = shipment.outgoing_moves
>>> move.state
'draft'
>>> move, = shipment.inventory_moves
>>> move.state
'draft'
Finish the production::
>>> production.click('do')
>>> shipment.reload()
>>> move, = shipment.outgoing_moves
>>> move.state
'draft'
>>> move, = shipment.inventory_moves
>>> move.state
'assigned'

View File

@@ -0,0 +1,82 @@
=======================================
Sale Supply Production Routing Scenario
=======================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules, assertEqual
Activate modules::
>>> config = activate_modules(
... ['sale_supply_production', 'production_routing'],
... create_company)
>>> BoM = Model.get('production.bom')
>>> Party = Model.get('party.party')
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Production = Model.get('production')
>>> Routing = Model.get('production.routing')
>>> Sale = Model.get('sale.sale')
Create parties::
>>> Party = Model.get('party.party')
>>> customer = Party(name="Customer")
>>> customer.save()
Create product::
>>> unit, = ProductUom.find([('name', '=', "Unit")])
>>> template = ProductTemplate()
>>> template.name = "Product"
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.producible = True
>>> template.salable = True
>>> template.supply_on_sale = 'always'
>>> template.list_price = Decimal(30)
>>> product, = template.products
>>> product.cost_price = Decimal(20)
>>> template.save()
>>> product, = template.products
Create a Bill of Material with routing::
>>> bom = BoM(name="product")
>>> _ = bom.outputs.new(product=product, quantity=1)
>>> bom.save()
>>> routing = Routing(name="product")
>>> routing.boms.append(BoM(bom.id))
>>> routing.save()
>>> _ = product.boms.new(bom=bom, routing=routing)
>>> product.save()
Sale 10 products::
>>> sale = Sale()
>>> sale.party = customer
>>> sale.invoice_method = 'manual'
>>> line = sale.lines.new()
>>> line.product = product
>>> line.quantity = 10
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'processing'
Check the production::
>>> production, = Production.find([])
>>> production.state
'request'
>>> assertEqual(production.product, product)
>>> assertEqual(production.bom, bom)
>>> assertEqual(production.routing, routing)

View File

@@ -0,0 +1,106 @@
===========================================
Sale Supply Production Stock First Scenario
===========================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... 'sale_supply_production', create_company, create_chart)
>>> Inventory = Model.get('stock.inventory')
>>> Location = Model.get('stock.location')
>>> Party = Model.get('party.party')
>>> ProductCategory = Model.get('product.category')
>>> ProductTemplate = Model.get('product.template')
>>> Sale = Model.get('sale.sale')
>>> UoM = Model.get('product.uom')
Get accounts::
>>> accounts = get_accounts()
Create parties::
>>> customer = Party(name='Customer')
>>> customer.save()
Create account category::
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_revenue = accounts['revenue']
>>> account_category.save()
Create product::
>>> unit, = UoM.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = "Product"
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.producible = True
>>> template.salable = True
>>> template.supply_on_sale = 'stock_first'
>>> template.list_price = Decimal(30)
>>> template.account_category = account_category
>>> product, = template.products
>>> product.cost_price = Decimal(20)
>>> template.save()
>>> product, = template.products
Fill warehouse::
>>> inventory = Inventory()
>>> inventory.location, = Location.find([('code', '=', 'STO')])
>>> line = inventory.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> inventory.click('confirm')
>>> inventory.state
'done'
Sale 3 products without production request::
>>> sale = Sale()
>>> sale.party = customer
>>> line = sale.lines.new()
>>> line.product = product
>>> line.quantity = 3
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'processing'
>>> line, = sale.lines
>>> len(line.productions)
0
>>> move, = line.moves
>>> move.state
'draft'
Sale 4 products with production request::
>>> sale = Sale()
>>> sale.party = customer
>>> line = sale.lines.new()
>>> line.product = product
>>> line.quantity = 4
>>> sale.click('quote')
>>> sale.click('confirm')
>>> sale.state
'processing'
>>> line, = sale.lines
>>> len(line.productions)
1
>>> move, = line.moves
>>> move.state
'staging'

View File

@@ -0,0 +1,13 @@
# 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.tests.test_tryton import ModuleTestCase
class SaleSupplyProductionTestCase(ModuleTestCase):
'Test Sale Supply Production module'
module = 'sale_supply_production'
extras = ['production_routing']
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# 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.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)