diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-30 11:33:34 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-04-30 11:33:34 +0700 |
| commit | cd629ed3f891910aa0e3effbe54372172cb30b46 (patch) | |
| tree | e2d2f6fdb3976360760b12abea9d5ecbef37ceec | |
| parent | ca03f0119e33dd62adbf998106378d8e0f4096b6 (diff) | |
filter search matches so and matches so on stock picking
| -rw-r--r-- | indoteknik_custom/models/automatic_purchase.py | 8 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 21 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 29 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 1 |
7 files changed, 40 insertions, 24 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index dae1c6a4..479d4e42 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -279,7 +279,10 @@ class AutomaticPurchase(models.Model): ('sale_line_id.product_id', 'in', matches_so_product_ids), ]) + sale_ids = [] for sale_order in matches_so: + sale_ids.append(str(sale_order.sale_id.name)) + matches_so_line = { 'purchase_order_id': purchase_order.id, 'sale_id': sale_order.sale_id.id, @@ -295,6 +298,11 @@ class AutomaticPurchase(models.Model): 'margin_so': sale_order.sale_line_id.item_percent_margin } po_matches_so_line = self.env['purchase.order.sales.match'].create([matches_so_line]) + + sale_ids_str = ','.join(sale_ids) + + purchase_order.sale_order = sale_ids_str + self.create_sales_order_purchase_match(purchase_order) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index caad90d3..8d9141dd 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -55,6 +55,27 @@ class PurchaseOrder(models.Model): revisi_po = fields.Boolean(string='Revisi', tracking=3) from_apo = fields.Boolean(string='From APO', tracking=3) approval_edit_line = fields.Boolean(string='Approval Edit Line', tracking=3) + sale_order = fields.Char(string='Sale Order') + + def _prepare_picking(self): + if not self.group_id: + self.group_id = self.group_id.create({ + 'name': self.name, + 'partner_id': self.partner_id.id + }) + if not self.partner_id.property_stock_supplier.id: + raise UserError(_("You must set a Vendor Location for this partner %s", self.partner_id.name)) + return { + 'picking_type_id': self.picking_type_id.id, + 'partner_id': self.partner_id.id, + 'user_id': False, + 'date': self.date_order, + 'origin': self.name, + 'location_dest_id': self._get_destination_location(), + 'location_id': self.partner_id.property_stock_supplier.id, + 'company_id': self.company_id.id, + 'sale_order': self.sale_order, + } @api.model def action_multi_cancel(self): diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 39366028..7fb4a024 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -31,30 +31,11 @@ class SaleOrderLine(models.Model): qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') reserved_from = fields.Char(string='Reserved From', copy=False) - # def get_reserved_from(self): - # for line in self: - # current_stock = self.env['stock.quant'].search([ - # ('product_id', '=', line.product_id.id), - # ('location_id', '=', line.order_id.warehouse_id.lot_stock_id.id) - # ]) - - # po_stock = self.env['purchase.order.line'].search([ - # ('product_id', '=', line.product_id.id), - # ('order_id.sale_order_id', '=', line.order_id.id), - # ('state', '=', 'done') - # ]) - - # available_quantity = current_stock.available_quantity if current_stock else 0 - # product_qty = po_stock.product_qty if po_stock else 0 - - # if available_quantity >= line.product_uom_qty: - # line.reserved_from = 'From Stock' - # elif product_qty >= line.product_uom_qty: - # line.reserved_from = 'From PO' - # elif (available_quantity + product_qty) >= line.product_uom_qty: - # line.reserved_from = 'From Stock and PO' - # else: - # line.reserved_from = None + @api.onchange('product_uom', 'product_uom_qty') + def product_uom_change(self): + + super(SaleOrderLine, self).product_uom_change() + return False def _compute_qty_reserved(self): for line in self: diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c2508660..43b3bfad 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -84,6 +84,7 @@ class StockPicking(models.Model): ], string='Printed?', copy=False) date_unreserve = fields.Datetime(string="Date Unreserved", copy=False, tracking=True) date_availability = fields.Datetime(string="Date Availability", copy=False, tracking=True) + sale_order = fields.Char(string='Sale Order') def do_unreserve(self): res = super(StockPicking, self).do_unreserve() diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 33603216..eedd9ec9 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -28,6 +28,7 @@ </button> <field name="date_order" position="before"> <field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/> + <field name="sale_order"/> <field name="approval_status"/> <field name="amount_total_without_service"/> </field> @@ -158,6 +159,7 @@ <field name="arch" type="xml"> <field name="name" position="after"> <field name="sale_order_id" string="Sale Order"/> + <field name="sale_order" string="Matches Sale Order"/> </field> </field> </record> @@ -170,6 +172,7 @@ <field name="arch" type="xml"> <field name="name" position="after"> <field name="sale_order_id" string="Sale Order"/> + <field name="sale_order" string="Matches Sale Order"/> </field> </field> </record> diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 23905ef7..3ecccf29 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -49,6 +49,7 @@ </field> <field name="user_id" position="after"> <field name="helper_by_id" readonly="1"/> + <field name="compute_fullfillment"/> </field> <field name="tag_ids" position="after"> <field name="eta_date" readonly="1"/> diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index a8772906..e4b7596f 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -61,6 +61,7 @@ <field name="origin" position="after"> <field name="status_printed"/> <field name="purchase_id"/> + <field name="sale_order"/> <field name="date_doc_kirim"/> <field name="summary_qty_operation"/> <field name="count_line_operation"/> |
