From f3e37cbd999409929703ebddef5b487a7daf4940 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 16 Oct 2023 13:46:05 +0700 Subject: fix error base pricelist --- indoteknik_custom/models/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index fb8561e7..b1930ada 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -403,7 +403,7 @@ class ProductProduct(models.Model): for product in self: pricelist_id = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default_price_id_v2') - domain = [('pricelist_id', '=', pricelist_id or 17022), ('product_id', '=', product.id)] + domain = [('pricelist_id.id', '=', pricelist_id or 17022), ('product_id.id', '=', product.id)] product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1) if product_pricelist_item.base_pricelist_id: -- cgit v1.2.3 From 6d9ac5debfc7f8809e627900555301aac6ab6083 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 16 Oct 2023 15:24:28 +0700 Subject: Add qty sold field and solr data --- indoteknik_custom/models/product_template.py | 15 ++++++++++++++- indoteknik_custom/models/solr/product_product.py | 1 + indoteknik_custom/models/solr/product_template.py | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index b1930ada..da1a111f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -52,7 +52,11 @@ class ProductTemplate(models.Model): help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru') seq_new_product = fields.Integer(string='Seq New Product', help='Urutan Sequence New Product') is_edited = fields.Boolean(string='Is Edited') - + qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') + + def _get_qty_sold(self): + for rec in self: + rec.qty_sold = sum(x.qty_sold for x in rec.product_variant_ids) def day_product_to_edit(self): day_products = [] @@ -331,6 +335,15 @@ class ProductProduct(models.Model): qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan') sla_version = fields.Integer(string="SLA Version", default=0) is_edited = fields.Boolean(string='Is Edited') + qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold') + + def _get_qty_sold(self): + for product in self: + order_line = self.env['sale.order.line'].search([ + ('order_id.state', 'in', ['done', 'sale']), + ('product_id', '=', product.id) + ]) + product.qty_sold = sum(x.product_uom_qty for x in order_line) def day_product_to_edit(self): day_products = [] diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 31a0026d..720be7fa 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -64,6 +64,7 @@ class ProductProduct(models.Model): 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, 'publish_b': variant.product_tmpl_id.active and variant.product_tmpl_id.type == 'product', + 'qty_sold_f': variant.qty_sold }) self.solr().add(docs=[document], softCommit=True) diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index d7439bcb..cc8d4bf2 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -80,7 +80,8 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': template.active and template.type == 'product' + 'publish_b': template.active and template.type == 'product', + "qty_sold_f": template.qty_sold }) self.solr().add(docs=[document], softCommit=True) -- cgit v1.2.3 From db4547a746308fe1498e36208c1821168183a7e2 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 17 Oct 2023 09:48:32 +0700 Subject: add column note and description in purchase order --- indoteknik_custom/models/automatic_purchase.py | 5 +++-- indoteknik_custom/models/purchase_order.py | 1 + indoteknik_custom/views/purchase_order.xml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index e21b411d..990d3cc5 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -30,12 +30,13 @@ class AutomaticPurchase(models.Model): for vendor in vendor_ids: param_header = { 'partner_id': vendor['partner_id'][0], - 'partner_ref': 'Automatic PO', + # 'partner_ref': 'Automatic PO', '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 + 'date_order': current_time, + 'note_description': 'Automatic PO' } # new_po = self.env['purchase.order'].create([param_header]) products_vendors = self.env['automatic.purchase.line'].search([ diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 8ad25228..5e4617d4 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -47,6 +47,7 @@ class PurchaseOrder(models.Model): count_line_product = fields.Float('Total Item', compute='compute_count_line_product') note_description = fields.Char(string='Note', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') has_active_invoice = fields.Boolean(string='Has Active Invoice', compute='_compute_has_active_invoice') + description = fields.Char(string='Description', help='bisa diisi sebagai informasi indent barang tertentu atau apapun') def _compute_has_active_invoice(self): for order in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index adcaaf43..a0614a56 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -75,6 +75,7 @@ + -- cgit v1.2.3 From c136e5d34dfef4ae95c366b5c52197863b967919 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 17 Oct 2023 09:54:42 +0700 Subject: Fix product virtual rating calculation --- indoteknik_custom/models/product_template.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index da1a111f..d8a2aae2 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -188,12 +188,7 @@ class ProductTemplate(models.Model): def _compute_web_price(self): for template in self: - products = self.env['product.product'].search([ - ('product_tmpl_id', '=', template.id), - ('active', 'in', [True, False]) - ]) - for variants in products: - template.web_price = variants[0].web_price + template.web_price = template.product_variant_id.web_price def _have_promotion_program(self): for template in self: -- cgit v1.2.3