diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-12-14 11:32:25 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-12-14 11:32:25 +0700 |
| commit | bb2a3647ac1f5885bc6481ce10bfcd91813bfe81 (patch) | |
| tree | 8a4c56c0141611e08e2ad42df00b1106c9569644 | |
| parent | e6770e132602c094197fbd6d9becc2bbc9c2d8e0 (diff) | |
change suggest to virtual column
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 8 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 22 | ||||
| -rw-r--r-- | indoteknik_custom/models/requisition.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 13 |
4 files changed, 30 insertions, 25 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index f95e01c9..177a4744 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -211,16 +211,16 @@ class PurchaseOrder(models.Model): if order_line.product_id.id and order_line.product_id.id not in products_exception: qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty - suggest = 'harus beli' - if qty_available > order_line.product_qty: - suggest = 'masih cukup' + # suggest = 'harus beli' + # if qty_available > order_line.product_qty: + # suggest = 'masih cukup' values = { 'order_id': self.id, 'product_id': order_line.product_id.id, 'name': order_line.product_id.display_name, 'product_qty': order_line.product_qty, 'qty_available_store': qty_available, - 'suggest': suggest, + # 'suggest': suggest, 'so_line_id': order_line.id, } self.order_line.create(values) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index eced5d43..5e1c7b5f 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -22,18 +22,26 @@ class PurchaseOrderLine(models.Model): help="Total % Margin in Sales Order Header") delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') line_no = fields.Integer('No', default=0) - qty_available = fields.Float('Qty Available', compute='compute_qty_stock') - qty_onhand = fields.Float('Qty On Hand', compute='compute_qty_stock') - qty_incoming = fields.Float('Qty Incoming', compute='compute_qty_stock') - qty_outgoing = fields.Float('Qty Outgoing', compute='compute_qty_stock') + qty_available = fields.Float('Qty Available', compute='_compute_qty_stock') + qty_onhand = fields.Float('Qty On Hand', compute='_compute_qty_stock') + qty_incoming = fields.Float('Qty Incoming', compute='_compute_qty_stock') + qty_outgoing = fields.Float('Qty Outgoing', compute='_compute_qty_stock') qty_available_store = fields.Float(string='Available') - suggest = fields.Char(string='Suggest') + suggest = fields.Char(string='Suggest', compute='_compute_suggest_purchasing') price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') indent = fields.Boolean(string='Indent', help='centang ini jika barang indent') is_ltc = fields.Boolean(string='Sudah di LTC', default=False, help='centang ini jika barang sudah di LTC') note = fields.Char(string='Note') + def _compute_suggest_purchasing(self): + print(1) + for line in self: + if line.qty_available < 0: + line.suggest = 'harus beli' + else: + line.suggest = 'masih cukup' + def compute_price_vendor(self): for line in self: purchase_pricelist = self.env['purchase.pricelist'].search([ @@ -48,7 +56,7 @@ class PurchaseOrderLine(models.Model): else: line.price_vendor = 0 - def compute_qty_stock(self): + def _compute_qty_stock(self): for line in self: line.qty_available = line.product_id.virtual_available line.qty_onhand = line.product_id.qty_available @@ -57,7 +65,7 @@ class PurchaseOrderLine(models.Model): @api.onchange('product_id') def _onchange_product_custom(self): - self.compute_qty_stock() + self._compute_qty_stock() # Override method from addons/purchase/models/purchase.py @api.onchange('product_qty', 'product_uom') diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 6408c4fd..7ceff6e5 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -176,10 +176,10 @@ class Requisition(models.Model): 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' + # 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] @@ -191,8 +191,8 @@ class Requisition(models.Model): 'product_uom_qty': product.qty_purchase, 'price_unit': product.price_unit, 'taxes_id': tax, - 'qty_available_store': qty_available, - 'suggest': suggest, + # 'qty_available_store': qty_available, + # 'suggest': suggest, } new_line = self.env['purchase.order.line'].create([param_line]) product.current_po_id = new_po.id diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index b5a9b4ad..4cf83dd4 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -13,12 +13,6 @@ class="oe_highlight oe_edit_only" attrs="{'invisible': ['|', ('sale_order_id', '=', False), ('state', 'not in', ['draft'])]}" /> - <button name="calculate_line_no" - string="Line No" - type="object" - class="oe_highlight oe_edit_only" - attrs="{'invisible': ['|', ('state', '=', 'purchase'), ('state', '=', 'done')]}" - /> </div> <button id="draft_confirm" position="after"> <button name="po_approve" @@ -57,8 +51,11 @@ <attribute name="options">{'no_create': True}</attribute> </field> <field name="product_qty" position="before"> - <field name="qty_available_store" readonly="1" /> - <field name="suggest" readonly="1" /> + <field name="qty_onhand" readonly="1" optional="hide"/> + <field name="qty_incoming" readonly="1" optional="hide"/> + <field name="qty_outgoing" readonly="1" optional="hide"/> + <field name="qty_available" readonly="1" optional="hide"/> + <field name="suggest" readonly="1" optional="hide"/> </field> <field name="price_unit" position="after"> <field name="price_vendor" attrs="{'readonly': 1}" optional="hide"/> |
