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 @@
===================================
Sale Copy Product Customer 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_product_customer', create_company)
Create party::
>>> Party = Model.get('party.party')
>>> customer = Party(name='customer')
>>> customer.save()
Create a product with customers::
>>> 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.salable = True
>>> template.list_price = Decimal('10')
>>> template.cost_price_method = 'fixed'
>>> product_customer = template.product_customers.new()
>>> product_customer.party = customer
>>> template.save()
>>> product, = template.products
>>> product_customer = product.product_customers.new()
>>> product_customer.party = customer
>>> assertEqual(product_customer.template, template)
>>> product.save()
Customer is copied when copying the template::
>>> template_copy, = template.duplicate()
>>> product_copy, = template_copy.products
>>> len(template_copy.product_customers)
2
>>> len(product_copy.product_customers)
1

View File

@@ -0,0 +1,68 @@
==============================
Sale Product Customer 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_customer', create_company)
Create parties::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.save()
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.salable = True
>>> template.list_price = Decimal('10')
>>> template.save()
>>> product, = template.products
>>> product_customer = product.product_customers.new()
>>> product_customer.party = customer
>>> product_customer.code = 'CUST'
>>> product.save()
Create sale::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = customer
>>> line = sale.lines.new()
Check filling product customer::
>>> line.product = product
>>> line.product_customer.code
'CUST'
Add product customer to the template::
>>> product_customer2 = template.product_customers.new()
>>> product_customer2.party = customer
>>> product_customer2.code = 'TEMPCUST'
>>> template.save()
Count product linked to customer::
>>> ProductCustomer = Model.get('sale.product_customer')
>>> products = ProductCustomer.find(
... [('party', '=', customer.id)])
>>> len(products)
2

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 SaleProductCustomerTestCase(ModuleTestCase):
'Test Sale Product Customer module'
module = 'sale_product_customer'
extras = ['sale_amendment', 'sale_blanket_agreement']
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)