diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index a29be71..9ba426a 100755 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -1920,13 +1920,14 @@ class Line(sequence_ordered(), ModelSQL, ModelView): invoice_line.lot = l.id if self.product.type == 'service': invoice_line.unit_price = self.unit_price - invoice_line.quantity = 1 invoice_line.product = self.product invoice_line.stock_moves = [] Fee = Pool().get('fee.fee') fee = Fee.search(['purchase','=',self.purchase.id]) if fee: invoice_line.fee = fee[0] + if fee[0].mode == 'lumpsum': + invoice_line.quantity = 1 lines.append(invoice_line) logger.info("GETINVLINE:%s",self.product.type) logger.info("GETINVLINE2:%s",l.invoice_line_prov) diff --git a/modules/purchase_trade/fee.py b/modules/purchase_trade/fee.py index 051138f..47c4348 100755 --- a/modules/purchase_trade/fee.py +++ b/modules/purchase_trade/fee.py @@ -278,10 +278,16 @@ class Fee(ModelSQL,ModelView): logger.info("ADJUST_PURCHASE_VALUES:%s",self) if self.type == 'ordered' and self.state == 'not invoiced' and self.purchase: logger.info("ADJUST_PURCHASE_VALUES_QT:%s",self.purchase.lines[0].quantity) - if self.amount != self.purchase.lines[0].unit_price: - self.purchase.lines[0].unit_price = self.amount - # if self.quantity != self.purchase.lines[0].quantity: - # self.purchase.lines[0].quantity = self.quantity + if self.mode == 'lumpsum': + if self.amount != self.purchase.lines[0].unit_price: + self.purchase.lines[0].unit_price = self.amount + # if self.quantity != self.purchase.lines[0].quantity: + # self.purchase.lines[0].quantity = self.quantity + else: + if self.get_price_per_qt() != self.purchase.lines[0].unit_price: + self.purchase.lines[0].unit_price = self.get_price_per_qt() + if self.quantity != self.purchase.lines[0].quantity: + self.purchase.lines[0].quantity = self.quantity if self.product != self.purchase.lines[0].product: self.purchase.lines[0].product = self.product PurchaseLine.save([self.purchase.lines[0]]) @@ -352,18 +358,20 @@ class Fee(ModelSQL,ModelView): PurchaseLine = Pool().get('purchase.line') pl = PurchaseLine() pl.product = fee.product - # if fee.line or fee.sale_line: - # pl.quantity = round(qt_line,5) - # if fee.shipment_in: - # pl.quantity = round(qt_sh,5) - pl.quantity = 1 + if fee.line or fee.sale_line: + pl.quantity = round(qt_line,5) + if fee.shipment_in: + pl.quantity = round(qt_sh,5) logger.info("CREATE_PURHCASE_FOR_FEE_QT:%s",pl.quantity) pl.unit = unit pl.fee_ = fee.id if fee.price: fee_price = fee.get_price_per_qt() logger.info("GET_FEE_PRICE_PER_QT:%s",fee_price) - pl.unit_price = round(Decimal(fee.amount),4) + pl.unit_price = round(Decimal(fee_price),4) + if fee.mode == 'lumpsum': + pl.quantity = 1 + pl.unit_price = round(Decimal(fee.amount),4) p = Purchase() p.lines = [pl] p.party = fee.supplier