diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-10-03 07:05:14 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-10-03 07:05:14 +0000 |
| commit | 19e0be70679ed862453fedeba14fb4cdf02232e9 (patch) | |
| tree | 69b578c47cc17ae477c58d8bda718d823b998b20 | |
| parent | 78f205302c35cab2512971d64c8152aab2dcfa95 (diff) | |
| parent | d238f43442cc27db0d0c05bba99b42b41eaadf54 (diff) | |
Merged in production (pull request #128)
Production
| -rw-r--r-- | indoteknik_api/models/product_product.py | 15 | ||||
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 16 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 9 | ||||
| -rw-r--r-- | indoteknik_custom/models/solr/apache_solr_queue.py | 11 | ||||
| -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/account_move.xml | 6 | ||||
| -rw-r--r-- | indoteknik_custom/views/apache_solr_queue.xml | 16 | ||||
| -rwxr-xr-x | indoteknik_custom/views/product_template.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_move_line.xml | 24 |
15 files changed, 107 insertions, 37 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 78e32762..fdc90533 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -64,9 +64,9 @@ class ProductProduct(models.Model): price_discount = self._get_website_price_after_disc_and_tax() pricelists = { - 'tier1': self._get_pricelist_tier(1), - 'tier2': self._get_pricelist_tier(2), - 'tier3': self._get_pricelist_tier(3), + 'tier1': self._get_pricelist_tier1, + 'tier2': self._get_pricelist_tier2, + 'tier3': self._get_pricelist_tier3, } price_tier = pricelist.get_tier_name() @@ -214,6 +214,15 @@ class ProductProduct(models.Model): retValue = pl_item2.price_discount return retValue + def _get_pricelist_tier1(self): + return self._get_pricelist_tier(1) + + def _get_pricelist_tier2(self): + return self._get_pricelist_tier(2) + + def _get_pricelist_tier3(self): + return self._get_pricelist_tier(3) + def _get_pricelist_tier(self, tier_number): config_param_name = f'product.pricelist.tier{tier_number}' product_pricelist_tier = int(self.env['ir.config_parameter'].get_param(config_param_name)) 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/account_move.py b/indoteknik_custom/models/account_move.py index 18025b32..c3cd7ef9 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -2,6 +2,10 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError from datetime import timedelta, date import logging +import base64 +import PyPDF2 +import os +import re _logger = logging.getLogger(__name__) @@ -23,6 +27,14 @@ class AccountMove(models.Model): cost_centre_id = fields.Many2one('cost.centre', string='Cost Centre') analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') due_line = fields.One2many('due.extension.line', 'invoice_id', compute='_compute_due_line', string='Due Extension Lines') + no_faktur_pajak = fields.Char(string='No Faktur Pajak') + + @api.onchange('efaktur_id') + def change_efaktur_id(self): + for invoice in self: + if not invoice.efaktur_id: + return + invoice.no_faktur_pajak = invoice.efaktur_id.name def _compute_due_line(self): for invoice in self: 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/sale_order.py b/indoteknik_custom/models/sale_order.py index 71163fa4..e201496a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1,6 +1,6 @@ from odoo import fields, models, api, _ from odoo.exceptions import UserError -import logging, random, string, requests, math, json, re +import logging, random, string, requests, math, json, re _logger = logging.getLogger(__name__) @@ -80,6 +80,7 @@ class SaleOrder(models.Model): estimated_arrival_days = fields.Integer('Estimated Arrival Days', default=0) email = fields.Char(string='Email') picking_iu_id = fields.Many2one('stock.picking', 'Picking IU') + helper_by_id = fields.Many2one('res.users', 'Helper By') @api.model def action_multi_update_state(self): @@ -246,6 +247,12 @@ class SaleOrder(models.Model): minimum_amount = 20000000 for order in self: order.have_visit_service = self.amount_total > minimum_amount + + def write(self, values): + if self.env.user.id in [991, 20, 1180]: + values['helper_by_id'] = self.env.user.id + + return super(SaleOrder, self).write(values) def check_due(self): """To show the due amount and warning stage""" diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py index 6a5b480f..8dd7c273 100644 --- a/indoteknik_custom/models/solr/apache_solr_queue.py +++ b/indoteknik_custom/models/solr/apache_solr_queue.py @@ -1,5 +1,5 @@ from odoo import models, fields -from datetime import datetime +from datetime import datetime, timedelta import logging, time @@ -72,3 +72,12 @@ class ApacheSolrQueue(models.Model): if count == 0: self.create(payload) + def delete_weekly_solr(self, limit=500): + solr = self.search([ + ('execute_status', '=', 'success'), + ('execute_date', '>=', (datetime.utcnow() - timedelta(days=7))), + ], limit=limit) + for rec in solr: + rec.unlink() + + 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/account_move.xml b/indoteknik_custom/views/account_move.xml index 11558bf4..c45dab25 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -13,6 +13,12 @@ <field name="invoice_date" position="after"> <field name="payment_schedule" attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"/> </field> + <field name="efaktur_document" position="before"> + <field name="no_faktur_pajak" readonly="1"/> + </field> + <field name="efaktur_document" position="attributes"> + <attribute name="widget">pdf_viewer</attribute> + </field> <field name="invoice_user_id" position="after"> <field name="date_kirim_tukar_faktur"/> <field name="shipper_faktur_id"/> diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml index 3861fd20..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> @@ -58,6 +59,21 @@ </record> <data noupdate="1"> + <record id="cron_apache_solr_queue_delete" model="ir.cron"> + <field name="name">Solr Queue: Delete Weekly</field> + <field name="interval_number">14</field> + <field name="interval_type">minutes</field> + <field name="numbercall">-1</field> + <field name="doall" eval="False"/> + <field name="model_id" ref="model_apache_solr_queue"/> + <field name="code">model.delete_weekly_solr()</field> + <field name="state">code</field> + <field name="priority">65</field> + <field name="active">True</field> + </record> + </data> + + <data noupdate="1"> <record id="cron_apache_solr_queue_process" model="ir.cron"> <field name="name">Solr Queue: Process</field> <field name="interval_number">6</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/sale_order.xml b/indoteknik_custom/views/sale_order.xml index bc098f18..0d972ec1 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -41,6 +41,9 @@ <field name="source_id" position="attributes"> <attribute name="invisible">1</attribute> </field> + <field name="user_id" position="after"> + <field name="helper_by_id" readonly="1"/> + </field> <field name="analytic_account_id" position="after"> <field name="customer_type" attrs="{'required': ['|', ('create_date', '>', '2023-06-28'), ('create_date', '=', False)]}"/> <field name="npwp" placeholder='99.999.999.9-999.999' attrs="{'required': ['|', ('create_date', '>', '2023-06-28'), ('create_date', '=', False)]}"/> 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> |
