Remove _inherits

review670002
This commit is contained in:
Cédric Krier committed 2013-03-20 22:51:12 +01:00
1 parent 8e1124ef5b
commit 65cfc60c14
5 files changed
+56 -28

No files matched your search

+4 -2
View File
@@ -1,7 +1,7 @@
#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 decimal import Decimal
from functools import reduce
from functools import reduce, partial
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.backend import TableHandler
from trytond.pyson import In, Eval, Not, Equal, If, Get, Bool
@@ -385,13 +385,15 @@ class Move(Workflow, ModelSQL, ModelView):
if hasattr(Product, 'cost_price'):
digits = Product.cost_price.digits
write = partial(Product.write, [product])
else:
digits = ProductTemplate.cost_price.digits
write = partial(ProductTemplate.write, [product.template])
new_cost_price = new_cost_price.quantize(
Decimal(str(10.0 ** -digits[1])))
with Transaction().set_user(0, set_context=True):
Product.write([product], {
write({
'cost_price': new_cost_price,
})
+16 -9
View File
@@ -31,10 +31,13 @@ Create company::
>>> Currency = Model.get('currency.currency')
>>> CurrencyRate = Model.get('currency.currency.rate')
>>> Company = Model.get('company.company')
>>> Party = Model.get('party.party')
>>> company_config = Wizard('company.company.config')
>>> company_config.execute('company')
>>> company = company_config.form
>>> company.name = 'Dunder Mifflin'
>>> party = Party(name='Dunder Mifflin')
>>> party.save()
>>> company.party = party
>>> currencies = Currency.find([('code', '=', 'USD')])
>>> if not currencies:
... currency = Currency(name='US Dollar', symbol='$', code='USD',
@@ -57,15 +60,19 @@ Reload the context::
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> product = Product()
>>> product.name = 'Product'
>>> product.default_uom = unit
>>> product.type = 'goods'
>>> product.list_price = Decimal('300')
>>> product.cost_price = Decimal('80')
>>> product.cost_price_method = 'average'
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal('300')
>>> template.cost_price = Decimal('80')
>>> template.cost_price_method = 'average'
>>> template.save()
>>> product.template = template
>>> product.save()
Get stock locations::
@@ -94,7 +101,7 @@ Make 1 unit of the product available @ 100 ::
Check Cost Price is 100::
>>> product.reload()
>>> product.cost_price == Decimal('100')
>>> product.template.cost_price == Decimal('100')
True
Add 1 more unit @ 200::
@@ -116,5 +123,5 @@ Add 1 more unit @ 200::
Check Cost Price Average is 150::
>>> product.reload()
>>> product.cost_price == Decimal('150')
>>> product.template.cost_price == Decimal('150')
True
+14 -7
View File
@@ -31,10 +31,13 @@ Create company::
>>> Currency = Model.get('currency.currency')
>>> CurrencyRate = Model.get('currency.currency.rate')
>>> Company = Model.get('company.company')
>>> Party = Model.get('party.party')
>>> company_config = Wizard('company.company.config')
>>> company_config.execute('company')
>>> company = company_config.form
>>> company.name = 'OPENLABS'
>>> party = Party(name='OPENLABS')
>>> party.save()
>>> company.party = party
>>> currencies = Currency.find([('code', '=', 'EUR')])
>>> if not currencies:
... currency = Currency(name='Euro', symbol=u'€', code='EUR',
@@ -69,15 +72,19 @@ Create category::
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> product = Product()
>>> product.name = 'Product'
>>> product.category = category
>>> product.default_uom = unit
>>> product.type = 'goods'
>>> product.list_price = Decimal('20')
>>> product.cost_price = Decimal('8')
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.category = category
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal('20')
>>> template.cost_price = Decimal('8')
>>> template.save()
>>> product.template = template
>>> product.save()
Get stock locations::
+21 -8
View File
@@ -29,6 +29,7 @@ class StockTestCase(unittest.TestCase):
def setUp(self):
trytond.tests.test_tryton.install_module('stock')
self.template = POOL.get('product.template')
self.product = POOL.get('product.product')
self.category = POOL.get('product.category')
self.uom = POOL.get('product.uom')
@@ -61,7 +62,7 @@ class StockTestCase(unittest.TestCase):
}])
kg, = self.uom.search([('name', '=', 'Kilogram')])
g, = self.uom.search([('name', '=', 'Gram')])
product, = self.product.create([{
template, = self.template.create([{
'name': 'Test Move.internal_quantity',
'type': 'goods',
'list_price': Decimal(1),
@@ -70,9 +71,12 @@ class StockTestCase(unittest.TestCase):
'cost_price_method': 'fixed',
'default_uom': kg.id,
}])
product, = self.product.create([{
'template': template.id,
}])
supplier, = self.location.search([('code', '=', 'SUP')])
storage, = self.location.search([('code', '=', 'STO')])
company, = self.company.search([('name', '=', 'B2CK')])
company, = self.company.search([('rec_name', '=', 'B2CK')])
currency = company.currency
self.user.write([self.user(USER)], {
'main_company': company.id,
@@ -115,7 +119,7 @@ class StockTestCase(unittest.TestCase):
}])
kg, = self.uom.search([('name', '=', 'Kilogram')])
g, = self.uom.search([('name', '=', 'Gram')])
product, = self.product.create([{
template, = self.template.create([{
'name': 'Test products_by_location',
'type': 'goods',
'list_price': Decimal(0),
@@ -124,10 +128,13 @@ class StockTestCase(unittest.TestCase):
'cost_price_method': 'fixed',
'default_uom': kg.id,
}])
product, = self.product.create([{
'template': template.id,
}])
supplier, = self.location.search([('code', '=', 'SUP')])
customer, = self.location.search([('code', '=', 'CUS')])
storage, = self.location.search([('code', '=', 'STO')])
company, = self.company.search([('name', '=', 'B2CK')])
company, = self.company.search([('rec_name', '=', 'B2CK')])
currency = company.currency
self.user.write([self.user(USER)], {
'main_company': company.id,
@@ -311,14 +318,14 @@ class StockTestCase(unittest.TestCase):
# Test with_childs
with Transaction().start(DB_NAME, USER,
context=CONTEXT) as transaction:
company, = self.company.search([('name', '=', 'B2CK')])
company, = self.company.search([('rec_name', '=', 'B2CK')])
self.user.write([self.user(USER)], {
'main_company': company.id,
'company': company.id,
})
unit, = self.uom.search([('name', '=', 'Unit')])
product, = self.product.create([{
template, = self.template.create([{
'name': 'Test products_by_location',
'type': 'goods',
'list_price': Decimal(0),
@@ -326,6 +333,9 @@ class StockTestCase(unittest.TestCase):
'cost_price_method': 'fixed',
'default_uom': unit.id,
}])
product, = self.product.create([{
'template': template.id,
}])
lost_found, = self.location.search([('type', '=', 'lost_found')])
warehouse, = self.location.search([('type', '=', 'warehouse')])
@@ -372,7 +382,7 @@ class StockTestCase(unittest.TestCase):
'name': 'Test period',
}])
unit, = self.uom.search([('name', '=', 'Unit')])
product, = self.product.create([{
template, = self.template.create([{
'name': 'Test period',
'type': 'goods',
'category': category.id,
@@ -381,10 +391,13 @@ class StockTestCase(unittest.TestCase):
'list_price': Decimal(0),
'cost_price': Decimal(0),
}])
product, = self.product.create([{
'template': template.id,
}])
supplier, = self.location.search([('code', '=', 'SUP')])
customer, = self.location.search([('code', '=', 'CUS')])
storage, = self.location.search([('code', '=', 'STO')])
company, = self.company.search([('name', '=', 'B2CK')])
company, = self.company.search([('rec_name', '=', 'B2CK')])
currency = company.currency
self.user.write([self.user(USER)], {
'main_company': company.id,
+1 -2
View File
@@ -2,12 +2,11 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree string="Products">
<field name="name"/>
<field name="template"/>
<field name="code"/>
<field name="quantity"/>
<field name="cost_value"/>
<field name="forecast_quantity"/>
<field name="default_uom"/>
<field name="type"/>
<field name="active"/>
</tree>