Renamed module and homogenized with other farm modules
This commit is contained in:
parent
78cfb62038
commit
2c6ada2ecc
2
README
2
README
|
@ -14,7 +14,7 @@ questions on the NaN·tic bug tracker, mailing list,
|
||||||
wiki or IRC channel:
|
wiki or IRC channel:
|
||||||
|
|
||||||
* http://doc.tryton-erp.es/
|
* http://doc.tryton-erp.es/
|
||||||
* http://bitbucket.org/nantic/nutrition_program
|
* http://bitbucket.org/nantic/trytond-farm_nutrition_program
|
||||||
* http://groups.tryton.org/
|
* http://groups.tryton.org/
|
||||||
* http://wiki.tryton.org/
|
* http://wiki.tryton.org/
|
||||||
* irc://irc.freenode.net/tryton
|
* irc://irc.freenode.net/tryton
|
||||||
|
|
12
__init__.py
12
__init__.py
|
@ -1,5 +1,5 @@
|
||||||
#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.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from .nutrition_program import *
|
from .nutrition_program import *
|
||||||
|
@ -7,9 +7,11 @@ from .nutrition_program import *
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
|
Animal,
|
||||||
|
AnimalGroup,
|
||||||
NutritionProgram,
|
NutritionProgram,
|
||||||
StockLot,
|
Specie,
|
||||||
module='nutrition_program', type_='model')
|
module='farm_nutrition_program', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
OpenBOM,
|
OpenBOM,
|
||||||
module='nutrition_program', type_='wizard')
|
module='farm_nutrition_program', type_='wizard')
|
||||||
|
|
|
@ -2,66 +2,102 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,bom:"
|
msgctxt "field:farm.animal,nutrition_program:"
|
||||||
|
msgid "Nutrition Program"
|
||||||
|
msgstr "Programa de alimentación"
|
||||||
|
|
||||||
|
msgctxt "field:farm.animal.group,nutrition_program:"
|
||||||
|
msgid "Nutrition Program"
|
||||||
|
msgstr "Programa de alimentación"
|
||||||
|
|
||||||
|
msgctxt "field:farm.nutrition.program,animal_type:"
|
||||||
|
msgid "Animal Type"
|
||||||
|
msgstr "Tipo animal"
|
||||||
|
|
||||||
|
msgctxt "field:farm.nutrition.program,bom:"
|
||||||
msgid "BOM"
|
msgid "BOM"
|
||||||
msgstr "Lista de material"
|
msgstr "Lista de material"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,create_date:"
|
msgctxt "field:farm.nutrition.program,create_date:"
|
||||||
msgid "Create Date"
|
msgid "Create Date"
|
||||||
msgstr "Fecha de creación"
|
msgstr "Fecha de creación"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,create_uid:"
|
msgctxt "field:farm.nutrition.program,create_uid:"
|
||||||
msgid "Create User"
|
msgid "Create User"
|
||||||
msgstr "Usuario de creación"
|
msgstr "Usuario de creación"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,end_weight:"
|
msgctxt "field:farm.nutrition.program,end_weight:"
|
||||||
msgid "End Weight"
|
msgid "End Weight"
|
||||||
msgstr "Peso final"
|
msgstr "Peso final"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,id:"
|
msgctxt "field:farm.nutrition.program,id:"
|
||||||
msgid "ID"
|
msgid "ID"
|
||||||
msgstr "ID"
|
msgstr "Identificador"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,product:"
|
msgctxt "field:farm.nutrition.program,product:"
|
||||||
msgid "Product"
|
msgid "Product"
|
||||||
msgstr "Producto"
|
msgstr "Producto"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,rec_name:"
|
msgctxt "field:farm.nutrition.program,rec_name:"
|
||||||
msgid "Name"
|
msgid "Name"
|
||||||
msgstr "Nombre"
|
msgstr "Nombre"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,start_weight:"
|
msgctxt "field:farm.nutrition.program,specie:"
|
||||||
|
msgid "Specie"
|
||||||
|
msgstr "Especie"
|
||||||
|
|
||||||
|
msgctxt "field:farm.nutrition.program,start_weight:"
|
||||||
msgid "Start Weight"
|
msgid "Start Weight"
|
||||||
msgstr "Peso inicial"
|
msgstr "Peso inicial"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,write_date:"
|
msgctxt "field:farm.nutrition.program,write_date:"
|
||||||
msgid "Write Date"
|
msgid "Write Date"
|
||||||
msgstr "Fecha modificación"
|
msgstr "Fecha modificación"
|
||||||
|
|
||||||
msgctxt "field:nutrition.program,write_uid:"
|
msgctxt "field:farm.nutrition.program,write_uid:"
|
||||||
msgid "Write User"
|
msgid "Write User"
|
||||||
msgstr "Usuario modificación"
|
msgstr "Usuario modificación"
|
||||||
|
|
||||||
|
msgctxt "model:farm.nutrition.program,name:"
|
||||||
|
msgid "Nutrition Program"
|
||||||
|
msgstr "Programa de alimentación"
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:act_nutrition_program"
|
msgctxt "model:ir.action,name:act_nutrition_program"
|
||||||
msgid "Nutrition Programs"
|
msgid "Nutrition Programs"
|
||||||
msgstr "Programas de Alimentación"
|
msgstr "Programas de alimentación"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action,name:wizard_bom_open"
|
||||||
|
msgid "BOMs"
|
||||||
|
msgstr "Listas de material"
|
||||||
|
|
||||||
msgctxt "model:ir.action.act_window,name:act_nutrition_program"
|
msgctxt "model:ir.action.act_window,name:act_nutrition_program"
|
||||||
msgid "Nutrition Programs"
|
msgid "Nutrition Programs"
|
||||||
msgstr "Programa de Alimentación"
|
msgstr "Programas de alimentación"
|
||||||
|
|
||||||
msgctxt "model:ir.ui.menu,name:menu_nutrition_program"
|
msgctxt "model:res.group,name:group_nutrition_program"
|
||||||
|
msgid "Farm / Nutriton Program"
|
||||||
|
msgstr "Granja / Programa de alimentación"
|
||||||
|
|
||||||
|
msgctxt "selection:farm.nutrition.program,animal_type:"
|
||||||
|
msgid "Female"
|
||||||
|
msgstr "Hembra"
|
||||||
|
|
||||||
|
msgctxt "selection:farm.nutrition.program,animal_type:"
|
||||||
|
msgid "Group"
|
||||||
|
msgstr "Grupo"
|
||||||
|
|
||||||
|
msgctxt "selection:farm.nutrition.program,animal_type:"
|
||||||
|
msgid "Individual"
|
||||||
|
msgstr "Individual"
|
||||||
|
|
||||||
|
msgctxt "selection:farm.nutrition.program,animal_type:"
|
||||||
|
msgid "Male"
|
||||||
|
msgstr "Macho"
|
||||||
|
|
||||||
|
msgctxt "view:farm.nutrition.program:"
|
||||||
msgid "Nutrition Program"
|
msgid "Nutrition Program"
|
||||||
msgstr "Programa de Alimentación"
|
msgstr "Programa de alimentación"
|
||||||
|
|
||||||
msgctxt "model:ir.ui.menu,name:menu_nutrition_program_tree"
|
msgctxt "view:farm.nutrition.program:"
|
||||||
msgid "Nutrition Programs"
|
msgid "Nutrition Programs"
|
||||||
msgstr "Programas de Alimentación"
|
msgstr "Programas de alimentación"
|
||||||
|
|
||||||
msgctxt "model:nutrition.program,name:"
|
|
||||||
msgid "Nutrition Program"
|
|
||||||
msgstr "Programa de Alimentación"
|
|
||||||
|
|
||||||
msgctxt "model:res.group,name:group_nutrition_program_admin"
|
|
||||||
msgid "Nutrition Program Administration"
|
|
||||||
msgstr "Administrador de programas de alimentación"
|
|
||||||
|
|
|
@ -1,28 +1,38 @@
|
||||||
#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.
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.pyson import Eval, PYSONEncoder
|
from trytond.pyson import Eval, PYSONEncoder
|
||||||
from trytond.wizard import Wizard, StateAction
|
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
from trytond.wizard import Wizard, StateAction
|
||||||
|
|
||||||
__all__ = ['NutritionProgram', 'StockLot', 'OpenBOM']
|
__all__ = ['NutritionProgram', 'Animal', 'AnimalGroup', 'OpenBOM', 'Specie']
|
||||||
__metaclass__ = PoolMeta
|
__metaclass__ = PoolMeta
|
||||||
|
|
||||||
|
|
||||||
class NutritionProgram(ModelSQL, ModelView):
|
class NutritionProgram(ModelSQL, ModelView):
|
||||||
'Nutrition Program'
|
'Nutrition Program'
|
||||||
__name__ = 'nutrition.program'
|
__name__ = 'farm.nutrition.program'
|
||||||
|
|
||||||
|
specie = fields.Many2One('farm.specie', 'Specie', required=True,
|
||||||
|
readonly=True, select=True)
|
||||||
|
animal_type = fields.Selection([
|
||||||
|
('male', 'Male'),
|
||||||
|
('female', 'Female'),
|
||||||
|
('individual', 'Individual'),
|
||||||
|
('group', 'Group'),
|
||||||
|
], "Animal Type", required=True, select=True)
|
||||||
start_weight = fields.Float('Start Weight')
|
start_weight = fields.Float('Start Weight')
|
||||||
end_weight = fields.Float('End Weight')
|
end_weight = fields.Float('End Weight')
|
||||||
product = fields.Many2One('product.product', 'Product', required=True)
|
product = fields.Many2One('product.product', 'Product', required=True)
|
||||||
animal_product = fields.Many2One('product.product', 'Animal Product')
|
bom = fields.Function(fields.Many2One('production.bom', 'BOM', domain=[
|
||||||
bom = fields.Function(fields.Many2One('production.bom', 'BOM',
|
('output_products', '=', Eval('product', 0)),
|
||||||
domain=[
|
], depends=['product']),
|
||||||
('output_products', '=', Eval('product', 0)),
|
'get_bom')
|
||||||
],
|
|
||||||
depends=['product']), 'get_bom')
|
@staticmethod
|
||||||
|
def default_specie():
|
||||||
|
return Transaction().context.get('specie')
|
||||||
|
|
||||||
def get_bom(self, name):
|
def get_bom(self, name):
|
||||||
if self.product and self.product.boms:
|
if self.product and self.product.boms:
|
||||||
|
@ -33,48 +43,61 @@ class NutritionProgram(ModelSQL, ModelView):
|
||||||
self.start_weight or '', self.end_weight or '')
|
self.start_weight or '', self.end_weight or '')
|
||||||
|
|
||||||
|
|
||||||
class StockLot:
|
def _get_nutrition_program(animal):
|
||||||
__name__ = 'stock.lot'
|
pool = Pool()
|
||||||
|
Program = pool.get('farm.nutrition.program')
|
||||||
|
|
||||||
nutrition_program = fields.Function(fields.Many2One('nutrition.program',
|
domain = [
|
||||||
'Nutrition Program', domain=[
|
('specie', '=', animal.specie),
|
||||||
('product', '=', Eval('product')),
|
('animal_type', '=', animal.lot.animal_type),
|
||||||
], depends=['product']), 'get_nutrition_program')
|
]
|
||||||
|
order = [('end_weight', 'DESC')]
|
||||||
|
weight_domain = []
|
||||||
|
if animal.current_weight:
|
||||||
|
weight = animal.current_weight.weight
|
||||||
|
weight_domain = [
|
||||||
|
('start_weight', '<=', weight),
|
||||||
|
('end_weight', '>=', weight),
|
||||||
|
]
|
||||||
|
programs = Program.search(domain + weight_domain, order=order, limit=1)
|
||||||
|
if len(programs) > 0:
|
||||||
|
return programs[0].id
|
||||||
|
programs = Program.search(weight_domain, order=order, limit=1)
|
||||||
|
if len(programs) > 0:
|
||||||
|
return programs[0].id
|
||||||
|
|
||||||
|
|
||||||
|
class Animal:
|
||||||
|
__name__ = 'farm.animal'
|
||||||
|
|
||||||
|
nutrition_program = fields.Function(
|
||||||
|
fields.Many2One('farm.nutrition.program', 'Nutrition Program'),
|
||||||
|
'get_nutrition_program')
|
||||||
|
|
||||||
def get_nutrition_program(self, name):
|
def get_nutrition_program(self, name):
|
||||||
pool = Pool()
|
return _get_nutrition_program(self)
|
||||||
Program = pool.get('nutrition.program')
|
|
||||||
|
|
||||||
animal = self.animal_group if self.animal_group else self.animal
|
|
||||||
if not animal:
|
|
||||||
return
|
|
||||||
|
|
||||||
domain = [('animal_product', '=', self.product)]
|
class AnimalGroup:
|
||||||
order = [('end_weight', 'DESC')]
|
__name__ = 'farm.animal.group'
|
||||||
weight_domain = []
|
|
||||||
if animal.current_weight:
|
nutrition_program = fields.Function(
|
||||||
weight = animal.current_weight.weight
|
fields.Many2One('farm.nutrition.program', 'Nutrition Program'),
|
||||||
weight_domain = [
|
'get_nutrition_program')
|
||||||
('start_weight', '<=', weight),
|
|
||||||
('end_weight', '>=', weight),
|
def get_nutrition_program(self, name):
|
||||||
]
|
return _get_nutrition_program(self)
|
||||||
programs = Program.search(domain + weight_domain, order=order, limit=1)
|
|
||||||
if len(programs) > 0:
|
|
||||||
return programs[0].id
|
|
||||||
programs = Program.search(weight_domain, order=order, limit=1)
|
|
||||||
if len(programs) > 0:
|
|
||||||
return programs[0].id
|
|
||||||
|
|
||||||
|
|
||||||
class OpenBOM(Wizard):
|
class OpenBOM(Wizard):
|
||||||
'Open BOM'
|
'Open BOM'
|
||||||
__name__ = 'nutrition.program.open.bom'
|
__name__ = 'farm.nutrition.program.open_bom'
|
||||||
start_state = 'open_'
|
start_state = 'open_'
|
||||||
open_ = StateAction('production.act_bom_list')
|
open_ = StateAction('production.act_bom_list')
|
||||||
|
|
||||||
def do_open_(self, action):
|
def do_open_(self, action):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
NutritionProgram = pool.get('nutrition.program')
|
NutritionProgram = pool.get('farm.nutrition.program')
|
||||||
|
|
||||||
program = NutritionProgram(Transaction().context.get('active_id'))
|
program = NutritionProgram(Transaction().context.get('active_id'))
|
||||||
|
|
||||||
|
@ -88,3 +111,33 @@ class OpenBOM(Wizard):
|
||||||
|
|
||||||
def transition_open_(self):
|
def transition_open_(self):
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
||||||
|
|
||||||
|
class Specie:
|
||||||
|
__name__ = 'farm.specie'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _create_additional_menus(cls, specie, specie_menu, specie_submenu_seq,
|
||||||
|
current_menus, current_actions):
|
||||||
|
pool = Pool()
|
||||||
|
ActWindow = pool.get('ir.action.act_window')
|
||||||
|
Group = pool.get('res.group')
|
||||||
|
ModelData = pool.get('ir.model.data')
|
||||||
|
|
||||||
|
super(Specie, cls)._create_additional_menus(specie, specie_menu,
|
||||||
|
specie_submenu_seq, current_menus, current_actions)
|
||||||
|
|
||||||
|
act_window_program = ActWindow(ModelData.get_id(
|
||||||
|
'farm_nutrition_program', 'act_nutrition_program'))
|
||||||
|
program_group = Group(ModelData.get_id('farm_nutrition_program',
|
||||||
|
'group_nutrition_program'))
|
||||||
|
|
||||||
|
cls._create_menu_w_action(specie, [
|
||||||
|
('specie', '=', specie.id),
|
||||||
|
], {
|
||||||
|
'specie': specie.id,
|
||||||
|
},
|
||||||
|
'Nutrition Programs', specie_menu, specie_submenu_seq,
|
||||||
|
'tryton-list', program_group, act_window_program, False,
|
||||||
|
current_menus, current_actions)
|
||||||
|
specie_submenu_seq += 1
|
||||||
|
|
|
@ -3,30 +3,44 @@
|
||||||
copyright notices and license terms. -->
|
copyright notices and license terms. -->
|
||||||
<tryton>
|
<tryton>
|
||||||
<data>
|
<data>
|
||||||
|
<!-- groups -->
|
||||||
|
<record model="res.group" id="group_nutrition_program">
|
||||||
|
<field name="name">Farm / Nutriton Program</field>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group"
|
||||||
|
id="user_admin_group_nutrition_programs">
|
||||||
|
<field name="user" ref="res.user_admin"/>
|
||||||
|
<field name="group" ref="group_nutrition_program"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group"
|
||||||
|
id="user_trigger_group_nutrition_programs">
|
||||||
|
<field name="user" ref="res.user_trigger"/>
|
||||||
|
<field name="group" ref="group_nutrition_program"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- farm.nutrition.program -->
|
||||||
<record model="ir.ui.view" id="nutrition_program_view_form">
|
<record model="ir.ui.view" id="nutrition_program_view_form">
|
||||||
<field name="model">nutrition.program</field>
|
<field name="model">farm.nutrition.program</field>
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="name">nutrition_program_form</field>
|
<field name="name">nutrition_program_form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="nutrition_program_view_tree">
|
<record model="ir.ui.view" id="nutrition_program_view_tree">
|
||||||
<field name="model">nutrition.program</field>
|
<field name="model">farm.nutrition.program</field>
|
||||||
<field name="type">tree</field>
|
<field name="type">tree</field>
|
||||||
<field name="name">nutrition_program_tree</field>
|
<field name="name">nutrition_program_tree</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<record model="ir.action.act_window" id="act_nutrition_program">
|
<record model="ir.action.act_window" id="act_nutrition_program">
|
||||||
<field name="name">Nutrition Programs</field>
|
<field name="name">Nutrition Programs</field>
|
||||||
<field name="res_model">nutrition.program</field>
|
<field name="res_model">farm.nutrition.program</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.action.act_window.view"
|
<record model="ir.action.act_window.view"
|
||||||
id="act_nutrition_program_view1">
|
id="act_nutrition_program_view1">
|
||||||
<field name="sequence" eval="10"/>
|
<field name="sequence" eval="10"/>
|
||||||
<field name="view" ref="nutrition_program_view_tree"/>
|
<field name="view" ref="nutrition_program_view_tree"/>
|
||||||
<field name="act_window" ref="act_nutrition_program"/>
|
<field name="act_window" ref="act_nutrition_program"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.action.act_window.view"
|
<record model="ir.action.act_window.view"
|
||||||
id="act_nutrition_program_view2">
|
id="act_nutrition_program_view2">
|
||||||
<field name="sequence" eval="20"/>
|
<field name="sequence" eval="20"/>
|
||||||
|
@ -34,55 +48,37 @@
|
||||||
<field name="act_window" ref="act_nutrition_program"/>
|
<field name="act_window" ref="act_nutrition_program"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem name="Nutrition Program" id="menu_nutrition_program"
|
|
||||||
sequence="8"/>
|
|
||||||
<menuitem parent="menu_nutrition_program" action="act_nutrition_program"
|
|
||||||
id="menu_nutrition_program_tree" sequence="10"/>
|
|
||||||
|
|
||||||
<!-- Permissions -->
|
|
||||||
<record model="res.group" id="group_nutrition_program_admin">
|
|
||||||
<field name="name">Nutrition Program Administration</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record model="res.user-res.group"
|
|
||||||
id="user_admin_group_nutrition_program_admin">
|
|
||||||
<field name="user" ref="res.user_admin"/>
|
|
||||||
<field name="group" ref="group_nutrition_program_admin"/>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record model="ir.ui.menu-res.group" id="menugroup_nutrition_program">
|
|
||||||
<field name="menu" ref="menu_nutrition_program"/>
|
|
||||||
<field name="group" ref="group_nutrition_program_admin"/>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
|
|
||||||
<record model="ir.model.access" id="access_nutrition_program">
|
<record model="ir.model.access" id="access_nutrition_program">
|
||||||
<field name="model" search="[('model', '=', 'nutrition.program')]"/>
|
<field name="model"
|
||||||
|
search="[('model', '=', 'farm.nutrition.program')]"/>
|
||||||
<field name="perm_read" eval="True"/>
|
<field name="perm_read" eval="True"/>
|
||||||
<field name="perm_write" eval="False"/>
|
<field name="perm_write" eval="False"/>
|
||||||
<field name="perm_create" eval="False"/>
|
<field name="perm_create" eval="False"/>
|
||||||
<field name="perm_delete" eval="False"/>
|
<field name="perm_delete" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.model.access" id="access_nutrition_program_admin">
|
<record model="ir.model.access"
|
||||||
<field name="model" search="[('model', '=', 'nutrition.program')]"/>
|
id="access_nutrition_program_group_nutrition_program">
|
||||||
<field name="group" ref="group_nutrition_program_admin"/>
|
<field name="model"
|
||||||
|
search="[('model', '=', 'farm.nutrition.program')]"/>
|
||||||
|
<field name="group" ref="group_nutrition_program"/>
|
||||||
<field name="perm_read" eval="True"/>
|
<field name="perm_read" eval="True"/>
|
||||||
<field name="perm_write" eval="True"/>
|
<field name="perm_write" eval="True"/>
|
||||||
<field name="perm_create" eval="True"/>
|
<field name="perm_create" eval="True"/>
|
||||||
<field name="perm_delete" eval="True"/>
|
<field name="perm_delete" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- farm.nutrition.program.open_bom -->
|
||||||
<record model="ir.action.wizard" id="wizard_bom_open">
|
<record model="ir.action.wizard" id="wizard_bom_open">
|
||||||
<field name="name">BOMs</field>
|
<field name="name">BOMs</field>
|
||||||
<field name="wiz_name">nutrition.program.open.bom</field>
|
<field name="wiz_name">farm.nutrition.program.open_bom</field>
|
||||||
</record>
|
|
||||||
<record model="ir.action.keyword"
|
|
||||||
id="act_nutrition_program_open_keyword1">
|
|
||||||
<field name="keyword">form_relate</field>
|
|
||||||
<field name="model">nutrition.program,-1</field>
|
|
||||||
<field name="action" ref="wizard_bom_open"/>
|
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.keyword"
|
||||||
|
id="act_nutrition_program_open_keyword1">
|
||||||
|
<field name="keyword">form_relate</field>
|
||||||
|
<field name="model">farm.nutrition.program,-1</field>
|
||||||
|
<field name="action" ref="wizard_bom_open"/>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ import re
|
||||||
import os
|
import os
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
|
|
||||||
MODULE = 'nutrition_program'
|
MODULE = 'farm_nutrition_program'
|
||||||
PREFIX = 'nantic'
|
PREFIX = 'nantic'
|
||||||
MODULE2PREFIX = {}
|
MODULE2PREFIX = {}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# 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.
|
||||||
|
from .test_nutrition_program import suite
|
||||||
from .test import suite
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
====================
|
==========================
|
||||||
Move Events Scenario
|
Nutrition Program Scenario
|
||||||
====================
|
==========================
|
||||||
|
|
||||||
=============
|
=============
|
||||||
General Setup
|
General Setup
|
||||||
|
@ -13,7 +13,7 @@ Imports::
|
||||||
>>> from decimal import Decimal
|
>>> from decimal import Decimal
|
||||||
>>> from proteus import config, Model, Wizard
|
>>> from proteus import config, Model, Wizard
|
||||||
>>> now = datetime.datetime.now()
|
>>> now = datetime.datetime.now()
|
||||||
>>> yesterday = datetime.datetime.now() - relativedelta(month=1)
|
>>> yesterday = datetime.datetime.now() - relativedelta(days=1)
|
||||||
>>> today = datetime.date.today()
|
>>> today = datetime.date.today()
|
||||||
|
|
||||||
Create database::
|
Create database::
|
||||||
|
@ -25,7 +25,7 @@ Install farm::
|
||||||
|
|
||||||
>>> Module = Model.get('ir.module.module')
|
>>> Module = Model.get('ir.module.module')
|
||||||
>>> modules = Module.find([
|
>>> modules = Module.find([
|
||||||
... ('name', '=', 'nutrition_program'),
|
... ('name', '=', 'farm_nutrition_program'),
|
||||||
... ])
|
... ])
|
||||||
>>> Module.install([x.id for x in modules], config.context)
|
>>> Module.install([x.id for x in modules], config.context)
|
||||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
||||||
|
@ -177,19 +177,20 @@ Create individual::
|
||||||
u'L1'
|
u'L1'
|
||||||
>>> individual.farm.code
|
>>> individual.farm.code
|
||||||
u'WH'
|
u'WH'
|
||||||
>>> individual.lot.nutrition_program == None
|
>>> individual.nutrition_program == None
|
||||||
True
|
True
|
||||||
|
|
||||||
Create nutrition program::
|
Create nutrition program::
|
||||||
|
|
||||||
>>> NutritionProgram = Model.get('nutrition.program')
|
>>> NutritionProgram = Model.get('farm.nutrition.program')
|
||||||
>>> nutrition_program = NutritionProgram(
|
>>> nutrition_program = NutritionProgram(
|
||||||
|
... specie=pigs_specie,
|
||||||
|
... animal_type='individual',
|
||||||
... start_weight=10.0,
|
... start_weight=10.0,
|
||||||
... end_weight=30.0,
|
... end_weight=30.0,
|
||||||
... product=grain_product)
|
... product=grain_product)
|
||||||
... animal_product=individual_product)
|
|
||||||
>>> nutrition_program.save()
|
>>> nutrition_program.save()
|
||||||
>>> individual.lot.nutrition_program == None
|
>>> individual.nutrition_program == None
|
||||||
True
|
True
|
||||||
|
|
||||||
Add weight on animal::
|
Add weight on animal::
|
||||||
|
@ -204,16 +205,17 @@ Add weight on animal::
|
||||||
>>> individual.reload()
|
>>> individual.reload()
|
||||||
>>> individual.current_weight.weight == Decimal('15.0')
|
>>> individual.current_weight.weight == Decimal('15.0')
|
||||||
True
|
True
|
||||||
>>> individual.lot.nutrition_program == nutrition_program
|
>>> individual.nutrition_program == nutrition_program
|
||||||
True
|
True
|
||||||
|
|
||||||
Create another nutrition program::
|
Create another nutrition program::
|
||||||
|
|
||||||
>>> nutrition_program2 = NutritionProgram(
|
>>> nutrition_program2 = NutritionProgram(
|
||||||
|
... specie=pigs_specie,
|
||||||
|
... animal_type='individual',
|
||||||
... start_weight=50.0,
|
... start_weight=50.0,
|
||||||
... end_weight=70.0,
|
... end_weight=70.0,
|
||||||
... product=grain_product)
|
... product=grain_product)
|
||||||
... animal_product=individual_product)
|
|
||||||
>>> nutrition_program2.save()
|
>>> nutrition_program2.save()
|
||||||
>>> AnimalWeight = Model.get('farm.animal.weight')
|
>>> AnimalWeight = Model.get('farm.animal.weight')
|
||||||
>>> kg, = ProductUom.find([('name', '=', 'Kilogram')])
|
>>> kg, = ProductUom.find([('name', '=', 'Kilogram')])
|
||||||
|
@ -225,5 +227,5 @@ Create another nutrition program::
|
||||||
>>> individual.reload()
|
>>> individual.reload()
|
||||||
>>> individual.current_weight.weight == Decimal('60.0')
|
>>> individual.current_weight.weight == Decimal('60.0')
|
||||||
True
|
True
|
||||||
>>> individual.lot.nutrition_program == nutrition_program2
|
>>> individual.nutrition_program == nutrition_program2
|
||||||
True
|
True
|
||||||
|
|
|
@ -22,13 +22,13 @@ class TestCase(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
trytond.tests.test_tryton.install_module('nutrition_program')
|
trytond.tests.test_tryton.install_module('farm_nutrition_program')
|
||||||
|
|
||||||
def test0005views(self):
|
def test0005views(self):
|
||||||
'''
|
'''
|
||||||
Test views.
|
Test views.
|
||||||
'''
|
'''
|
||||||
test_view('nutrition_program')
|
test_view('farm_nutrition_program')
|
||||||
|
|
||||||
def test0006depends(self):
|
def test0006depends(self):
|
||||||
'''
|
'''
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=3.0.0
|
version=3.0.1
|
||||||
depends:
|
depends:
|
||||||
farm
|
farm
|
||||||
xml:
|
xml:
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<!-- 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. -->
|
||||||
<form string="Nutrition Program" col="4">
|
<form string="Nutrition Program" col="4">
|
||||||
|
<label name="animal_type"/>
|
||||||
|
<field name="animal_type"/>
|
||||||
|
<newline/>
|
||||||
<label name="start_weight"/>
|
<label name="start_weight"/>
|
||||||
<field name="start_weight"/>
|
<field name="start_weight"/>
|
||||||
<label name="end_weight"/>
|
<label name="end_weight"/>
|
||||||
|
@ -10,6 +13,4 @@
|
||||||
<field name="product"/>
|
<field name="product"/>
|
||||||
<label name="bom"/>
|
<label name="bom"/>
|
||||||
<field name="bom"/>
|
<field name="bom"/>
|
||||||
<label name="animal_product"/>
|
|
||||||
<field name="animal_product"/>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- 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. -->
|
||||||
<tree string="Nutrition program">
|
<tree string="Nutrition Programs">
|
||||||
<field name="product"/>
|
<field name="product"/>
|
||||||
|
<field name="animal_type"/>
|
||||||
<field name="start_weight"/>
|
<field name="start_weight"/>
|
||||||
<field name="end_weight"/>
|
<field name="end_weight"/>
|
||||||
<field name="bom"/>
|
<field name="bom"/>
|
||||||
|
|
Loading…
Reference in New Issue