mirror of
https://bitbucket.org/presik/trytonpsk-purchase_discount.git
synced 2023-12-14 05:03:01 +01:00
new version
This commit is contained in:
parent
08cffa79ae
commit
f93429db61
22
purchase.py
22
purchase.py
|
@ -12,7 +12,7 @@ from trytond.config import config as config_
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
__all__ = ['PurchaseLine', 'PurchaseDiscountReport', 'Configuration',
|
__all__ = ['PurchaseLine', 'PurchaseDiscountReport', 'Configuration',
|
||||||
'PurchaseDiscountWizardStart', 'PurchaseDiscountWizard']
|
'PurchaseDiscountWizardStart', 'PurchaseDiscountWizard']
|
||||||
|
|
||||||
STATES = {
|
STATES = {
|
||||||
'invisible': Eval('type') != 'line',
|
'invisible': Eval('type') != 'line',
|
||||||
|
@ -22,14 +22,12 @@ DIGITS = config_.getint('product', 'price_decimal', default=4)
|
||||||
DISCOUNT_DIGITS = 6
|
DISCOUNT_DIGITS = 6
|
||||||
|
|
||||||
|
|
||||||
class Configuration:
|
class Configuration(metaclass=PoolMeta):
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
__name__ = 'purchase.configuration'
|
__name__ = 'purchase.configuration'
|
||||||
description = fields.Char('Default Description')
|
description = fields.Char('Default Description')
|
||||||
|
|
||||||
|
|
||||||
class Purchase:
|
class Purchase(metaclass=PoolMeta):
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
__name__ = 'purchase.purchase'
|
__name__ = 'purchase.purchase'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -39,8 +37,7 @@ class Purchase:
|
||||||
return config.description
|
return config.description
|
||||||
|
|
||||||
|
|
||||||
class PurchaseLine:
|
class PurchaseLine(metaclass=PoolMeta):
|
||||||
__metaclass__ = PoolMeta
|
|
||||||
__name__ = 'purchase.line'
|
__name__ = 'purchase.line'
|
||||||
|
|
||||||
gross_unit_price = fields.Numeric('Gross Price', digits=(16, DIGITS),
|
gross_unit_price = fields.Numeric('Gross Price', digits=(16, DIGITS),
|
||||||
|
@ -51,7 +48,7 @@ class PurchaseLine:
|
||||||
stock_quantity = fields.Function(fields.Float('Stock Quantity',
|
stock_quantity = fields.Function(fields.Float('Stock Quantity',
|
||||||
digits=(16, 2), depends=['product'], states=STATES),
|
digits=(16, 2), depends=['product'], states=STATES),
|
||||||
'on_change_with_stock_quantity')
|
'on_change_with_stock_quantity')
|
||||||
product_description = fields.Text('Application')
|
# product_description = fields.Text('Application')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
@ -99,13 +96,13 @@ class PurchaseLine:
|
||||||
def on_change_discount(self):
|
def on_change_discount(self):
|
||||||
return self.update_prices()
|
return self.update_prices()
|
||||||
|
|
||||||
@fields.depends('unit_price', 'discount', 'stock_quantity', 'product_description')
|
@fields.depends('unit_price', 'discount', 'stock_quantity')
|
||||||
def on_change_product(self):
|
def on_change_product(self):
|
||||||
super(PurchaseLine, self).on_change_product()
|
super(PurchaseLine, self).on_change_product()
|
||||||
self.gross_unit_price = self.unit_price
|
self.gross_unit_price = self.unit_price
|
||||||
self.discount = Decimal(0)
|
self.discount = Decimal(0)
|
||||||
if self.product and self.product.description:
|
# if self.product and self.product.description:
|
||||||
self.product_description = self.product.description
|
# self.product_description = self.product.description
|
||||||
if self.unit_price:
|
if self.unit_price:
|
||||||
self.update_prices()
|
self.update_prices()
|
||||||
|
|
||||||
|
@ -141,9 +138,6 @@ class PurchaseLine:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line.gross_unit_price = self.gross_unit_price
|
line.gross_unit_price = self.gross_unit_price
|
||||||
line.discount = self.discount
|
line.discount = self.discount
|
||||||
# if self.product_description and self.product:
|
|
||||||
# self.product.description = self.product_description
|
|
||||||
# self.product.save()
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=5.0.0
|
version=5.0.1
|
||||||
depends:
|
depends:
|
||||||
product
|
product
|
||||||
purchase
|
purchase
|
||||||
|
|
|
@ -13,7 +13,7 @@ copyright notices and license terms. -->
|
||||||
</group>
|
</group>
|
||||||
<label name="stock_quantity"/>
|
<label name="stock_quantity"/>
|
||||||
<field name="stock_quantity"/>
|
<field name="stock_quantity"/>
|
||||||
<separator name="product_description" colspan="4"/>
|
<!-- <separator name="product_description" colspan="4"/>
|
||||||
<field name="product_description" colspan="4"/>
|
<field name="product_description" colspan="4"/> -->
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -8,6 +8,6 @@ copyright notices and license terms. -->
|
||||||
<suffix name="discount" string="%"/>
|
<suffix name="discount" string="%"/>
|
||||||
</field>
|
</field>
|
||||||
<!-- <field name="stock_quantity"/>-->
|
<!-- <field name="stock_quantity"/>-->
|
||||||
<field name="product_description"/>
|
<!-- <field name="product_description"/> -->
|
||||||
</xpath>
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
|
Loading…
Reference in a new issue