From f421cc893699f8b6357d2d1f719db1bfd19c5bac Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 29 Apr 2024 11:06:30 +0700 Subject: add customer pareto status --- indoteknik_custom/models/res_partner.py | 4 ++++ indoteknik_custom/views/res_partner.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 5a62596d..f992628f 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -30,6 +30,10 @@ class ResPartner(models.Model): ('manager', 'Manager'), ('director', 'Director') ], string='Web Role') + pareto_status = fields.Selection([ + ('PR', 'Pareto Repeating'), + ('PNR', 'Pareto Non Repeating') + ]) def get_child_ids(self): partner = self.env['res.partner'].search([('id', '=', self.id)], limit=1) diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index e7b8517a..4c481e8a 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -15,6 +15,7 @@ + -- cgit v1.2.3 From cd629ed3f891910aa0e3effbe54372172cb30b46 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 30 Apr 2024 11:33:34 +0700 Subject: filter search matches so and matches so on stock picking --- indoteknik_custom/models/automatic_purchase.py | 8 +++++++ indoteknik_custom/models/purchase_order.py | 21 +++++++++++++++++++ indoteknik_custom/models/sale_order_line.py | 29 +++++--------------------- indoteknik_custom/models/stock_picking.py | 1 + indoteknik_custom/views/purchase_order.xml | 3 +++ indoteknik_custom/views/sale_order.xml | 1 + 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 @@ + @@ -158,6 +159,7 @@ + @@ -170,6 +172,7 @@ + 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 @@ + 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 @@ + -- cgit v1.2.3 From 181357dc01f84a47fd63209bc6a6dd4f085a718b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 30 Apr 2024 14:34:37 +0700 Subject: fix fulfillment so --- indoteknik_custom/models/purchase_order.py | 8 +++++++- indoteknik_custom/models/sale_order.py | 8 ++++---- indoteknik_custom/models/stock_picking.py | 2 +- indoteknik_custom/views/sale_order.xml | 3 +++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 8d9141dd..be971307 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -63,6 +63,12 @@ class PurchaseOrder(models.Model): 'name': self.name, 'partner_id': self.partner_id.id }) + + if self.sale_order_id: + sale_order = self.sale_order_id + else: + sale_order = self.sale_order + 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 { @@ -74,7 +80,7 @@ class PurchaseOrder(models.Model): '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, + 'sale_order': sale_order, } @api.model diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 6e32ca79..620953b9 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -99,14 +99,14 @@ class SaleOrder(models.Model): def _compute_fullfillment(self): for rec in self: - for fullfillment in rec.fullfillment_line: - fullfillment.unlink() - + rec.fullfillment_line.unlink() + for line in rec.order_line: line._compute_reserved_from() - + rec.compute_fullfillment = True + def _compute_eta_date(self): max_leadtime = 0 diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 43b3bfad..d98a2c82 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -84,7 +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') + sale_order = fields.Char(string='Matches SO', copy=False) def do_unreserve(self): res = super(StockPicking, self).do_unreserve() diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 3ecccf29..2cc406ea 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -187,6 +187,9 @@ + + + -- cgit v1.2.3 From 7bf5ed2c7892da0b56554b1d6fa8badd687080e7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 3 May 2024 10:28:31 +0700 Subject: change request add so on stock picking and fix bug double so on po --- indoteknik_custom/models/automatic_purchase.py | 10 +++--- indoteknik_custom/models/purchase_order.py | 2 ++ indoteknik_custom/models/purchase_order_line.py | 42 +++++++++++++++++++++++++ indoteknik_custom/models/purchasing_job.py | 1 + indoteknik_custom/models/stock_move.py | 1 + indoteknik_custom/models/stock_picking.py | 2 +- indoteknik_custom/views/purchase_order.xml | 1 + indoteknik_custom/views/stock_picking.xml | 3 ++ 8 files changed, 56 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 479d4e42..6478f2c9 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -253,7 +253,8 @@ class AutomaticPurchase(models.Model): 'product_uom_qty': line.qty_purchase, 'price_unit': line.last_price, 'taxes_id': [line.taxes_id.id] if line.taxes_id else None, - # 'so_line_id': [sales.sale_line_id.id for sales in sales_match], + 'so_line_id': sales_match[0].sale_line_id.id if sales_match else None, + 'so_id': sales_match[0].sale_id.id if sales_match else None } new_po_line = self.env['purchase.order.line'].create([param_line]) line.current_po_id = new_po.id @@ -279,9 +280,9 @@ class AutomaticPurchase(models.Model): ('sale_line_id.product_id', 'in', matches_so_product_ids), ]) - sale_ids = [] + sale_ids_set = set() for sale_order in matches_so: - sale_ids.append(str(sale_order.sale_id.name)) + sale_ids_set.add(str(sale_order.sale_id.name)) matches_so_line = { 'purchase_order_id': purchase_order.id, @@ -299,10 +300,9 @@ class AutomaticPurchase(models.Model): } po_matches_so_line = self.env['purchase.order.sales.match'].create([matches_so_line]) - sale_ids_str = ','.join(sale_ids) + sale_ids_str = ','.join(sale_ids_set) 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 be971307..5946399d 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1,5 +1,6 @@ from odoo import fields, models, api, _ from odoo.exceptions import AccessError, UserError, ValidationError +from dateutil.relativedelta import relativedelta from datetime import datetime, timedelta import logging from pytz import timezone, utc @@ -315,6 +316,7 @@ class PurchaseOrder(models.Model): 'qty_available_store': qty_available, # 'suggest': suggest, 'so_line_id': order_line.id, + 'so_id': order_line.order_id.id, } self.order_line.create(values) for order_line in self.order_line: diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 2eeb7d3e..8a3b3930 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -2,6 +2,7 @@ from odoo import fields, models, api, _ from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT import logging +from dateutil.relativedelta import relativedelta from datetime import datetime _logger = logging.getLogger(__name__) @@ -31,6 +32,7 @@ class PurchaseOrderLine(models.Model): suggest = fields.Char(string='Suggest') price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor') so_line_id = fields.Many2one('sale.order.line', string='ID SO Line') + so_id = fields.Many2one('sale.order', string='SO') 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') @@ -40,6 +42,46 @@ class PurchaseOrderLine(models.Model): delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') + def _prepare_stock_move_vals(self, picking, price_unit, product_uom_qty, product_uom): + self.ensure_one() + product = self.product_id.with_context(lang=self.order_id.dest_address_id.lang or self.env.user.lang) + description_picking = product._get_description(self.order_id.picking_type_id) + if self.product_description_variants: + description_picking += "\n" + self.product_description_variants + date_planned = self.date_planned or self.order_id.date_planned + + if self.so_id: + sale_id = self.so_id.id + else: + sale_id = self.so_line_id.order_id.id + + return { + # truncate to 2000 to avoid triggering index limit error + # TODO: remove index in master? + 'name': (self.name or '')[:2000], + 'product_id': self.product_id.id, + 'date': date_planned, + 'date_deadline': date_planned + relativedelta(days=self.order_id.company_id.po_lead), + 'location_id': self.order_id.partner_id.property_stock_supplier.id, + 'location_dest_id': (self.orderpoint_id and not (self.move_ids | self.move_dest_ids)) and self.orderpoint_id.location_id.id or self.order_id._get_destination_location(), + 'picking_id': picking.id, + 'partner_id': self.order_id.dest_address_id.id, + 'move_dest_ids': [(4, x) for x in self.move_dest_ids.ids], + 'state': 'draft', + 'purchase_line_id': self.id, + 'company_id': self.order_id.company_id.id, + 'price_unit': price_unit, + 'picking_type_id': self.order_id.picking_type_id.id, + 'group_id': self.order_id.group_id.id, + 'origin': self.order_id.name, + 'description_picking': description_picking, + 'propagate_cancel': self.propagate_cancel, + 'warehouse_id': self.order_id.picking_type_id.warehouse_id.id, + 'product_uom_qty': product_uom_qty, + 'product_uom': product_uom.id, + 'sale_id': sale_id, + } + @api.constrains('price_unit') def constrains_purchase_price(self): for line in self: diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index deec88d7..bdd35874 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -58,6 +58,7 @@ class PurchasingJob(models.Model): CASE WHEN vendor_id = 5571 THEN 27 WHEN vendor_id = 9688 THEN 397 + WHEN vendor_id = 35475 THEN 397 ELSE (CASE WHEN random() < 0.5 THEN 397 ELSE 1036 END) END AS user_id, vendor_id diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index dade9a04..9c991be3 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -5,6 +5,7 @@ class StockMove(models.Model): _inherit = 'stock.move' line_no = fields.Integer('No', default=0) + sale_id = fields.Many2one('sale.order', string='SO') def _prepare_account_move_line_from_mr(self, po_line, qty, move=False): po_line.ensure_one() diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index d98a2c82..9b4fffb1 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -81,7 +81,7 @@ class StockPicking(models.Model): status_printed = fields.Selection([ ('not_printed', 'Belum Print'), ('printed', 'Printed') - ], string='Printed?', copy=False) + ], string='Printed?', copy=False, tracking=True) 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='Matches SO', copy=False) diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index eedd9ec9..bb38715e 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -72,6 +72,7 @@ + diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index e4b7596f..90f662cc 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -88,6 +88,9 @@ + + + -- cgit v1.2.3 From bfed92c6802a8683a715766640f77cd7b3c80fab Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 3 May 2024 11:02:36 +0700 Subject: change request purchasing job --- indoteknik_custom/models/purchasing_job.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index bdd35874..86f8afcc 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -59,6 +59,7 @@ class PurchasingJob(models.Model): WHEN vendor_id = 5571 THEN 27 WHEN vendor_id = 9688 THEN 397 WHEN vendor_id = 35475 THEN 397 + WHEN vendor_id = 29712 THEN 397 ELSE (CASE WHEN random() < 0.5 THEN 397 ELSE 1036 END) END AS user_id, vendor_id -- cgit v1.2.3 From 39a5314e992cea3f8cf97127abcbd11cf27fa371 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 4 May 2024 09:18:50 +0700 Subject: change request sale order line --- indoteknik_custom/models/sale_order_line.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 7fb4a024..8fb34328 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -33,9 +33,11 @@ class SaleOrderLine(models.Model): @api.onchange('product_uom', 'product_uom_qty') def product_uom_change(self): + if not self.product_uom or not self.product_id: + self.price_unit = 0.0 + return - super(SaleOrderLine, self).product_uom_change() - return False + self.price_unit = self.price_unit def _compute_qty_reserved(self): for line in self: -- cgit v1.2.3 From 1edb9ae0da36e33b1e0b1124ce5c6f9a515b732b Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 7 May 2024 11:32:49 +0700 Subject: add potensi pareto repeating in partner --- indoteknik_custom/models/res_partner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index f992628f..81f49cdf 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -32,6 +32,7 @@ class ResPartner(models.Model): ], string='Web Role') pareto_status = fields.Selection([ ('PR', 'Pareto Repeating'), + ('PPR', 'Potensi Pareto Repeating'), ('PNR', 'Pareto Non Repeating') ]) -- cgit v1.2.3 From 71a36d6f5bb8688f0d8907818fb90026c5dac5d3 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 7 May 2024 11:41:52 +0700 Subject: add status non pareto --- indoteknik_custom/models/res_partner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 81f49cdf..abb7f739 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -33,7 +33,8 @@ class ResPartner(models.Model): pareto_status = fields.Selection([ ('PR', 'Pareto Repeating'), ('PPR', 'Potensi Pareto Repeating'), - ('PNR', 'Pareto Non Repeating') + ('PNR', 'Pareto Non Repeating'), + ('NP', 'Non Pareto') ]) def get_child_ids(self): -- cgit v1.2.3 From cb9ae6021dd4858372ed78d16ab491226c95f1d2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 10 May 2024 11:27:07 +0700 Subject: change request qty onhand and fix bug name apo --- indoteknik_custom/models/automatic_purchase.py | 8 +++++--- indoteknik_custom/models/product_template.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 6478f2c9..af09abf0 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -183,8 +183,10 @@ class AutomaticPurchase(models.Model): def create_po_by_vendor(self, vendor_id): current_time = datetime.now() - # if not self.apo_type =='reordering': - # self.check_qty_po() + if not self.apo_type =='reordering': + name = "/PJ/" + else: + name = "/A/" PRODUCT_PER_PO = 20 @@ -218,7 +220,7 @@ class AutomaticPurchase(models.Model): # i start from zero (0) for i in range(page): new_po = self.env['purchase.order'].create([param_header]) - new_po.name = new_po.name + "/PJ/" + str(i + 1) + new_po.name = new_po.name + name + str(i + 1) self.env['automatic.purchase.match'].create([{ 'automatic_purchase_id': self.id, diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 4bab2cad..8494e18a 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -410,7 +410,7 @@ class ProductProduct(models.Model): for product in self: qty_onhand = self.env['stock.quant'].search([ ('product_id', '=', product.id), - ('location_id', '=', 57) + ('location_id', 'in', [57, 83]) ]) qty = sum(qty_onhand.mapped('quantity')) product.qty_onhand_bandengan = qty -- cgit v1.2.3