diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-10-13 16:23:22 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-10-13 16:23:22 +0700 |
| commit | 47be053bafe8e212e7c98332666819e65428c4e3 (patch) | |
| tree | 19a7c4545989ff6a5d85968090346fdd4e268706 | |
| parent | c4b6e2d594b8cbd7d424673d04741a1a4cb2ff81 (diff) | |
| parent | 3acb428bfa048acb6d4d2d57e9d8720e77d08075 (diff) | |
Merge commit '3acb428bfa048acb6d4d2d57e9d8720e77d08075' into feature/rest-api
# Conflicts:
# indoteknik_custom/models/product_template.py
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/crm_lead.py | 25 | ||||
| -rw-r--r-- | indoteknik_custom/models/ir_attachment.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 58 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 14 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 2 |
6 files changed, 89 insertions, 23 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 415cd380..138321c6 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -26,3 +26,4 @@ from . import stock_picking_type from . import delivery_order from . import product_pricelist from . import users +from . import ir_attachment diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index 15ec4119..53ea176c 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models, api class CrmLead(models.Model): @@ -9,4 +9,27 @@ class CrmLead(models.Model): file_nib = fields.Binary(string="Nomor Induk Berusaha") file_tdp = fields.Binary(string="Tanda Daftar Perusahaan") file_siup = fields.Binary(string="Surat Izin Usaha Perdagangan") + body_html_lead = fields.Text('Body HTML', compute='compute_body_leads') + def compute_body_leads(self): + for lead in self: + mail_message = self.env['mail.message'].search([ + ('res_id', '=', lead.id), + ('model', '=', 'crm.lead'), + ('message_type', '=', 'email') + ], limit=1) + lead.body_html_lead = mail_message.body or '' + + def _update_tags_leads(self): + leads = self.env['crm.lead'].search([ + ('active', '=', True), + ('type', '=', 'lead'), + ('tag_ids', '=', False), + ], limit=1000) + for lead in leads: + tags = self.env['crm.tag'].search([('id', '>', 0)]) + input_tags = [] + for tag in tags: + if tag.name.lower() in lead.body_html_lead.lower(): + input_tags.append(tag.id) + lead.tag_ids = input_tags diff --git a/indoteknik_custom/models/ir_attachment.py b/indoteknik_custom/models/ir_attachment.py new file mode 100644 index 00000000..278eb938 --- /dev/null +++ b/indoteknik_custom/models/ir_attachment.py @@ -0,0 +1,12 @@ +from odoo import api, fields, models, _ +import logging + +_logger = logging.getLogger(__name__) + + +class Attachment(models.Model): + _inherit = 'ir.attachment' + + @api.autovacuum + def _gc_file_store(self): + _logger.info("filestore gc checked, removed - override")
\ No newline at end of file diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 5c75718a..8291a517 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -1,5 +1,8 @@ from odoo import fields, models, api from datetime import datetime, timedelta +import logging + +_logger = logging.getLogger(__name__) class ProductTemplate(models.Model): @@ -23,7 +26,8 @@ class ProductTemplate(models.Model): digits='Product Price', inverse='_set_product_lst_price', help="Web Price with pricelist_id = 1") qty_stock_vendor = fields.Float('QTY Stock Vendor', compute='_compute_qty_stock_vendor') - have_promotion_program = fields.Boolean('Have Promotion Program', compute='_have_promotion_program', help="Punya promotion program gak?") + have_promotion_program = fields.Boolean('Have Promotion Program', compute='_have_promotion_program', + help="Punya promotion program gak?") product_rating = fields.Float('Product Rating', help="Digunakan untuk sorting product di website") last_calculate_rating = fields.Datetime("Last Calculate Rating") web_price_sorting = fields.Float('Web Price Sorting', help='Hanya digunakan untuk sorting di web, harga tidak berlaku') @@ -36,9 +40,26 @@ class ProductTemplate(models.Model): def _compute_web_price(self): for template in self: - product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)],limit=1) - product_pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 1),('product_id', '=', product.id)],limit=1) - template.web_price = product_pricelist_item.fixed_price + 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: @@ -63,10 +84,14 @@ class ProductTemplate(models.Model): products = self.env['product.template'].search([ ('type', '=', 'product'), ('active', '=', True), - ('last_calculate_rating', '!=', False), - ], limit=5000) + ('last_calculate_rating', '=', False), + # ('id', '=', 22798), + ], limit=10000) + for product in products: - print("Calculate Rating Product ", product) + # print("Calculate Rating Product ", product) + _logger.info("Calculate Rating Product %s" % product.id) + product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1) rate = 0 if product.web_price: rate += 1 @@ -75,6 +100,10 @@ class ProductTemplate(models.Model): rate += 1 if product.image_128: rate += 1 + if product.website_description: + rate += 1 + if product_variant.qty_stock_vendor > 0: + rate += 1 product.product_rating = rate product.last_calculate_rating = current_time @@ -82,9 +111,11 @@ class ProductTemplate(models.Model): ('type', '=', 'product'), ('active', '=', True), ('last_calculate_rating', '<', delta_time), - ], limit=5000) + ], limit=10000) + for product in products: print("Calculate Rating Product OutOfDate", product) + product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1) rate = 0 if product.web_price: rate += 1 @@ -93,6 +124,10 @@ class ProductTemplate(models.Model): rate += 1 if product.image_128: rate += 1 + if product.website_description: + rate += 1 + if product_variant.qty_stock_vendor > 0: + rate += 1 product.product_rating = rate product.last_calculate_rating = current_time @@ -109,10 +144,11 @@ class ProductProduct(models.Model): def _compute_web_price(self): for product in self: - product_pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 1),('product_id', '=', product.id)],limit=1) + product_pricelist_item = self.env['product.pricelist.item'].search( + [('pricelist_id', '=', 1), ('product_id', '=', product.id)], limit=1) product.web_price = product_pricelist_item.fixed_price def _compute_stock_vendor(self): for product in self: - stock_vendor = self.env['stock.vendor'].search([('product_variant_id', '=', product.id)],limit=1) - product.qty_stock_vendor = stock_vendor.quantity+product.qty_available
\ No newline at end of file + stock_vendor = self.env['stock.vendor'].search([('product_variant_id', '=', product.id)], limit=1) + product.qty_stock_vendor = stock_vendor.quantity + product.qty_available diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 05e3e19f..a23a6d44 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -44,6 +44,10 @@ class SaleOrder(models.Model): for order in self: if order.state == 'cancel' or order.state == 'done' or order.state == 'sale': raise UserError("Status harus draft atau sent") + if not order.partner_id.property_payment_term_id: + raise UserError("Payment Term pada Master Data Customer harus diisi") + if not order.partner_id.active_limit: + raise UserError("Credit Limit pada Master Data Customer harus diisi") if not order.sales_tax_id: raise UserError("Tax di Header harus diisi") if not order.carrier_id: @@ -56,16 +60,6 @@ class SaleOrder(models.Model): raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara')) if not line.vendor_id or not line.purchase_price: raise UserError(_('Isi Vendor dan Harga Beli sebelum Request Approval')) - # if line.item_percent_margin <= 15 and not self.env.user.is_leader: # akbar or tyas - # approval2 += 1 - # elif line.item_percent_margin <= 25 and not self.env.user.is_leader and not self.env.user.is_sales_manager: - # approval1 += 1 - # if approval2 > 0: - # order.approval_status = 'pengajuan2' - # elif approval1 > 0: - # order.approval_status = 'pengajuan1' - # else: - # raise UserError("Bisa langsung Confirm") if order.total_percent_margin <= 15 and not self.env.user.is_leader: order.approval_status = 'pengajuan2' elif order.total_percent_margin <= 25 and not self.env.user.is_leader and not self.env.user.is_sales_manager: diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 47f9b4a4..53fac25e 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -19,7 +19,7 @@ </field> <field name="partner_shipping_id" position="after"> <field name="approval_status" /> - <field name="sales_tax_id" domain="[('type_tax_use','=','sale')]"/> + <field name="sales_tax_id" domain="[('type_tax_use','=','sale')]" required="1"/> <field name="carrier_id"/> </field> <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_total']" position="after"> |
