summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-31 16:23:11 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-31 16:23:11 +0700
commit0c21532c6aa129cbafa80b6b67caf5526688b7d8 (patch)
tree39eea036454837b318272bd45237bb66c680688b
parentc5bcd2528adefe9312b482b0b7dcedef370056c0 (diff)
fix error
-rw-r--r--indoteknik_custom/models/requisition.py170
1 files changed, 85 insertions, 85 deletions
diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py
index d6b33044..f3dd5093 100644
--- a/indoteknik_custom/models/requisition.py
+++ b/indoteknik_custom/models/requisition.py
@@ -108,93 +108,93 @@ class Requisition(models.Model):
line.current_po_line_id = new_po_line.id
return po_ids
- def create_po_from_requisition(self):
- if not self.requisition_lines:
- raise UserError('Tidak ada Lines, belum bisa create PO')
- if self.is_po:
- raise UserError('Sudah pernah di create PO')
- current_time = datetime.now()
- vendor_ids = self.env['requisition.line'].read_group([('requisition_id', '=', self.id), ('partner_id', '!=', False)], fields=['partner_id'], groupby=['partner_id'])
+ # def create_po_from_requisition(self):
+ # if not self.requisition_lines:
+ # raise UserError('Tidak ada Lines, belum bisa create PO')
+ # if self.is_po:
+ # raise UserError('Sudah pernah di create PO')
+ # current_time = datetime.now()
+ # vendor_ids = self.env['requisition.line'].read_group([('requisition_id', '=', self.id), ('partner_id', '!=', False)], fields=['partner_id'], groupby=['partner_id'])
- counter_po_number = 0
- po_ids = []
- for vendor in vendor_ids:
- param_header = {
- 'partner_id': vendor['partner_id'][0],
- # 'partner_ref': self.sale_order_id.name,
- 'currency_id': 12,
- 'user_id': self.env.user.id,
- 'company_id': 1, # indoteknik dotcom gemilang
- 'picking_type_id': 28, # indoteknik bandengan receipts
- 'date_order': current_time,
- 'sale_order_id': self.sale_order_id.id,
- 'note_description': 'from Purchase Requisition'
- }
- param_requisition_line = [
- ('requisition_id', '=', self.id),
- ('partner_id', '=', vendor['partner_id'][0]),
- ('qty_purchase', '>', 0)
- ]
- # new_po = self.env['purchase.order'].create([param_header])
- products_vendors = self.env['requisition.line'].search(, order='brand_id')
- count = brand_id = 0
-
- for product in products_vendors:
- if count > 200 or brand_id != product.brand_id.id:
- continue
-
- count = 0
- counter_po_number += 1
- new_po = self.env['purchase.order'].create([param_header])
- new_po.name = new_po.name + "/R/"+str(counter_po_number)
- self.env['requisition.purchase.match'].create([{
- 'requisition_id': self.id,
- 'order_id': new_po.id
- }])
- po_ids.append(new_po.id)
- self.env.cr.commit()
- # else:
- # new_po = self.env['purchase.order'].create([param_header])
- brand_id = product.brand_id.id
- count += 10
-
- # qty_available = product.product_id.qty_onhand_bandengan + product.product_id.qty_incoming_bandengan - product.product_id.outgoing_qty
- # suggest = 'harus beli'
- # if qty_available > product.qty_purchase:
- # suggest = 'masih cukup'
-
- tax = [22]
-
- param_line = {
+ # counter_po_number = 0
+ # po_ids = []
+ # for vendor in vendor_ids:
+ # param_header = {
+ # 'partner_id': vendor['partner_id'][0],
+ # # 'partner_ref': self.sale_order_id.name,
+ # 'currency_id': 12,
+ # 'user_id': self.env.user.id,
+ # 'company_id': 1, # indoteknik dotcom gemilang
+ # 'picking_type_id': 28, # indoteknik bandengan receipts
+ # 'date_order': current_time,
+ # 'sale_order_id': self.sale_order_id.id,
+ # 'note_description': 'from Purchase Requisition'
+ # }
+ # param_requisition_line = [
+ # ('requisition_id', '=', self.id),
+ # ('partner_id', '=', vendor['partner_id'][0]),
+ # ('qty_purchase', '>', 0)
+ # ]
+ # # new_po = self.env['purchase.order'].create([param_header])
+ # products_vendors = self.env['requisition.line'].search(, order='brand_id')
+ # count = brand_id = 0
+
+ # for product in products_vendors:
+ # if count > 200 or brand_id != product.brand_id.id:
+ # continue
+
+ # count = 0
+ # counter_po_number += 1
+ # new_po = self.env['purchase.order'].create([param_header])
+ # new_po.name = new_po.name + "/R/"+str(counter_po_number)
+ # self.env['requisition.purchase.match'].create([{
+ # 'requisition_id': self.id,
+ # 'order_id': new_po.id
+ # }])
+ # po_ids.append(new_po.id)
+ # self.env.cr.commit()
+ # # else:
+ # # new_po = self.env['purchase.order'].create([param_header])
+ # brand_id = product.brand_id.id
+ # count += 10
+
+ # # qty_available = product.product_id.qty_onhand_bandengan + product.product_id.qty_incoming_bandengan - product.product_id.outgoing_qty
+ # # suggest = 'harus beli'
+ # # if qty_available > product.qty_purchase:
+ # # suggest = 'masih cukup'
+
+ # tax = [22]
+
+ # param_line = {
- 'sequence': count,
- 'product_id': product.product_id.id,
- 'product_qty': product.qty_purchase,
- 'product_uom_qty': product.qty_purchase,
- 'price_unit': product.price_unit,
- 'taxes_id': tax,
- # 'qty_available_store': qty_available,
- # 'suggest': suggest,
- }
- new_line = self.env['purchase.order.line'].create([param_line])
- if new_po:
- new_line.write({
- 'order_id': new_po.id,
- })
- product.current_po_id = new_po.id
- product.current_po_line_id = new_line.id
- _logger.info('Create PO Line %s' % product.product_id.name)
- # self.notification = self.notification + ' %s' % new_po.name
- self.is_po = True
- if po_ids:
- return {
- 'name': _('Purchase Order'),
- 'view_mode': 'tree,form',
- 'res_model': 'purchase.order',
- 'target': 'current',
- 'type': 'ir.actions.act_window',
- 'domain': [('id', 'in', po_ids)],
- }
+ # 'sequence': count,
+ # 'product_id': product.product_id.id,
+ # 'product_qty': product.qty_purchase,
+ # 'product_uom_qty': product.qty_purchase,
+ # 'price_unit': product.price_unit,
+ # 'taxes_id': tax,
+ # # 'qty_available_store': qty_available,
+ # # 'suggest': suggest,
+ # }
+ # new_line = self.env['purchase.order.line'].create([param_line])
+ # if new_po:
+ # new_line.write({
+ # 'order_id': new_po.id,
+ # })
+ # product.current_po_id = new_po.id
+ # product.current_po_line_id = new_line.id
+ # _logger.info('Create PO Line %s' % product.product_id.name)
+ # # self.notification = self.notification + ' %s' % new_po.name
+ # self.is_po = True
+ # if po_ids:
+ # return {
+ # 'name': _('Purchase Order'),
+ # 'view_mode': 'tree,form',
+ # 'res_model': 'purchase.order',
+ # 'target': 'current',
+ # 'type': 'ir.actions.act_window',
+ # 'domain': [('id', 'in', po_ids)],
+ # }
class RequisitionLine(models.Model):
_name = 'requisition.line'