diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-16 11:43:41 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-16 11:43:41 +0700 |
| commit | 4cec68ef40a33071d949c33c1592c146779f1abe (patch) | |
| tree | f3715f3eb91fed73777da1126c05915bacd60e0e | |
| parent | b734cf901978f1fda1afd45dd654659b7f7a2971 (diff) | |
add delivered validation system parameter and add sequence for new product template scheduler
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 48 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/views/x_manufactures.xml | 1 |
3 files changed, 33 insertions, 20 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 9f0410f4..ef0ead1b 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -46,12 +46,34 @@ class ProductTemplate(models.Model): material = fields.Char(string='Material') is_new_product = fields.Boolean(string='Produk Baru', 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') # def write(self, vals): # if 'solr_flag' not in vals and self.solr_flag == 1: # vals['solr_flag'] = 2 # return super().write(vals) + def update_new_product(self): + current_time = datetime.now() + delta_time = current_time - timedelta(days=30) + + #current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') + delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') + + products = self.env['product.template'].search([ + ('type', '=', 'product'), + ('active', '=', True), + ('product_rating', '>', 3), + ('create_date', '>=', delta_time), + ], limit=1000) + + seq = 0 + for product in products: + seq += 1 + product.is_new_product = True + product.seq_new_product = seq + _logger.info('Updated New Product %s' % product.name) + def update_internal_reference(self): templates_without_variant = self.env['product.template'].search([ ('default_code', '=', False), @@ -92,33 +114,21 @@ class ProductTemplate(models.Model): for template in self: product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1) - # product_pricelist_default = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default') - # product_pricelist_disc = self.env['product.pricelist.item'].search([ - # ('pricelist_id', '=', product_pricelist_default.int()), - # ('product_id', '=', product.id)], limit=1) - # disc = product_pricelist_disc.price_discount - product_pricelist_item = self.env['product.pricelist.item'].search([ ('pricelist_id', '=', 1), ('product_id', '=', product.id)], limit=1) price = product_pricelist_item.fixed_price - # - # if not disc and not price: - # template.web_price = 0 - # elif not disc: template.web_price = price - # else: - # price_disc = price - (price * disc / 100) - # template.web_price = price_disc def _have_promotion_program(self): for template in self: - domain = [ - ('rule_products_domain', 'ilike', template.x_manufacture.x_name), - ('active', '=', True) - ] - coupon_program = self.env['coupon.program'].search(domain, limit=1) - if coupon_program: + product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1) + + product_pricelist_item = self.env['product.pricelist.item'].search([ + ('pricelist_id', '=', 4), + ('product_id', '=', product.id)], limit=1) + discount = product_pricelist_item.price_discount + if discount: template.have_promotion_program = True else: template.have_promotion_program = False diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 84a374c5..d19214d2 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -145,8 +145,10 @@ class StockPicking(models.Model): continue raise UserError('Sudah pernah dikirim kalender') + is_delivered_validation = self.env['ir.config_parameter'].get_param( + 'stock_picking.qty_delivered_validation') for line in self.move_line_ids_without_package: - if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing': + if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing' and is_delivered_validation == 'Y': if line.move_id.sale_line_id.qty_delivered + line.qty_done > line.move_id.sale_line_id.product_uom_qty: raise UserError("Qty Delivered akan lebih dari Qty SO") diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index c7cedd9c..cc8fd10c 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -65,6 +65,7 @@ <field name="solr_flag"/> <field name="product_rating"/> <field name="is_new_product"/> + <field name="seq_new_product"/> </tree> </field> </page> |
