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,52 @@
=========================
Production Split 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
Activate modules::
>>> config = activate_modules('production_split', create_company)
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Production = Model.get('production')
Create product::
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.producible = True
>>> template.list_price = Decimal(20)
>>> template.save()
>>> product, = template.products
Create a production::
>>> production = Production()
>>> production.product = product
>>> production.quantity = 10
>>> production.save()
Split the production::
>>> split_production = production.click('split_wizard')
>>> split_production.form.quantity = 4
>>> split_production.form.count = 1
>>> split_production.execute('split')
>>> production2, = Production.find([('id', '!=', production.id)])
>>> production.quantity
4.0
>>> production2.quantity
6.0

View File

@@ -0,0 +1,45 @@
# 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 unittest.mock import patch
from trytond.pool import Pool
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
class ProductionSplitTestCase(ModuleTestCase):
'Test Production Split module'
module = 'production_split'
@with_transaction()
def test_split(self):
'Test split'
pool = Pool()
Uom = pool.get('product.uom')
Production = pool.get('production')
unit, = Uom.search([('name', '=', 'Unit')])
with patch.object(Production, 'save'), \
patch.object(Production, 'explode_bom'), \
patch.object(Production, 'copy') as copy:
copy.side_effect = lambda l, values: [
Production(**values) for r in l]
for quantity, quantity_split, count, quantities in [
(10, 5, None, [5, 5]),
(13, 5, None, [5, 5, 3]),
(7, 8, None, [7]),
(20, 5, 2, [5, 5, 10]),
(20, 5, 4, [5, 5, 5, 5]),
]:
production = Production()
production.quantity = quantity
production.unit = unit
productions = production.split(
quantity_split, unit, count=count)
self.assertEqual(
[p.quantity for p in productions], quantities)
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)