Expiry info should be a defined on product template, not on variant

This commit is contained in:
Sergi Almacellas Abellana 2013-10-28 13:58:39 +01:00
parent 166d363088
commit dde0ecbdb8
6 changed files with 19 additions and 19 deletions

View File

@ -7,7 +7,7 @@ from .stock import *
def register():
Pool.register(
Product,
Template,
Lot,
Location,
Move,

View File

@ -7,12 +7,12 @@ from trytond.pool import Pool, PoolMeta
from trytond.pyson import And, Bool, Equal, Eval, If, Not
from trytond.transaction import Transaction
__all__ = ['Product', 'Lot', 'Location', 'Move']
__all__ = ['Template', 'Lot', 'Location', 'Move']
__metaclass__ = PoolMeta
class Product:
__name__ = 'product.product'
class Template:
__name__ = 'product.template'
life_time = fields.Integer('Life Time',
help='The number of days before a lot may become dangerous and should '
@ -80,7 +80,7 @@ class Lot:
for fname in ('life_date', 'expiry_date', 'removal_date',
'alert_date'):
product_field = fname.replace('date', 'time')
margin = getattr(self.product, product_field)
margin = getattr(self.product.template, product_field)
result[fname] = (margin
and date.today() + timedelta(days=margin))
return result

View File

@ -5,14 +5,14 @@
<data>
<!-- product.product -->
<record model="ir.ui.view" id="product_view_form">
<field name="model">product.product</field>
<field name="inherit" ref="product.product_view_form"/>
<field name="model">product.template</field>
<field name="inherit" ref="product.template_view_form"/>
<field name="name">product_form</field>
</record>
<record model="ir.ui.view" id="product_view_list">
<field name="model">product.product</field>
<field name="inherit" ref="product.product_view_tree"/>
<field name="model">product.template</field>
<field name="inherit" ref="product.template_view_tree"/>
<field name="name">product_list</field>
</record>

View File

@ -63,13 +63,13 @@ class TestCase(unittest.TestCase):
'cost_price': Decimal(0),
'cost_price_method': 'fixed',
'default_uom': unit.id,
}])
product, = self.product.create([{
'template': template.id,
'life_time': 20,
'expiry_time': 10,
'alert_time': 5,
}])
product, = self.product.create([{
'template': template.id,
}])
lot, lot2, = self.lot.create([{
'number': '001',
'product': product.id,
@ -116,13 +116,13 @@ class TestCase(unittest.TestCase):
'cost_price': Decimal(0),
'cost_price_method': 'fixed',
'default_uom': unit.id,
}])
product, = self.product.create([{
'template': template.id,
'life_time': 20,
'expiry_time': 10,
'alert_time': 5,
}])
product, = self.product.create([{
'template': template.id,
}])
lot, lot2, = self.lot.create([{
'number': '001',
'product': product.id,

View File

@ -2,8 +2,8 @@
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='description']" position="after">
<group id="expiry_times" colspan="4" col="8">
<xpath expr="/form/notebook" position="inside">
<page id="expiry_times" string="Expiry Times">
<label name="life_time"/>
<field name="life_time"/>
<label name="expiry_time"/>
@ -12,6 +12,6 @@
<field name="removal_time"/>
<label name="alert_time"/>
<field name="alert_time"/>
</group>
</page>
</xpath>
</data>

View File

@ -2,7 +2,7 @@
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/tree/field[@name='rec_name']" position="after">
<xpath expr="/tree/field[@name='default_uom']" position="after">
<field name="expiry_time"/>
</xpath>
</data>