From 124aafcd00d3899eb54f9ec27556ce307c7656f4 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 27 Mar 2023 15:11:47 +0700 Subject: custom method for create bill from stock picking or goods receipt --- indoteknik_custom/models/stock_picking.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 77af676c..e63370f5 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -84,15 +84,17 @@ class StockPicking(models.Model): # Invoice values. invoice_vals = order._prepare_invoice() # Invoice line values (keep only necessary sections). - for line in order.order_line: - if line.display_type == 'line_section': + for line in self.move_ids_without_package: + po_line = self.env['purchase.order.line'].search([('order_id', '=', po.id), ('product_id', '=', line.product_id.id)], limit=1) + qty = line.product_uom_qty + if po_line.display_type == 'line_section': pending_section = line continue - if not float_is_zero(line.qty_to_invoice, precision_digits=precision): + if not float_is_zero(po_line.qty_to_invoice, precision_digits=precision): if pending_section: - invoice_vals['invoice_line_ids'].append((0, 0, pending_section._prepare_account_move_line())) + invoice_vals['invoice_line_ids'].append((0, 0, pending_section._prepare_account_move_line_from_mr(po_line, qty))) pending_section = None - invoice_vals['invoice_line_ids'].append((0, 0, line._prepare_account_move_line())) + invoice_vals['invoice_line_ids'].append((0, 0, line._prepare_account_move_line_from_mr(po_line, qty))) invoice_vals_list.append(invoice_vals) if not invoice_vals_list: -- cgit v1.2.3