parent
ece635f891
commit
47563cf6b9
18
product.py
18
product.py
|
@ -5,10 +5,6 @@ from trytond.pool import PoolMeta, Pool
|
||||||
from trytond.pyson import Eval, Bool, Id
|
from trytond.pyson import Eval, Bool, Id
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from trytond.wizard import (Wizard, StateAction, StateView, StateTransition,
|
|
||||||
Button)
|
|
||||||
from trytond.exceptions import UserWarning
|
|
||||||
from trytond.modules.product.product import STATES, DEPENDS
|
|
||||||
|
|
||||||
__all__ = ['Template', 'Product', 'TemplateProductPackaging',
|
__all__ = ['Template', 'Product', 'TemplateProductPackaging',
|
||||||
'ExtraProductPackaging']
|
'ExtraProductPackaging']
|
||||||
|
@ -50,7 +46,6 @@ class ExtraProductPackaging(ModelSQL, ModelView):
|
||||||
digits=(16, Eval('unit_digits', 2)),
|
digits=(16, Eval('unit_digits', 2)),
|
||||||
depends=['unit_digits'])
|
depends=['unit_digits'])
|
||||||
|
|
||||||
|
|
||||||
@fields.depends('extra_product')
|
@fields.depends('extra_product')
|
||||||
def on_change_with_unit_digits(self, name=None):
|
def on_change_with_unit_digits(self, name=None):
|
||||||
if self.extra_product:
|
if self.extra_product:
|
||||||
|
@ -62,20 +57,20 @@ class Template(metaclass=PoolMeta):
|
||||||
__name__ = 'product.template'
|
__name__ = 'product.template'
|
||||||
|
|
||||||
density = fields.Float('Density (kg/m3)',
|
density = fields.Float('Density (kg/m3)',
|
||||||
digits=(16, Eval('weight_digits', 2)), states=STATES,
|
digits=(16, Eval('weight_digits', 2)),
|
||||||
depends=DEPENDS + ['weight_digits'])
|
depends=['weight_digits'])
|
||||||
bulk_type = fields.Boolean('Bulk', states=STATES, depends=DEPENDS)
|
bulk_type = fields.Boolean('Bulk')
|
||||||
bulk_product = fields.Many2One('product.product', 'Bulk Product',
|
bulk_product = fields.Many2One('product.product', 'Bulk Product',
|
||||||
domain=[
|
domain=[
|
||||||
('bulk_type', '=', True),
|
('bulk_type', '=', True),
|
||||||
],
|
],
|
||||||
states= {
|
states= {
|
||||||
'readonly': (~Eval('active', True) | Eval('bulk_type') == True),
|
'readonly': (~Eval('active', True) | Eval('bulk_type') == True),
|
||||||
}, depends=DEPENDS)
|
}, depends=['bulk_type'])
|
||||||
bulk_quantity = fields.Function(fields.Float('Bulk Quantity',
|
bulk_quantity = fields.Function(fields.Float('Bulk Quantity',
|
||||||
help="The amount of bulk stock in the location."),
|
help="The amount of bulk stock in the location."),
|
||||||
'sum_product')
|
'sum_product')
|
||||||
packaging = fields.Boolean('Packaging', states=STATES, depends=DEPENDS)
|
packaging = fields.Boolean('Packaging')
|
||||||
packaging_products = fields.One2Many('product.template-product.packaging',
|
packaging_products = fields.One2Many('product.template-product.packaging',
|
||||||
'product', 'Packaging Products',
|
'product', 'Packaging Products',
|
||||||
states = {
|
states = {
|
||||||
|
@ -293,7 +288,6 @@ class Product(metaclass=PoolMeta):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_bulk_quantity(cls, products, name):
|
def get_bulk_quantity(cls, products, name):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Moves = pool.get('stock.move')
|
|
||||||
Location = pool.get('stock.location')
|
Location = pool.get('stock.location')
|
||||||
Product = pool.get('product.product')
|
Product = pool.get('product.product')
|
||||||
Date = pool.get('ir.date')
|
Date = pool.get('ir.date')
|
||||||
|
@ -328,11 +322,9 @@ class Product(metaclass=PoolMeta):
|
||||||
grouping=('product',) , grouping_filter=(products_ids,))
|
grouping=('product',) , grouping_filter=(products_ids,))
|
||||||
|
|
||||||
res.update(quantity)
|
res.update(quantity)
|
||||||
sum_ = []
|
|
||||||
for product in output_products:
|
for product in output_products:
|
||||||
res[product.bulk_product.id] += (bulk_quantity.get(product.id,0)
|
res[product.bulk_product.id] += (bulk_quantity.get(product.id,0)
|
||||||
* product.netweight if product.netweight else 0.0)
|
* product.netweight if product.netweight else 0.0)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tree editable="bottom">
|
<tree editable="1">
|
||||||
<field name="extra_product"/>
|
<field name="extra_product"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tree editable="bottom">
|
<tree editable="1">
|
||||||
<field name="packaging_product"/>
|
<field name="packaging_product"/>
|
||||||
<field name="packaged_product"/>
|
<field name="packaged_product"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
Loading…
Reference in New Issue