diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-03 13:25:40 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-03 13:25:40 +0700 |
| commit | 585ce08efde0f61ba6462b8e303cb08615f0cf33 (patch) | |
| tree | e09bf1d4787c1bbe2d2ced4fc16c554ade520dd8 | |
| parent | 4bd636d8b79c45878f13865d04f726f0729996ef (diff) | |
| parent | dbe24b9cd600c7b5a9d0587f80a782ed93c9a761 (diff) | |
Merge branch 'production' into iman/pengajuan-tempo
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 76 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 4 |
5 files changed, 61 insertions, 24 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 2e80beec..4d186568 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -1,4 +1,4 @@ -from odoo import fields, models, api +from odoo import fields, models, api, tools, _ from datetime import datetime, timedelta, date from odoo.exceptions import UserError import logging @@ -484,33 +484,38 @@ class ProductProduct(models.Model): def _get_qty_incoming_bandengan(self): for product in self: - qty_incoming = self.env['stock.move'].search([ - ('product_id', '=', product.id), - ('location_dest_id', 'in', [57, 83]), - ('state', 'not in', ['done', 'cancel']) - ]) - qty = sum(qty_incoming.mapped('product_uom_qty')) + qty = self.env['v.move.outstanding'].read_group( + domain=[ + ('product_id', '=', product.id), + ('location_dest_id', 'in', [57, 83]), + ], + fields=['qty_need'], + groupby=[] + )[0].get('qty_need', 0.0) product.qty_incoming_bandengan = qty def _get_qty_incoming_bandengan_with_exclude(self): for product in self: - qty_incoming = self.env['stock.move'].search([ - ('product_id', '=', product.id), - ('location_dest_id', 'in', [57, 83]), - ('state', 'not in', ['done', 'cancel']) - ]) - qty = sum(qty_incoming.mapped('product_uom_qty')) + qty = self.env['v.move.outstanding'].read_group( + domain=[ + ('product_id', '=', product.id), + ('location_dest_id', 'in', [57, 83]), + ], + fields=['qty_need'], + groupby=[] + )[0].get('qty_need', 0.0) product.qty_incoming_bandengan = qty def _get_qty_outgoing_bandengan(self): for product in self: - qty_incoming = self.env['stock.move'].search([ - ('product_id', '=', product.id), - ('location_dest_id', '=', 5), - ('location_id', 'in', [57, 83]), - ('state', 'not in', ['done', 'cancel']) - ]) - qty = sum(qty_incoming.mapped('product_uom_qty')) + qty = self.env['v.move.outstanding'].read_group( + domain=[ + ('product_id', '=', product.id), + ('location_id', 'in', [57, 83]), + ], + fields=['qty_need'], + groupby=[] + )[0].get('qty_need', 0.0) product.qty_outgoing_bandengan = qty def _get_qty_onhand_bandengan(self): @@ -600,3 +605,34 @@ class ProductProduct(models.Model): ('end_date', '>=', current_time) ], limit=1) return pricelist + + +class OutstandingMove(models.Model): + _name = 'v.move.outstanding' + _auto = False + _rec_name = 'id' + + id = fields.Integer(string='ID') + product_id = fields.Many2one('product.product', string='Product') + reference = fields.Char(string='Reference', help='Nomor Dokumen terkait') + qty_need = fields.Float(string='Qty Need', help='Qty yang akan outgoing / incoming') + location_id = fields.Many2one('stock.location', string='Location', help='Lokasi asal') + location_dest_id = fields.Many2one('stock.location', string='Location To', help='Lokasi tujuan') + + def init(self): + # where clause 'state in' follow the origin of outgoing and incoming odoo + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + CREATE OR REPLACE VIEW %s AS + select sm.id, sm.reference, sm.product_id, + sm.product_uom_qty as qty_need, + sm.location_id, sm.location_dest_id + from stock_move sm + where 1=1 + and sm.state in( + 'waiting', + 'confirmed', + 'assigned', + 'partially_available' + ) + """ % self._table) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 04fafa69..a31ff569 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -33,7 +33,7 @@ class SaleOrderLine(models.Model): qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') product_available_quantity = fields.Float(string='Qty pickup by user',) reserved_from = fields.Char(string='Reserved From', copy=False) - item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') + item_percent_margin_without_deduction = fields.Float('Margin Without Deduction', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') md_vendor_id = fields.Many2one('res.partner', string='MD Vendor', readonly=True) margin_md = fields.Float(string='Margin MD') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 17dd5766..03b10cdb 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -539,7 +539,7 @@ class StockPicking(models.Model): qty_onhand = check_qty_per_inventory(self, line.product_id, line.location_id) if line.qty_done > qty_onhand: - raise UserError('Quantity Done melebihi Quantity Onhand') + raise UserError(f'{line.product_id.display_name} : Quantity Done melebihi Quantity Onhand') def button_validate(self): if not self.env.user.is_logistic_approver and self.env.context.get('active_model') == 'stock.picking': diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index e55bd2d9..d4a1ea90 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -146,6 +146,7 @@ access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 access_v_requisition_match_po,access.v.requisition.match.po,model_v_requisition_match_po,,1,1,1,1 access_approval_retur_picking,access.approval.retur.picking,model_approval_retur_picking,,1,1,1,1 access_sales_order_fulfillment_v2,access.sales.order.fulfillment.v2,model_sales_order_fulfillment_v2,,1,1,1,1 +access_v_move_outstanding,access.v.move.outstanding,model_v_move_outstanding,,1,1,1,1 access_va_multi_approve,access.va.multi.approve,model_va_multi_approve,,1,1,1,1 access_va_multi_reject,access.va.multi.reject,model_va_multi_reject,,1,1,1,1 diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index e12130de..703b4d49 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -263,9 +263,9 @@ <page string="Matches PO" name="page_matches_po" invisible="1"> <field name="order_sales_match_line" readonly="1"/> </page> - <page string="Fullfillment" name="page_sale_order_fullfillment"> + <!-- <page string="Fullfillment" name="page_sale_order_fullfillment"> <field name="fullfillment_line" readonly="1"/> - </page> + </page> --> <page string="Fulfillment v2" name="page_sale_order_fullfillment2"> <field name="fulfillment_line_v2" readonly="1"/> </page> |
