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,95 @@
==============================
Sale Product Quantity 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('sale_product_quantity', create_company)
>>> Party = Model.get('party.party')
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Sale = Model.get('sale.sale')
Create parties::
>>> customer = Party(name="Customer")
>>> customer.save()
Create product::
>>> gr, = ProductUom.find([('name', '=', "Gram")])
>>> kg, = ProductUom.find([('name', '=', "Kilogram")])
>>> template = ProductTemplate()
>>> template.name = "Product"
>>> template.default_uom = gr
>>> template.type = 'goods'
>>> template.list_price = Decimal('10')
>>> template.salable = True
>>> template.sale_uom = kg
>>> template.sale_quantity_minimal = 0.1
>>> template.sale_quantity_rounding = 0.05
>>> template.save()
>>> product, = template.products
Make a sale::
>>> sale = Sale()
>>> sale.party = customer
>>> line = sale.lines.new()
>>> line.product = product
>>> line.quantity
0.1
>>> sale.save()
Can not set quantity below minimal::
>>> line, = sale.lines
>>> line.quantity = 0.05
>>> sale.save()
Traceback (most recent call last):
...
SaleValidationError: ...
Can not set quantity different than rounding::
>>> line, = sale.lines
>>> line.quantity = 1.01
>>> sale.save()
Traceback (most recent call last):
...
SaleValidationError: ...
Use different unit::
>>> line, = sale.lines
>>> line.unit = gr
>>> line.quantity = 500
>>> sale.save()
Can not set quantity below minimal::
>>> line, = sale.lines
>>> line.quantity = 50
>>> sale.save()
Traceback (most recent call last):
...
SaleValidationError: ...
Can not set quantity different than rounding::
>>> line, = sale.lines
>>> line.quantity = 505
>>> sale.save()
Traceback (most recent call last):
...
SaleValidationError: ...

View File

@@ -0,0 +1,93 @@
==================================
Sale Product Quantity POS 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(
... ['sale_product_quantity', 'sale_point'],
... create_company)
>>> Journal = Model.get('account.journal')
>>> Location = Model.get('stock.location')
>>> POS = Model.get('sale.point')
>>> Party = Model.get('party.party')
>>> ProductTemplate = Model.get('product.template')
>>> ProductUom = Model.get('product.uom')
>>> Sale = Model.get('sale.point.sale')
>>> SequenceStrict = Model.get('ir.sequence.strict')
>>> SequenceType = Model.get('ir.sequence.type')
Get journal::
>>> journal_revenue, = Journal.find([('type', '=', 'revenue')], limit=1)
Get stock locations::
>>> storage_loc, = Location.find([('code', '=', 'STO')])
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
Create POS::
>>> pos = POS(name="POS")
>>> pos.journal = journal_revenue
>>> pos.sequence = SequenceStrict(name="POS", company=pos.company)
>>> pos.sequence.sequence_type, = SequenceType.find(
... [('name', '=', "POS")], limit=1)
>>> pos.sequence.save()
>>> pos.storage_location = storage_loc
>>> pos.customer_location = customer_loc
>>> pos.save()
Create product::
>>> gr, = ProductUom.find([('name', '=', "Gram")])
>>> kg, = ProductUom.find([('name', '=', "Kilogram")])
>>> template = ProductTemplate()
>>> template.name = "Product"
>>> template.default_uom = gr
>>> template.type = 'goods'
>>> template.list_price = Decimal('10')
>>> template.salable = True
>>> template.sale_uom = kg
>>> template.sale_quantity_minimal = 0.1
>>> template.sale_quantity_rounding = 0.05
>>> template.save()
>>> product, = template.products
Make a sale::
>>> sale = Sale(point=pos)
>>> line = sale.lines.new()
>>> line.product = product
>>> line.quantity
0.1
>>> sale.save()
Can not set quantity below minimal::
>>> line, = sale.lines
>>> line.quantity = 0.05
>>> sale.save()
Traceback (most recent call last):
...
SaleValidationError: ...
Can not set quantity different than rounding::
>>> line, = sale.lines
>>> line.quantity = 1.01
>>> sale.save()
Traceback (most recent call last):
...
SaleValidationError: ...

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 SaleProductQuantityTestCase(ModuleTestCase):
'Test Sale Product Quantity module'
module = 'sale_product_quantity'
extras = ['sale_point']
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)