diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-02 16:45:07 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-10-02 16:45:07 +0700 |
| commit | 9fe4b646f1b1cda3d704a66dfbca3e935e38d96b (patch) | |
| tree | d22e810cbd1f0b409378ff363fb4427f89702481 | |
| parent | b0b5d0a094a1a87810b45bfcc52c17a82b73d3eb (diff) | |
Group by brand, sync to solr when validate stock picking, add new name function solr queue
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 16 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/apache_solr_queue.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_product.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 23 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_move.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/apache_solr_queue.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/product_template.xml | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_move_line.xml | 24 |
10 files changed, 42 insertions, 33 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 48434845..6ae60345 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -97,6 +97,7 @@ 'views/account_move_line.xml', 'views/sale_orders_multi_update.xml', 'views/quotation_so_multi_update.xml', + 'views/stock_move_line.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d35188b4..defcbdd4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -52,16 +52,7 @@ 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') - publish = fields.Boolean(string='Publish', default=True) - @api.constrains('active') - def constrains_active_publish(self): - if not self.active or self.type != 'product': - self.publish = False - else: - self.publish = True - - self._create_solr_queue('_sync_product_template_to_solr') def day_product_to_edit(self): day_products = [] @@ -193,7 +184,12 @@ class ProductTemplate(models.Model): def _compute_web_price(self): for template in self: - template.web_price = template.product_variant_ids[0].web_price + 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 def _have_promotion_program(self): for template in self: diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 8dd7c273..f66d356d 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -8,7 +8,7 @@ _logger = logging.getLogger(__name__) class ApacheSolrQueue(models.Model): _name = 'apache.solr.queue' - display_name = fields.Char('Display Name', compute="_compute_display_name") + display_name = fields.Char('Display Name', compute="_compute_display_name", store=True) res_model = fields.Char('Resource Model') res_id = fields.Integer('Resource ID') function_name = fields.Char('Function Name') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index 41af2d0e..16135e5e 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -63,7 +63,7 @@ class ProductProduct(models.Model): 'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly, 'attributes': [x.name for x in variant.product_template_attribute_value_ids], 'has_product_info_b': True, - 'publish_b': variant.product_tmpl_id.publish, + 'publish_b': variant.product_tmpl_id.active and variant.product_tmpl_id.type == 'product', }) 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 b4782d1c..e39530a7 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -23,23 +23,7 @@ class ProductTemplate(models.Model): 'function_name': function_name }) - @api.constrains('active', 'type') - def constrains_active(self): - for template in self: - template.publish = template.active and template.type == 'product' - self._create_solr_queue('_sync_product_template_to_solr') - - @api.constrains('publish') - def constrains_publish(self): - for template in self: - if template.active and template.type == 'product': - continue - template.product_variant_ids.publish = template.publish - self._create_solr_queue('_sync_product_template_to_solr') - - constrains_active._priority = 1 - - @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920') + @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'active') def _create_solr_queue_sync_product_template(self): self._create_solr_queue('_sync_product_template_to_solr') @@ -54,6 +38,9 @@ class ProductTemplate(models.Model): product._create_solr_queue('_sync_price_to_solr') product.solr_flag = 1 + def _sync_product_stock_to_solr(self): + self._sync_product_template_to_solr() + def _sync_product_template_to_solr(self): solr_model = self.env['apache.solr'] @@ -93,7 +80,7 @@ class ProductTemplate(models.Model): "category_name": category_name, "description_t": template.website_description or '', 'has_product_info_b': True, - 'publish_b': template.publish + 'publish_b': template.active and template.type == 'product' }) self.solr().add(docs=[document], softCommit=True) diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index bdbb0227..dade9a04 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import fields, models, api class StockMove(models.Model): @@ -72,3 +72,4 @@ class StockMoveLine(models.Model): _inherit = 'stock.move.line' line_no = fields.Integer('No', default=0) + manufacture = fields.Many2one('x_manufactures', string="Brands", related="product_id.x_manufacture", store=True) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 181f2a59..418649b1 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -307,7 +307,7 @@ class StockPicking(models.Model): for product in self.move_line_ids_without_package.product_id: if product: - product.product_tmpl_id._create_solr_queue('_sync_product_template_to_solr') + product.product_tmpl_id._create_solr_queue('_sync_product_stock_to_solr') res = super(StockPicking, self).button_validate() self.calculate_line_no() diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml index 9685ef06..13869b4c 100644 --- a/indoteknik_custom/views/apache_solr_queue.xml +++ b/indoteknik_custom/views/apache_solr_queue.xml @@ -28,6 +28,7 @@ <field name="res_model"/> <field name="res_id"/> <field name="function_name"/> + <field name="display_name" filter_domain="[('display_name', 'ilike', self)]"/> <filter string="Active Queue" name="active_queue" domain="[('execute_status', '=', False)]"/> </search> </field> diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index e09fee77..a3a23101 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -15,7 +15,6 @@ <field name="uom_po_id" position="after"> <field name="desc_update_solr" readonly="1" /> <field name="last_update_solr" readonly="1" /> - <field name="publish" /> </field> <page name="inventory" position="after"> <page string="Marketplace" name="marketplace"> diff --git a/indoteknik_custom/views/stock_move_line.xml b/indoteknik_custom/views/stock_move_line.xml new file mode 100644 index 00000000..757d2522 --- /dev/null +++ b/indoteknik_custom/views/stock_move_line.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <record id="stock_move_line_form_view_inherited" model="ir.ui.view"> + <field name="name">Stock Move Line</field> + <field name="model">stock.move.line</field> + <field name="inherit_id" ref="stock.view_move_line_form" /> + <field name="arch" type="xml"> + <field name="qty_done" position="after"> + <field name="manufacture"/> + </field> + </field> + </record> + + <record id="stock_move_line_tree_view_inherited" model="ir.ui.view"> + <field name="name">Stock Move Line</field> + <field name="model">stock.move.line</field> + <field name="inherit_id" ref="stock.view_move_line_tree" /> + <field name="arch" type="xml"> + <field name="product_id" position="after"> + <field name="manufacture"/> + </field> + </field> + </record> +</odoo> |
