fix some bugs
This commit is contained in:
parent
f6739dfd90
commit
280b359a03
|
@ -89,7 +89,7 @@ class AgronomicsContract(Workflow, ModelSQL, ModelView):
|
||||||
return 'draft'
|
return 'draft'
|
||||||
|
|
||||||
def get_rec_name(self, name):
|
def get_rec_name(self, name):
|
||||||
ret = self.producer.rec_name
|
ret = self.producer and self.producer.rec_name or ''
|
||||||
if self.start_date:
|
if self.start_date:
|
||||||
ret += ' - %s' % (self.start_date)
|
ret += ' - %s' % (self.start_date)
|
||||||
return ret
|
return ret
|
||||||
|
|
2
plot.py
2
plot.py
|
@ -143,7 +143,7 @@ class Parcel(ModelSQL, ModelView):
|
||||||
)*self.surface, 2)
|
)*self.surface, 2)
|
||||||
|
|
||||||
def get_purchased_quantity(self, name):
|
def get_purchased_quantity(self, name):
|
||||||
return sum([w.netweight for w in self.weighings if not w.table])
|
return sum([w.netweight for w in self.weighings if not w.table and w.netweight])
|
||||||
|
|
||||||
def get_remaining_quantity(self, name):
|
def get_remaining_quantity(self, name):
|
||||||
return (self.max_production or 0) - (self.purchased_quantity or 0)
|
return (self.max_production or 0) - (self.purchased_quantity or 0)
|
||||||
|
|
|
@ -355,6 +355,7 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
||||||
WeighingParcel = pool.get('agronomics.weighing-agronomics.parcel')
|
WeighingParcel = pool.get('agronomics.weighing-agronomics.parcel')
|
||||||
weighing_parcel_to_save = []
|
weighing_parcel_to_save = []
|
||||||
to_analysis = []
|
to_analysis = []
|
||||||
|
|
||||||
for weighing in weighings:
|
for weighing in weighings:
|
||||||
if not weighing.table:
|
if not weighing.table:
|
||||||
if weighing.parcels:
|
if weighing.parcels:
|
||||||
|
@ -380,8 +381,10 @@ class Weighing(Workflow, ModelSQL, ModelView):
|
||||||
else:
|
else:
|
||||||
remaining_weight -= parcel.remaining_quantity
|
remaining_weight -= parcel.remaining_quantity
|
||||||
weighing_parcel.netweight = parcel.remaining_quantity
|
weighing_parcel.netweight = parcel.remaining_quantity
|
||||||
|
|
||||||
if weighing_parcel.netweight:
|
if weighing_parcel.netweight:
|
||||||
weighing_parcel_to_save.append(weighing_parcel)
|
weighing_parcel_to_save.append(weighing_parcel)
|
||||||
|
|
||||||
if remaining_weight == 0:
|
if remaining_weight == 0:
|
||||||
to_analysis.append(weighing)
|
to_analysis.append(weighing)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue