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

View file

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

View file

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

View file

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

View file

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