04.02.26
This commit is contained in:
@@ -502,21 +502,21 @@ class Lot(ModelSQL, ModelView):
|
||||
physic_sum += round(Decimal(Uom.compute_qty(Uom(l.lot_unit_line),float(l.get_current_quantity()),l.line.unit)),5)
|
||||
return line.quantity_theorical - physic_sum
|
||||
|
||||
def get_current_quantity(self,name=None):
|
||||
def get_current_quantity(self,seq=0,name=None):
|
||||
# if self.lot_type == 'physic':
|
||||
qt, gross_qt = self.get_hist_quantity(0)
|
||||
qt, gross_qt = self.get_hist_quantity(seq)
|
||||
return qt
|
||||
# else:
|
||||
# return self.get_virtual_diff()
|
||||
|
||||
def get_current_quantity_converted(self,name=None):
|
||||
def get_current_quantity_converted(self,seq=0,name=None):
|
||||
Uom = Pool().get('product.uom')
|
||||
unit = self.line.unit if self.line else self.sale_line.unit
|
||||
return round(Decimal(Uom.compute_qty(self.lot_unit_line, float(self.get_current_quantity()), unit)),5)
|
||||
return round(Decimal(Uom.compute_qty(self.lot_unit_line, float(self.get_current_quantity(seq)), unit)),5)
|
||||
|
||||
def get_current_gross_quantity(self,name=None):
|
||||
def get_current_gross_quantity(self,seq=0,name=None):
|
||||
if self.lot_type == 'physic':
|
||||
qt, gross_qt = self.get_hist_quantity(0)
|
||||
qt, gross_qt = self.get_hist_quantity(seq)
|
||||
return gross_qt
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -1928,6 +1928,16 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
invoice_line.fee = fee[0]
|
||||
if fee[0].mode == 'lumpsum':
|
||||
invoice_line.quantity = 1
|
||||
elif fee[0].mode == 'ppack':
|
||||
invoice_line.quantity = fee[0].quantity
|
||||
else:
|
||||
seq = 0
|
||||
LotQtType = Pool().get('lot.qt.type')
|
||||
lqt = LotQtType.search([('name','=','BL')])
|
||||
if lqt:
|
||||
seq = lqt[0].sequence
|
||||
invoice_line.quantity = fee[0].get_fee_lots_qt(seq)
|
||||
|
||||
lines.append(invoice_line)
|
||||
logger.info("GETINVLINE:%s",self.product.type)
|
||||
logger.info("GETINVLINE2:%s",l.invoice_line_prov)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="supplier"/>
|
||||
<field name="mode"/>
|
||||
<field name="unit"/>
|
||||
<field name="auto_calculation"/>
|
||||
<field name="price"/>
|
||||
<field name="currency"/>
|
||||
<field name="weight_type"/>
|
||||
<field name="p_r"/>
|
||||
<field name="quantity" symbol="unit"/>
|
||||
<field name="amount"/>
|
||||
<field name="bl_state"/>
|
||||
<field name="inherit_shipment"/>
|
||||
<!-- <field name="purchase"/> -->
|
||||
<field name="inv"/>
|
||||
|
||||
@@ -7,12 +7,14 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="supplier"/>
|
||||
<field name="mode"/>
|
||||
<field name="unit"/>
|
||||
<field name="auto_calculation"/>
|
||||
<field name="price"/>
|
||||
<field name="currency"/>
|
||||
<field name="weight_type"/>
|
||||
<field name="p_r"/>
|
||||
<field name="quantity" symbol="unit"/>
|
||||
<field name="amount"/>
|
||||
<field name="bl_state"/>
|
||||
<!-- <field name="purchase"/> -->
|
||||
<field name="inv"/>
|
||||
<field name="state"/>
|
||||
|
||||
Reference in New Issue
Block a user