summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_move.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-03-27 15:11:47 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-03-27 15:11:47 +0700
commit124aafcd00d3899eb54f9ec27556ce307c7656f4 (patch)
tree5443107aa4e08d8cd73e22afd35207f0c1306b31 /indoteknik_custom/models/stock_move.py
parent4ab719732e495ad2eb42ee8ea1c63dc875b98f1d (diff)
custom method for create bill from stock picking or goods receipt
Diffstat (limited to 'indoteknik_custom/models/stock_move.py')
-rw-r--r--indoteknik_custom/models/stock_move.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py
index 22a73010..bdbb0227 100644
--- a/indoteknik_custom/models/stock_move.py
+++ b/indoteknik_custom/models/stock_move.py
@@ -6,6 +6,39 @@ class StockMove(models.Model):
line_no = fields.Integer('No', default=0)
+ def _prepare_account_move_line_from_mr(self, po_line, qty, move=False):
+ po_line.ensure_one()
+ aml_currency = move and move.currency_id or po_line.currency_id
+ date = move and move.date or fields.Date.today()
+ res = {
+ 'display_type': po_line.display_type,
+ 'sequence': po_line.sequence,
+ 'name': '%s: %s' % (po_line.order_id.name, po_line.name),
+ 'product_id': po_line.product_id.id,
+ 'product_uom_id': po_line.product_uom.id,
+ 'quantity': qty,
+ 'price_unit': po_line.currency_id._convert(po_line.price_unit, aml_currency, po_line.company_id, date, round=False),
+ '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,
+ }
+ if not move:
+ return res
+
+ if self.currency_id == move.company_id.currency_id:
+ currency = False
+ else:
+ currency = move.currency_id
+
+ res.update({
+ 'move_id': move.id,
+ 'currency_id': currency and currency.id or False,
+ 'date_maturity': move.invoice_date_due,
+ 'partner_id': move.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: