summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-03-24 09:32:19 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-03-24 09:32:19 +0700
commit98e81e0c84f6625aab09bb3b5c5e5137d68c61a0 (patch)
tree849cc9b0cc11c5b83a97db21fd3c0dfa56b7f449
parent3aa64db9c10d0fcb8009e9e6f942672a12669099 (diff)
development create bill from receipt
-rw-r--r--indoteknik_custom/models/stock_move.py23
-rw-r--r--indoteknik_custom/models/stock_picking.py23
-rw-r--r--indoteknik_custom/views/stock_picking.xml2
3 files changed, 38 insertions, 10 deletions
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index 22a73010..8be05630 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -6,6 +6,29 @@ class StockMove(models.Model):
line_no = fields.Integer('No', default=0)
+ def _prepare_lines_bill(self, po_line):
+ res = {
+ 'display_type': po_line.display_type,
+ 'sequence': po_line.sequence,
+ 'name': '%s: %s' % (po_line.order_id.name, po_line.name),
+ 'product_id': self.product_id.id,
+ 'product_uom_id': self.product_uom.id,
+ 'quantity': self.quantity_done,
+ 'price_unit': po_line.price_unit,
+ 'tax_ids': [(6, 0, po_line.taxes_id.ids)],
+ 'analytic_account_id': po_line.account_analytic_id.id,
+ 'analytic_tag_ids': [(6, 0, po_line.analytic_tag_ids.ids)],
+ 'purchase_line_id': po_line.id,
+ }
+
+ res.update({
+ 'move_id': self.move_id,
+ 'currency_id': self.move_id.currency_id,
+ 'date_maturity': self.move_id.invoice_date_due,
+ 'partner_id': self.move_id.partner_id.id,
+ })
+ return res
+
def _create_account_move_line(self, credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost):
self.ensure_one()
if self.picking_id.is_internal_use:
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 77af676c..f59534d2 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -84,16 +84,21 @@ 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':
- pending_section = line
- continue
- if not float_is_zero(line.qty_to_invoice, precision_digits=precision):
- if pending_section:
- invoice_vals['invoice_line_ids'].append((0, 0, pending_section._prepare_account_move_line()))
- pending_section = None
- invoice_vals['invoice_line_ids'].append((0, 0, line._prepare_account_move_line()))
+ # for line in order.order_line:
+ # if line.display_type == 'line_section':
+ # pending_section = line
+ # continue
+ # if not float_is_zero(line.qty_to_invoice, precision_digits=precision):
+ # if pending_section:
+ # invoice_vals['invoice_line_ids'].append((0, 0, pending_section._prepare_lines_bill()))
+ # pending_section = None
+ # invoice_vals['invoice_line_ids'].append((0, 0, line._prepare_lines_bill()))
+
+ for in_line in self.move_lines:
+ invoice_vals['invoice_line_ids'].append((0,0, in_line._prepare_lines_bill))
invoice_vals_list.append(invoice_vals)
+ print('---cek disini---')
+ print(invoice_vals_list)
if not invoice_vals_list:
raise UserError(_('There is no invoiceable line. If a product has a control policy based on received quantity, please make sure that a quantity has been received.'))
diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml
index 0ff79ea8..e4e9f722 100644
--- a/indoteknik_custom/views/stock_picking.xml
+++ b/indoteknik_custom/views/stock_picking.xml
@@ -34,7 +34,7 @@
<button name="action_create_invoice_from_mr"
string="Create Bill"
type="object"
- attrs="{'invisible': [('state', '!=', 'done')]}"
+ attrs="{'invisible': ['|', ('state', '!=', 'done'), ('name', 'ilike', 'out')]}"
/>
</button>
<field name="backorder_id" position="after">