02.04.26
This commit is contained in:
@@ -2774,40 +2774,54 @@ class LotInvoice(Wizard):
|
||||
'action': act
|
||||
}
|
||||
|
||||
def transition_invoicing(self):
|
||||
Lot = Pool().get('lot.lot')
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
Sale = Pool().get('sale.sale')
|
||||
lots = []
|
||||
action = self.inv.action
|
||||
for r in self.records:
|
||||
purchase = r.r_line.purchase
|
||||
sale = None
|
||||
if r.r_sale_line:
|
||||
sale = r.r_sale_line.sale
|
||||
lot = Lot(r.r_lot_p)
|
||||
# if lot.move == None:
|
||||
# Warning = Pool().get('res.user.warning')
|
||||
# warning_name = Warning.format("Lot not confirmed", [])
|
||||
# if Warning.check(warning_name):
|
||||
def transition_invoicing(self):
|
||||
Lot = Pool().get('lot.lot')
|
||||
Purchase = Pool().get('purchase.purchase')
|
||||
Sale = Pool().get('sale.sale')
|
||||
lots = []
|
||||
purchases = []
|
||||
sales = []
|
||||
action = self.inv.action
|
||||
for r in self.records:
|
||||
purchase = r.r_line.purchase if r.r_line else None
|
||||
sale = r.r_sale_line.sale if r.r_sale_line else None
|
||||
if purchase and purchase not in purchases:
|
||||
purchases.append(purchase)
|
||||
if sale and sale not in sales:
|
||||
sales.append(sale)
|
||||
lot = Lot(r.r_lot_p)
|
||||
# if lot.move == None:
|
||||
# Warning = Pool().get('res.user.warning')
|
||||
# warning_name = Warning.format("Lot not confirmed", [])
|
||||
# if Warning.check(warning_name):
|
||||
# raise QtWarning(warning_name,
|
||||
# "Lot not confirmed, click yes to confirm and invoice")
|
||||
# continue
|
||||
if lot.invoice_line:
|
||||
continue
|
||||
lots.append(lot)
|
||||
|
||||
invoice_line = None
|
||||
if self.inv.type == 'purchase':
|
||||
Purchase._process_invoice([purchase],lots,action,self.inv.pp_pur)
|
||||
invoice_line = r.r_lot_p.invoice_line if r.r_lot_p.invoice_line else r.r_lot_p.invoice_line_prov
|
||||
else:
|
||||
if sale:
|
||||
Sale._process_invoice([sale],lots,action,self.inv.pp_sale)
|
||||
invoice_line = r.r_lot_p.invoice_line if r.r_lot_p.sale_invoice_line else r.r_lot_p.sale_invoice_line_prov
|
||||
self.message.invoice = invoice_line.invoice
|
||||
|
||||
return 'message'
|
||||
if lot.invoice_line:
|
||||
continue
|
||||
lots.append(lot)
|
||||
|
||||
invoice_line = None
|
||||
if self.inv.type == 'purchase':
|
||||
Purchase._process_invoice(purchases, lots, action, self.inv.pp_pur)
|
||||
for lot in lots:
|
||||
lot = Lot(lot.id)
|
||||
invoice_line = lot.invoice_line or lot.invoice_line_prov
|
||||
if invoice_line:
|
||||
break
|
||||
else:
|
||||
if sales:
|
||||
Sale._process_invoice(sales, lots, action, self.inv.pp_sale)
|
||||
for lot in lots:
|
||||
lot = Lot(lot.id)
|
||||
invoice_line = lot.sale_invoice_line or lot.sale_invoice_line_prov
|
||||
if invoice_line:
|
||||
break
|
||||
if not invoice_line:
|
||||
raise UserError("No invoice line was generated from the selected lots.")
|
||||
self.message.invoice = invoice_line.invoice
|
||||
|
||||
return 'message'
|
||||
|
||||
def default_message(self, fields):
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user