04.02.26
This commit is contained in:
@@ -59,9 +59,9 @@ class Fee(ModelSQL,ModelView):
|
||||
('pcost', '% cost price'),
|
||||
('ppack', 'Per packing'),
|
||||
], 'Mode', required=True)
|
||||
|
||||
inherit_qt = fields.Boolean("Inh Qt")
|
||||
quantity = fields.Function(fields.Numeric("Qt",digits='unit'),'get_quantity')
|
||||
auto_calculation = fields.Boolean("Auto Calc.",states={'readonly': (Eval('mode') != 'ppack')})
|
||||
inherit_qt = fields.Boolean("Inh Qt",states={'readonly': Eval('mode') != 'ppack'})
|
||||
quantity = fields.Numeric("Qt",digits='unit',states={'readonly': (Eval('mode') != 'ppack') | Bool(Eval('auto_calculation'))})
|
||||
unit = fields.Many2One('product.uom',"Unit",domain=[
|
||||
If(Eval('mode') == 'ppack',
|
||||
('category', '=', 8),
|
||||
@@ -74,7 +74,7 @@ class Fee(ModelSQL,ModelView):
|
||||
'invisible': (Eval('shipment_in')),
|
||||
})
|
||||
purchase = fields.Many2One('purchase.purchase',"Purchase", ondelete='CASCADE')
|
||||
|
||||
qt_state = fields.Many2One('lot.qt.type',"Qt State")
|
||||
amount = fields.Function(fields.Numeric("Amount", digits='currency'),'get_amount')
|
||||
fee_lots = fields.Function(fields.Many2Many('lot.lot', None, None, "Lots"),'get_lots')#, searcher='search_lots')
|
||||
lots = fields.Many2Many('fee.lots', 'fee', 'lot',"Lots",domain=[('id', 'in', Eval('fee_lots',-1))] )
|
||||
@@ -93,6 +93,33 @@ class Fee(ModelSQL,ModelView):
|
||||
('brut', 'Gross'),
|
||||
], string='W. type')
|
||||
|
||||
@classmethod
|
||||
def default_qt_state(cls):
|
||||
LotQtType = Pool().get('lot.qt.type')
|
||||
lqt = LotQtType.search([('name','=','BL')])
|
||||
if lqt:
|
||||
return lqt[0].id
|
||||
|
||||
@fields.depends('auto_calculation','mode','_parent_line.lots','_parent_sale_line.lots','_parent_shipment_in.id')
|
||||
def on_change_with_quantity(self, name=None):
|
||||
qt = None
|
||||
line = self.line
|
||||
if not line:
|
||||
line = self.sale_line
|
||||
if line:
|
||||
if line.lots:
|
||||
qt = sum([e.get_current_quantity_converted() for e in line.lots])
|
||||
if not qt:
|
||||
LotQt = Pool().get('lot.qt')
|
||||
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
|
||||
if lqts:
|
||||
qt = Decimal(lqts[0].lot_quantity)
|
||||
if self.mode != 'ppack':
|
||||
return qt
|
||||
else:
|
||||
if self.auto_calculation:
|
||||
return Decimal(int(qt/self.unit.factor))
|
||||
|
||||
@fields.depends('mode','_parent_line.lots','_parent_sale_line.lots')
|
||||
def on_change_with_unit(self, name=None):
|
||||
if self.mode != 'ppack':
|
||||
@@ -217,6 +244,8 @@ class Fee(ModelSQL,ModelView):
|
||||
return round(self.price / self.quantity,4)
|
||||
elif self.mode == 'perqt':
|
||||
return self.price
|
||||
elif self.mode == 'ppack':
|
||||
return self.price / self.unit.factor * self.get_unit().factor
|
||||
elif self.mode == 'pprice' or self.mode == 'pcost':
|
||||
if self.line and self.price:
|
||||
return round(self.price * Decimal(self.line.unit_price) / 100,4)
|
||||
@@ -238,7 +267,7 @@ class Fee(ModelSQL,ModelView):
|
||||
def get_landed_status(self,name):
|
||||
if self.product:
|
||||
return self.product.template.landed_cost
|
||||
|
||||
|
||||
def get_quantity(self,name=None):
|
||||
qt = self.get_fee_lots_qt()
|
||||
if qt:
|
||||
@@ -305,12 +334,12 @@ class Fee(ModelSQL,ModelView):
|
||||
|
||||
return super().copy(fees, default=default)
|
||||
|
||||
def get_fee_lots_qt(self):
|
||||
def get_fee_lots_qt(self,seq=0):
|
||||
qt = Decimal(0)
|
||||
FeeLots = Pool().get('fee.lots')
|
||||
fee_lots = FeeLots.search([('fee', '=', self.id)])
|
||||
if fee_lots:
|
||||
qt = sum([e.lot.get_current_quantity_converted() for e in fee_lots])
|
||||
qt = sum([e.lot.get_current_quantity_converted(seq) for e in fee_lots])
|
||||
logger.info("GET_FEE_LOTS_QT:%s",qt)
|
||||
return qt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user