add wizard to create parcels from previous crop
This commit is contained in:
parent
dd341b2e99
commit
f6739dfd90
|
@ -54,6 +54,7 @@ def register():
|
|||
quality.QualityTest,
|
||||
quality.QuantitativeTestLine,
|
||||
quality.QualitativeTestLine,
|
||||
plot.CreateNewParcelStart,
|
||||
production.ProductionTemplate,
|
||||
production.ProductionTemplateLine,
|
||||
production.ProductionTemplateInputsProductTemplate,
|
||||
|
@ -62,7 +63,6 @@ def register():
|
|||
production.OutputDistribution,
|
||||
production.ProductionEnologyProduct,
|
||||
production.ProductionCostPriceDistribution,
|
||||
# production.ProductionProductionCostPriceDistribution,
|
||||
production.ProductionCostPriceDistributionTemplate,
|
||||
production.ProductionCostPriceDistributionTemplateProductionTemplateAsk,
|
||||
location.LocationMaterial,
|
||||
|
@ -72,6 +72,7 @@ def register():
|
|||
module='agronomics', type_='model')
|
||||
Pool.register(
|
||||
production.ProductionCostPriceDistributionTemplateProductionTemplate,
|
||||
plot.CreateNewParcel,
|
||||
module='agronomics', type_='wizard')
|
||||
Pool.register(
|
||||
module='agronomics', type_='report')
|
||||
|
|
35
plot.py
35
plot.py
|
@ -2,7 +2,7 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import fields, ModelSQL, ModelView
|
||||
from trytond.pool import Pool
|
||||
|
||||
from trytond.wizard import (Wizard, StateView, Button, StateTransition)
|
||||
|
||||
class Enclosure(ModelSQL, ModelView):
|
||||
"Enclosure"
|
||||
|
@ -28,6 +28,13 @@ class Crop(ModelSQL, ModelView):
|
|||
start_date = fields.Date('Start Date', required=True)
|
||||
end_date = fields.Date('End Date', required=True)
|
||||
|
||||
def copy_parcels(self, next_crop):
|
||||
pool = Pool()
|
||||
Parcel = pool.get('agronomics.parcel')
|
||||
parcels = Parcel.search([('crop' ,'=', self.id)])
|
||||
Parcel.copy(parcels, {'crop': next_crop})
|
||||
|
||||
|
||||
|
||||
class DenominationOrigin(ModelSQL, ModelView):
|
||||
"Denomination of Origin"
|
||||
|
@ -171,3 +178,29 @@ class Beneficiaries(ModelSQL, ModelView):
|
|||
table.drop_column('percent')
|
||||
|
||||
super(Beneficiaries, cls).__register__(module_name)
|
||||
|
||||
class CreateNewParcel(Wizard):
|
||||
'New Version'
|
||||
__name__ = 'agronomics.create_new_parcels'
|
||||
|
||||
start = StateView('agronomics.create_new_parcels.start',
|
||||
'agronomics.create_new_parcels_start_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Create', 'copy_parcels', 'tryton-accept', default=True),
|
||||
])
|
||||
copy_parcels = StateTransition()
|
||||
|
||||
def transition_copy_parcels(self):
|
||||
crop = self.start.previous_crop
|
||||
crop.copy_parcels(self.start.next_crop)
|
||||
return 'end'
|
||||
|
||||
|
||||
class CreateNewParcelStart(ModelView):
|
||||
"Create New Parcel - Start"
|
||||
__name__ = 'agronomics.create_new_parcels.start'
|
||||
|
||||
previous_crop = fields.Many2One('agronomics.crop', "Previous Crop",
|
||||
required=True)
|
||||
next_crop = fields.Many2One('agronomics.crop', "Next Crop",
|
||||
required=True)
|
||||
|
|
18
plot.xml
18
plot.xml
|
@ -543,5 +543,23 @@
|
|||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_create_new_parcels">
|
||||
<field name="name">Create new Parcels</field>
|
||||
<field name="wiz_name">agronomics.create_new_parcels</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="create_new_parcels_start_form">
|
||||
<field name="model">agronomics.create_new_parcels.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">create_new_parcels_start_form</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
parent="agronomics.menu_crop_list"
|
||||
action="wizard_create_new_parcels"
|
||||
sequence="90"
|
||||
id="menu_create_new_parcels"/>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<form>
|
||||
<label name="previous_crop"/>
|
||||
<field name="previous_crop"/>
|
||||
<label name="next_crop"/>
|
||||
<field name="next_crop"/>
|
||||
</form>
|
Loading…
Reference in New Issue