minor fix

This commit is contained in:
Elvis 2022-11-02 16:13:39 -05:00
parent 7091abf114
commit 5d3f5d9163
2 changed files with 11 additions and 6 deletions

14
crop.py
View File

@ -276,11 +276,15 @@ class FarmingCrop(Workflow, ModelSQL, ModelView):
@classmethod
def create_lots_lines(cls, crops):
Line = Pool().get('farming.crop.lot')
Lot = Pool().get('farming.location.lot')
lines = []
cls.clear_bed_lines(crops)
cls.clear_lots_lines(crops)
print('entro funcion')
for crop in crops:
for lot in crop.location.lots:
lots = Lot.search([('location', '=', crop.location)])
print(lots)
for lot in lots:
line = Line(
crop = crop.id,
lot = lot.id,
@ -290,7 +294,10 @@ class FarmingCrop(Workflow, ModelSQL, ModelView):
total_plants = lot.quantity
)
lines.append(line)
print(lines)
Line.save(lines)
print('crea estancias de cama')
cls.create_beds_lines(crops)
@classmethod
@ -424,8 +431,6 @@ class FarmingCrop(Workflow, ModelSQL, ModelView):
@classmethod
@ModelView.button
def load_location(cls, crops):
cls.clear_bed_lines(crops)
cls.clear_lots_lines(crops)
cls.create_lots_lines(crops)
cls.get_total_plants(crops)
@ -542,8 +547,7 @@ class FarmingCropLot(ModelSQL, ModelView):
__name__ = 'farming.crop.lot'
_rec_name = 'number'
crop = fields.Many2One('farming.crop', 'Crop', ondelete='CASCADE', required=True)
lot = fields.Many2One('farming.location.lot', 'Lot', required=True,
domain=[('lot.location', '=', 'crop_location')])
lot = fields.Many2One('farming.location.lot', 'Lot', required=True)
cycle = fields.Float('Cycle', digits=(16, 2), help="In weeks")
beds = fields.One2Many('farming.crop.lot.bed', 'lot', 'Beds')
activities = fields.One2Many('farming.activity', 'lot', 'Activities')

View File

@ -25,7 +25,8 @@ class FarmingLocationLot(ModelSQL, ModelView):
_rec_name = 'number'
number = fields.Char('Number', required=True)
location = fields.Many2One('farming.location', 'Location', required=True)
variety = fields.Many2One('farming.variety', 'Variety')
#variety = fields.Many2One('farming.variety', 'Variety')
variety = fields.Many2One('product.product', 'Variety')
quantity = fields.Integer('Quantity', states = {'readonly': Bool(Eval('beds'))}, depends=['beds'])
beds = fields.One2Many('farming.location.lot.bed', 'lot', 'Beds')