diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-04-29 06:30:50 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-04-29 06:30:50 +0000 |
| commit | 1c0c7be74b11371299bead2626840b3ebc2632f7 (patch) | |
| tree | 14e43d531e420cedb3f69956c2e5b75e81a2345e | |
| parent | 09c3b3a6a706d176f61bf89fc7acb690650b528c (diff) | |
| parent | a5727ae0dd3f82bf22b888125d924520833838b4 (diff) | |
Merged in feature/request-by-abl (pull request #140)
Feature/request by abl
27 files changed, 197 insertions, 26 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 3f31011c..957d49c7 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -357,12 +357,17 @@ class SaleOrder(controller.Controller): 'carrier_id': params['value']['carrier_id'], 'delivery_service_type': params['value']['delivery_service_type'], 'customer_type': 'nonpkp', - 'npwp': '0' + 'npwp': '0', + 'user_id': 1180 # User ID: Ima Nurhikmah } if params['value']['type'] == 'sale_order': parameters['approval_status'] = 'pengajuan1' sale_order = request.env['sale.order'].create([parameters]) sale_order.onchange_partner_contact() + + sales_partner = sale_order.partner_id.user_id + if sales_partner and sales_partner not in [25]: # 25: System + parameters['user_id'] = sales_partner.id user_id = params['value']['user_id'] user_cart = request.env['website.user.cart'] diff --git a/indoteknik_api/models/__init__.py b/indoteknik_api/models/__init__.py index 8c85938c..892d2657 100644 --- a/indoteknik_api/models/__init__.py +++ b/indoteknik_api/models/__init__.py @@ -9,4 +9,3 @@ from . import sale_order from . import x_manufactures from . import website_content from . import coupon_program -from . import res_partner diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py deleted file mode 100644 index 57200ac1..00000000 --- a/indoteknik_api/models/res_partner.py +++ /dev/null @@ -1,14 +0,0 @@ -from odoo import models - - -class ResPartner(models.Model): - _inherit = 'res.partner' - - def get_main_parent(self): - partner = self - - while partner.parent_id: - partner = partner.parent_id - - return partner -
\ No newline at end of file diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 969fd79f..c98834bf 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -8,7 +8,6 @@ class SaleOrder(models.Model): APPROVAL_STEP = { 'company': 1, 'cust_manager': 2, - 'cust_procurement': 3, 'cust_director': 3 } diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 1bfaa722..f1f3f9b6 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -121,6 +121,7 @@ 'views/cust_commision.xml', 'views/stock_quant.xml', 'views/purchasing_job_state.xml', + 'views/res_partner_site.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 92a0f232..160d2af3 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -110,3 +110,4 @@ from . import cust_commision from . import report_stock_forecasted from . import web_logging from . import sales_order_fullfillment +from . import res_partner_site diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index ca64d8b0..dae1c6a4 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -406,6 +406,7 @@ class AutomaticPurchase(models.Model): 'qty_so': sale.outgoing, 'qty_po': line.qty_purchase, 'purchase_price': price_so.purchase_price, + 'purchase_tax_id': price_so.purchase_tax_id.id if price_so.purchase_tax_id.id else None, }]) def _create_sync_purchasing_job(self, jobs): @@ -558,7 +559,7 @@ class AutomaticPurchaseSalesMatch(models.Model): qty_so = fields.Float(string='Qty SO') qty_po = fields.Float(string='Qty PO') purchase_price = fields.Float(string='Purchase Price SO') - + purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) class SyncPurchasingJob(models.Model): _name = 'sync.purchasing.job' diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index e60fe9a7..7ec2cecc 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -152,6 +152,7 @@ class CustomerCommision(models.Model): account_name = fields.Char(string='Account Name', tracking=3) bank_account = fields.Char(string='Account No', tracking=3) note_transfer = fields.Char(string='Keterangan') + brand_ids = fields.Many2many('x_manufactures', string='Brands') # add status for type of commision, fee, rebate / cashback # include child or not? @@ -250,7 +251,7 @@ class CustomerCommision(models.Model): partners = rec.partner_ids for partner in partners: - brand = [92, 10, 89, 12, 324, 11] + brand = [int(brand) for brand in rec.brand_ids] where = [ ('move_id.move_type', '=', 'out_invoice'), ('move_id.state', '=', 'posted'), diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index e8721142..9ffd607c 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -23,6 +23,15 @@ class CrmLead(models.Model): operator_name = fields.Char('Operator Name', help='Operator yang membalas') order_id = fields.Many2one('sale.order', string='Sales Order', help='Link ke sales order id') + @api.model + def create(self, vals): + rec = super(CrmLead, self).create(vals) + + if rec.email_from == 'api.noreply@altama.co.id' and rec.name.startswith('INDOTEKNIK|ODOO|'): + rec.user_id = 20 # User ID: Nabila Rahmawati + + return rec + @api.onchange('user_id') def _change_salesperson_so(self): if self.order_id: diff --git a/indoteknik_custom/models/cust_commision.py b/indoteknik_custom/models/cust_commision.py index da345f04..c3105cfd 100644 --- a/indoteknik_custom/models/cust_commision.py +++ b/indoteknik_custom/models/cust_commision.py @@ -21,6 +21,7 @@ class CustCommision(models.Model): ('cashback', 'Cashback'), ('rebate', 'Rebate'), ], string='Commision Type', required=True) + brand_ids = fields.Many2many('x_manufactures', string='Brands', help='Voucher appplied only for brand') @api.constrains('partner_id') def _check_partner_id(self): diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py index 9e3daf20..f84619ad 100644 --- a/indoteknik_custom/models/logbook_sj.py +++ b/indoteknik_custom/models/logbook_sj.py @@ -40,7 +40,8 @@ class LogbookSJ(models.TransientModel): 'carrier_id': stock.carrier_id.id, 'tracking_no': stock.delivery_tracking_no, 'partner_id': parent_id, - 'report_logbook_sj_id': report_logbook.id + 'report_logbook_sj_id': report_logbook.id, + 'note': line.note } self.env['report.logbook.sj.line'].create([data]) @@ -69,6 +70,7 @@ class LogbookSJLine(models.TransientModel): logbook_sj_id = fields.Many2one('logbook.sj', string='Logbook SJ') partner_id = fields.Many2one('res.partner', string='Customer') picking_id = fields.Many2one('res.partner', string='Customer') + note = fields.Char(string='Note') @api.onchange('name') def onchange_name(self): diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 624415e3..2eeb7d3e 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -42,12 +42,13 @@ class PurchaseOrderLine(models.Model): @api.constrains('price_unit') def constrains_purchase_price(self): - matches_so = self.env['purchase.order.sales.match'].search([ - ('purchase_order_id', '=', self.order_id.id), - ('product_id', '=', self.product_id.id), - ]) + for line in self: + matches_so = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', line.order_id.id), + ('product_id', '=', line.product_id.id), + ]) - matches_so.sale_line_id.purchase_price = self.price_unit + matches_so.sale_line_id.purchase_price = line.price_unit @api.constrains('product_qty') def constrains_product_qty(self): diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py index f34835ae..093848b5 100644 --- a/indoteknik_custom/models/report_logbook_sj.py +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -67,3 +67,4 @@ class ReportLogbookSJLine(models.Model): sale_id = fields.Many2one('sale.order', string='Sale Order') report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') not_exist = fields.Boolean(string='Not Exist') + note = fields.Char(string='Note') diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index ad6fd6ec..bc8e2b0d 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -31,6 +31,33 @@ class ResPartner(models.Model): ('director', 'Director'), ('procurement', 'Procurement'), ], string='Web Role') + site_id = fields.Many2one('res.partner.site', string='Site') + main_parent_id = fields.Many2one('res.partner', string='Main Parent', compute='_compute_main_parent_id') + + @api.onchange('site_id') + def _onchange_site_id(self): + for rec in self: + if not rec.site_id: continue + site = rec.site_id + + rec.street = site.street + rec.street2 = site.street2 + rec.city = site.city + rec.state_id = site.state_id + rec.country_id = site.country_id + rec.zip = site.zip + + def get_main_parent(self): + partner = self + + while partner.parent_id: + partner = partner.parent_id + + return partner + + def _compute_main_parent_id(self): + for partner in self: + partner.main_parent_id = partner.get_main_parent() def get_child_ids(self): partner = self.env['res.partner'].search([('id', '=', self.id)], limit=1) diff --git a/indoteknik_custom/models/res_partner_site.py b/indoteknik_custom/models/res_partner_site.py new file mode 100644 index 00000000..00850c97 --- /dev/null +++ b/indoteknik_custom/models/res_partner_site.py @@ -0,0 +1,20 @@ +from odoo import models, fields, api + +class ResPartnerSite(models.Model): + _name = 'res.partner.site' + + partner_ids = fields.One2many('res.partner', 'site_id', string='Partners') + partner_id = fields.Many2one('res.partner', string='Partner') + name = fields.Char(string='Name') + street = fields.Char(string='Street') + street2 = fields.Char(string='Street 2') + city = fields.Char(string='City') + state_id = fields.Many2one('res.country.state', string='State') + country_id = fields.Many2one('res.country', string='Country') + zip = fields.Char(string='Zip') + + @api.model + def create(self, vals): + rec = super(ResPartnerSite, self).create(vals) + rec.partner_id = rec.partner_id.get_main_parent() + return rec
\ No newline at end of file diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 1c85914e..055b545a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -459,6 +459,12 @@ class SaleOrder(models.Model): raise UserError("Bisa langsung Confirm") + def send_notif_to_salesperson(self): + for rec in self: + if not rec.partner_id.main_parent_id.use_so_approval: continue + template = self.env.ref('indoteknik_custom.mail_template_sale_order_notification_to_salesperson') + template.send_mail(rec.id, force_send=True) + def action_confirm(self): for order in self: order._validate_order() @@ -484,6 +490,7 @@ class SaleOrder(models.Model): order.approval_status = 'approved' order._set_sppkp_npwp_contact() order.calculate_line_no() + order.send_notif_to_salesperson() # order.order_line.get_reserved_from() res = super(SaleOrder, self).action_confirm() diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 9cd226fb..36aea1ed 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -75,3 +75,8 @@ class PromotionProgramLine(models.Model): for record in records: record._create_solr_queue('_sync_to_solr') record.solr_flag = 1 + + def action_sync_to_solr(self): + rec_ids = self.env.context.get('active_ids', []) + recs = self.search([('id', 'in', rec_ids)]) + recs._create_solr_queue('_sync_to_solr')
\ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 6d265748..f03e0118 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -109,4 +109,5 @@ access_report_logbook_sj_line,access.report.logbook.sj.line,model_report_logbook access_cust_commision,access.cust.commision,model_cust_commision,,1,1,1,1 access_report_stock_report_product_product_replenishment,access.report.stock.report_product_product_replenishment,model_report_stock_report_product_product_replenishment,,1,1,1,1 access_sales_order_fullfillment,access.sales.order.fullfillment,model_sales_order_fullfillment,,1,1,1,1 -access_purchasing_job_state,access.purchasing.job.state,model_purchasing_job_state,,1,1,1,1
\ No newline at end of file +access_purchasing_job_state,access.purchasing.job.state,model_purchasing_job_state,,1,1,1,1 +access_res_partner_site,access.res_partner_site,model_res_partner_site,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index 71d292c9..974fbd17 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -53,6 +53,7 @@ <field name="partner_invoice_id" readonly="1"/> <field name="salesperson_id" readonly="1"/> <field name="purchase_price" readonly="1"/> + <field name="purchase_tax_id" readonly="1"/> <field name="product_id" readonly="1"/> <field name="qty_so" readonly="1"/> <field name="qty_po" readonly="1"/> diff --git a/indoteknik_custom/views/cust_commision.xml b/indoteknik_custom/views/cust_commision.xml index be58a68c..f080bc60 100644 --- a/indoteknik_custom/views/cust_commision.xml +++ b/indoteknik_custom/views/cust_commision.xml @@ -12,6 +12,7 @@ <field name="achieve_1st"/> <field name="achieve_2nd"/> <field name="commision_type"/> + <field name="brand_ids"/> </tree> </field> </record> @@ -31,6 +32,7 @@ <field name="achieve_1st"/> <field name="achieve_2nd"/> <field name="commision_type"/> + <field name="brand_ids"/> </group> </group> </sheet> diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index 600ad192..4b74cd34 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -12,6 +12,7 @@ <field name="commision_percent"/> <field name="commision_amt" readonly="1"/> <field name="status" readonly="1"/> + <field name="brand_ids" widget="many2many_tags"/> </tree> </field> </record> @@ -63,6 +64,7 @@ </div> <field name="date_to"/> <field name="commision_type"/> + <field name="brand_ids" widget="many2many_tags"/> <field name="notification" readonly="1"/> <field name="status" readonly="1"/> <field name="total_dpp"/> diff --git a/indoteknik_custom/views/logbook_sj.xml b/indoteknik_custom/views/logbook_sj.xml index 9eb9aa12..0fa65be5 100644 --- a/indoteknik_custom/views/logbook_sj.xml +++ b/indoteknik_custom/views/logbook_sj.xml @@ -22,6 +22,7 @@ <field name="carrier_id" readonly="1"/> <field name="tracking_no" readonly="1"/> <field name="partner_id" readonly="1"/> + <field name="note"/> </tree> </field> </sheet> diff --git a/indoteknik_custom/views/promotion/promotion_program_line.xml b/indoteknik_custom/views/promotion/promotion_program_line.xml index 025ea35a..7c8e403d 100644 --- a/indoteknik_custom/views/promotion/promotion_program_line.xml +++ b/indoteknik_custom/views/promotion/promotion_program_line.xml @@ -73,6 +73,14 @@ action="promotion_program_line_action" /> + <record id="ir_actions_server_promotion_program_line_sync_to_solr" model="ir.actions.server"> + <field name="name">Sync to Solr</field> + <field name="model_id" ref="indoteknik_custom.model_promotion_program_line"/> + <field name="binding_model_id" ref="indoteknik_custom.model_promotion_program_line"/> + <field name="state">code</field> + <field name="code">model.action_sync_to_solr()</field> + </record> + <data noupdate="1"> <record id="cron_program_line_solr_flag_solr" model="ir.cron"> <field name="name">Program Line: Solr Flag to Queue</field> diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml index 8221b419..687464f0 100644 --- a/indoteknik_custom/views/report_logbook_sj.xml +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -31,6 +31,7 @@ <field name="picking_id"/> <field name="sale_id"/> <field name="not_exist"/> + <field name="note"/> </tree> </field> </record> diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index e7b8517a..f79b684e 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -31,6 +31,11 @@ <field name="use_only_ready_stock" attrs="{'invisible': [('parent_id', '!=', False), ('company_type', '!=', 'company')]}" /> <field name="web_role" attrs="{'invisible': ['|', ('parent_id', '=', False), ('company_type', '=', 'company')]}" /> </field> + <xpath expr="//field[@name='child_ids']/form//field[@name='name']" position="before"> + <field name="parent_id" invisible="1" /> + <field name="main_parent_id" invisible="1" /> + <field name="site_id" attrs="{'readonly': [('parent_id', '=', False)]}" domain="[('partner_id', '=', main_parent_id)]" context="{'default_partner_id': active_id}" /> + </xpath> </field> </record> </data> diff --git a/indoteknik_custom/views/res_partner_site.xml b/indoteknik_custom/views/res_partner_site.xml new file mode 100644 index 00000000..df4c8c4a --- /dev/null +++ b/indoteknik_custom/views/res_partner_site.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="res_partner_site_form_view" model="ir.ui.view"> + <field name="name">Partner Site</field> + <field name="model">res.partner.site</field> + <field name="arch" type="xml"> + <form> + <group> + <group> + <field name="name" required="1" /> + <field name="partner_id" invisible="1" /> + <label for="street" string="Address" /> + <div class="o_address_format" name="div_address"> + <field name="street" placeholder="Street..." class="o_address_street"/> + <field name="street2" placeholder="Street 2..." class="o_address_street"/> + <field name="city" placeholder="City" class="o_address_city"/> + <field name="state_id" class="o_address_state" placeholder="State" options="{'no_open': True, 'no_quick_create': True}" context="{'country_id': country_id, 'default_country_id': country_id, 'zip': zip}"/> + <field name="zip" placeholder="ZIP" class="o_address_zip"/> + <field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/> + </div> + </group> + </group> + </form> + </field> + </record> + </data> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 23905ef7..77740dd0 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -306,4 +306,60 @@ </field> </record> </data> + + <data> + <record id="mail_template_sale_order_notification_to_salesperson" model="mail.template"> + <field name="name">Sale Order: Notification to Salesperson</field> + <field name="model_id" ref="sale.model_sale_order"/> + <field name="subject">Konsolidasi Pengiriman</field> + <field name="email_from">sales@indoteknik.com</field> + <field name="email_to">${object.user_id.login | safe}</field> + <field name="body_html" type="html"> + <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;"> + <tr><td align="center"> + <table border="0" cellpadding="0" cellspacing="0" width="590" style="font-size: 13px; padding: 16px; background-color: white; color: #454748; border-collapse:separate;"> + <!-- HEADER --> + <tbody> + <tr> + <td align="center" style="min-width: 590px;"> + <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;"> + <tr> + <td valign="middle"> + <span></span> + </td> + </tr> + + <tr> + <td colspan="2" style="text-align:center;"> + <hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" /> + </td> + </tr> + </table> + </td> + </tr> + <!-- CONTENT --> + <tr> + <td align="center" style="min-width: 590px;"> + <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;"> + <tr><td style="padding-bottom: 24px;">Dear ${object.user_id.name},</td></tr> + + <tr><td style="padding-bottom: 16px;">Terdapat pesanan ${object.name} dari ${object.partner_id.main_parent_id.name} untuk site ${object.partner_shipping_id.site_id.name | safe} dengan total pembelian ${object.grand_total}</td></tr> + + <tr> + <td style="text-align:center;"> + <hr width="100%" + style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;" /> + </td> + </tr> + </table> + </td> + </tr> + <!-- CONTENT --> + </tbody> + </table> + </td></tr> + </table> + </field> + </record> + </data> </odoo>
\ No newline at end of file |
