diff options
| -rw-r--r-- | indoteknik_api/controllers/api_v1/sale_order.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 14 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchasing_job.py | 45 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchasing_job_multi_update.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 25 | ||||
| -rw-r--r-- | indoteknik_custom/models/shipment_group.py | 81 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/ir_sequence.xml | 10 | ||||
| -rw-r--r-- | indoteknik_custom/views/mail_template_efaktur.xml | 4 | ||||
| -rw-r--r-- | indoteknik_custom/views/report_logbook_bill.xml | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/report_logbook_sj.xml | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/shipment_group.xml | 69 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 5 |
18 files changed, 226 insertions, 47 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index ea2d381c..ee295b55 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -368,7 +368,7 @@ class SaleOrder(controller.Controller): 'flash_sale': params['value']['flash_sale'], 'customer_type': 'nonpkp', 'npwp': '0', - 'user_id': 1180 # User ID: Ima Nurhikmah + 'user_id': 20 # User ID: Nabila Rahmawati } if params['value']['type'] == 'sale_order': parameters['approval_status'] = 'pengajuan1' diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 67f16800..4a37414f 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -135,6 +135,7 @@ 'views/logbook_bill.xml', 'views/report_logbook_bill.xml', 'views/sale_order_multi_uangmuka_penjualan.xml', + 'views/shipment_group.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 ffd1b645..10f4acee 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -120,3 +120,4 @@ from . import purchase_order_multi_uangmuka2 from . import logbook_bill from . import report_logbook_bill from . import sale_order_multi_uangmuka_penjualan +from . import shipment_group diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index fbadd2aa..a7010bbe 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -78,18 +78,20 @@ class AccountMove(models.Model): }) return attachment - # @api.constrains('efaktur_document') + @api.constrains('efaktur_document') def send_scheduled_email(self): # Get the records for which emails need to be sent records = self.search([('id', 'in', self.ids)]) + template = self.env.ref('indoteknik_custom.mail_template_efaktur_document') for record in records: - attachment = self.generate_attachment(record) - email_values = { - 'attachment_ids': [(4, attachment.id)] - } - template.send_mail(record.id, email_values=email_values, force_send=True) + if record.invoice_payment_term_id.id == 26: + attachment = self.generate_attachment(record) + email_values = { + 'attachment_ids': [(4, attachment.id)] + } + template.send_mail(record.id, email_values=email_values, force_send=True) @api.model def create(self, vals): diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 4a029441..32ddf1e5 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -487,7 +487,6 @@ class PurchaseOrder(models.Model): for purchasing_job in purchasing_job_state: purchasing_job.unlink() - def _send_po_not_sync(self): # Mengirim data ke model Po Sync Price jika harga po dan purchase pricelist tidak singkron for line in self.order_line: diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 40061d22..373e469a 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -41,13 +41,14 @@ class PurchasingJob(models.Model): } def init(self): - query = """ + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" CREATE OR REPLACE VIEW %s AS ( WITH latest_purchase_orders AS ( SELECT pol.product_id, po.user_id, - ROW_NUMBER() OVER (PARTITION BY pol.product_id ORDER BY po.create_date DESC) AS order_rank + ROW_NUMBER() OVER (PARTITION BY po.partner_id ORDER BY po.create_date DESC) AS order_rank FROM purchase_order po RIGHT JOIN purchase_order_line pol ON pol.order_id = po.id LEFT JOIN res_partner rp ON rp.id = po.partner_id @@ -69,26 +70,11 @@ class PurchasingJob(models.Model): LEFT JOIN sale_order_line sol ON sol.id = vso.sale_line_id ) AS sub WHERE sub.vendor_id IS NOT NULL - ), - unique_sub AS ( - SELECT DISTINCT - vso.product_id, - sol.vendor_id - FROM v_sales_outstanding vso - LEFT JOIN sale_order_line sol ON sol.id = vso.sale_line_id - WHERE sol.vendor_id IS NOT NULL - ), - latest_po_filtered AS ( - SELECT - product_id, - user_id - FROM latest_purchase_orders - WHERE order_rank = 1 ) SELECT pmp.product_id AS id, pmp.product_id, - MAX(sub.vendor_id) AS vendor_id, + sub.vendor_id, pmp.brand, pmp.item_code, pmp.product, @@ -98,23 +84,30 @@ class PurchasingJob(models.Model): pmp.action, MAX(pjs.status_apo) AS status_apo, MAX(pjs.note) AS note, - MAX(ru.user_id) AS purchase_representative_id + ru.user_id AS purchase_representative_id FROM v_procurement_monitoring_by_product pmp LEFT JOIN purchasing_job_state pjs ON pjs.purchasing_job_id = pmp.product_id - LEFT JOIN unique_sub sub ON sub.product_id = pmp.product_id - LEFT JOIN latest_po_filtered po ON po.product_id = pmp.product_id + LEFT JOIN ( + SELECT + vso.product_id, + sol.vendor_id + FROM v_sales_outstanding vso + LEFT JOIN sale_order_line sol ON sol.id = vso.sale_line_id + ) AS sub ON sub.product_id = pmp.product_id + LEFT JOIN latest_purchase_orders po ON po.product_id = pmp.product_id LEFT JOIN random_user_ids ru ON ru.vendor_id = sub.vendor_id OR (ru.vendor_id IS NULL AND sub.vendor_id != 9688) WHERE pmp.action = 'kurang' - AND sub.vendor_id IS NOT NULL + AND sub.vendor_id IS NOT NULL GROUP BY pmp.product_id, pmp.brand, pmp.item_code, pmp.product, - pmp.action - )""" % self._table - - self.env.cr.execute(query) + pmp.action, + sub.vendor_id, + ru.user_id + ) + """ % self._table) def open_form_multi_generate_request_po(self): diff --git a/indoteknik_custom/models/purchasing_job_multi_update.py b/indoteknik_custom/models/purchasing_job_multi_update.py index 80a43e45..deba960a 100644 --- a/indoteknik_custom/models/purchasing_job_multi_update.py +++ b/indoteknik_custom/models/purchasing_job_multi_update.py @@ -18,7 +18,7 @@ class PurchasingJobMultiUpdate(models.TransientModel): ('purchasing_job_id', '=', product.id) ]) - # purchasing_job_state.unlink() + purchasing_job_state.unlink() purchasing_job_state.create({ 'purchasing_job_id': product.id, diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index ac81737d..0d28e677 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -201,6 +201,10 @@ class SaleOrder(models.Model): @api.model def action_multi_update_state(self): for sale in self: + for picking_ids in sale.picking_ids: + if not picking_ids.state == 'cancel': + raise UserError('DO harus cancel terlebih dahulu') + sale.update({ 'state': 'cancel', }) diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index d362d573..1fee041d 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -115,25 +115,33 @@ class SaleOrderLine(models.Model): [('vendor_id', '=', self.product_id.x_manufacture.override_vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1, order='count_trx_po desc, count_trx_po_vendor desc') - self.purchase_price = self._get_valid_purchase_price(purchase_price) + price, taxes = self._get_valid_purchase_price(purchase_price) + self.purchase_price = price + self.purchase_tax_id = taxes else: purchase_price = self.env['purchase.pricelist'].search( [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1, order='count_trx_po desc, count_trx_po_vendor desc') - self.purchase_price = self._get_valid_purchase_price(purchase_price) - self.purchase_tax_id = 22 + price, taxes = self._get_valid_purchase_price(purchase_price) + self.purchase_price = price + self.purchase_tax_id = taxes def _get_valid_purchase_price(self, purchase_price): price = 0 + taxes = '' human_last_update = purchase_price.human_last_update or datetime.min system_last_update = purchase_price.system_last_update or datetime.min + + if purchase_price.taxes_product_id.type_tax_use == 'purchase': + price = purchase_price.product_price + taxes = purchase_price.taxes_product_id.id if system_last_update > human_last_update: - price = purchase_price.system_price - else: - price = purchase_price.product_price + if purchase_price.taxes_system_id.type_tax_use == 'purchase': + price = purchase_price.system_price + taxes = purchase_price.taxes_system_id.id - return price or 0 + return price, taxes @api.onchange('product_id') def product_id_change(self): @@ -148,7 +156,8 @@ class SaleOrderLine(models.Model): query, limit=1, order='count_trx_po desc, count_trx_po_vendor desc') line.vendor_id = purchase_price.vendor_id line.tax_id = line.order_id.sales_tax_id - line.purchase_price = line._get_valid_purchase_price(purchase_price) + price, taxes = line._get_valid_purchase_price(purchase_price) + line.purchase_price = price line_name = ('[' + line.product_id.default_code + ']' if line.product_id.default_code else '') + ' ' + (line.product_id.name if line.product_id.name else '') + ' ' + \ ('(' + line.product_id.product_template_attribute_value_ids.name + ')' if line.product_id.product_template_attribute_value_ids.name else '') + ' ' + \ diff --git a/indoteknik_custom/models/shipment_group.py b/indoteknik_custom/models/shipment_group.py new file mode 100644 index 00000000..92f76db7 --- /dev/null +++ b/indoteknik_custom/models/shipment_group.py @@ -0,0 +1,81 @@ +from odoo import models, api, fields +from odoo.exceptions import AccessError, UserError, ValidationError +from datetime import timedelta, date +import logging + +_logger = logging.getLogger(__name__) + +class ShipmentGroup(models.Model): + _name = "shipment.group" + _description = "Shipment Group" + _inherit = ['mail.thread'] + _rec_name = 'number' + + number = fields.Char(string='Document No', index=True, copy=False, readonly=True, tracking=True) + shipment_line = fields.One2many('shipment.group.line', 'shipment_id', string='Shipment Group Lines', auto_join=True) + partner_id = fields.Many2one('res.partner', string='Customer') + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('shipment.group') or '0' + result = super(ShipmentGroup, self).create(vals) + return result + +class ShipmentGroupLine(models.Model): + _name = 'shipment.group.line' + _description = 'Shipment Group Line' + _order = 'shipment_id, id' + + shipment_id = fields.Many2one('shipment.group', string='Shipment Ref', required=True, ondelete='cascade', index=True, copy=False) + partner_id = fields.Many2one('res.partner', string='Customer') + picking_id = fields.Many2one('stock.picking', string='Picking') + sale_id = fields.Many2one('sale.order', string='Sale Order') + state = fields.Char(string='Status', readonly=True, compute='_compute_state') + + @api.depends('picking_id.state') + def _compute_state(self): + for rec in self: + if rec.picking_id: + if rec.picking_id.state == 'assigned': + rec.state = 'Ready' + elif rec.picking_id.state == 'done': + rec.state = 'Done' + elif rec.picking_id.state == 'cancel': + rec.state = 'Cancelled' + elif rec.picking_id.state == 'confirmed': + rec.state = 'Waiting' + elif rec.picking_id.state == 'waiting': + rec.state = 'Waiting Another Operation' + else: + rec.state = 'draft' + else: + rec.state = 'draft' + + @api.onchange('picking_id') + def onchange_picking_id(self): + if self.picking_id: + picking = self.env['stock.picking'].browse(self.picking_id.id) + + if self.shipment_id.partner_id and self.shipment_id.partner_id != picking.partner_id: + raise UserError('Partner must be same as shipment group') + + self.partner_id = picking.partner_id + + if not self.shipment_id.partner_id: + self.shipment_id.partner_id = picking.partner_id + + self.sale_id = picking.sale_id + + @api.model + def create(self, vals): + record = super(ShipmentGroupLine, self).create(vals) + if record.picking_id: + record.onchange_picking_id() + return record + + def write(self, vals): + res = super(ShipmentGroupLine, self).write(vals) + if 'picking_id' in vals: + self.onchange_picking_id() + return res + diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 62d86911..2dd69e01 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -82,9 +82,12 @@ class StockPicking(models.Model): ('not_printed', 'Belum Print'), ('printed', 'Printed') ], string='Printed?', copy=False, tracking=True) + date_printed_sj = fields.Datetime(string='Status Printed Surat Jalan', copy=False, tracking=True) + date_printed_list = fields.Datetime(string='Status Printed Picking List', copy=False, tracking=True) date_unreserve = fields.Datetime(string="Date Unreserved", copy=False, tracking=True) date_availability = fields.Datetime(string="Date Availability", copy=False, tracking=True) sale_order = fields.Char(string='Matches SO', copy=False) + printed_sj = fields.Boolean('Printed Surat Jalan', help='flag which is internal use or not') @api.onchange('carrier_id') def constrains_carrier_id(self): diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 30bc7d06..d33ec5e3 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -128,3 +128,5 @@ access_report_logbook_bill,access.report.logbook.sj,model_report_logbook_bill,,1 access_report_logbook_bill_line,access.report.logbook.sj.line,model_report_logbook_bill_line,,1,1,1,1 access_report_logbook_bill_line,access.report.logbook.sj.line,model_report_logbook_bill_line,,1,1,1,1 access_sale_order_multi_uangmuka_penjualan,access.sale.order.multi_uangmuka_penjualan,model_sale_order_multi_uangmuka_penjualan,,1,1,1,1 +access_shipment_group,access.shipment.group,model_shipment_group,,1,1,1,1 +access_shipment_group_line,access.shipment.group.line,model_shipment_group_line,,1,1,1,1 diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index 40ce135c..b4fb5c0c 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -21,6 +21,16 @@ <field name="number_increment">1</field> </record> + <record id="sequence_shipment_group" model="ir.sequence"> + <field name="name">Shipment Group</field> + <field name="code">shipment.group</field> + <field name="active">TRUE</field> + <field name="prefix">SG/%(year)s/</field> + <field name="padding">5</field> + <field name="number_next">1</field> + <field name="number_increment">1</field> + </record> + <record id="sequence_logbook_bill" model="ir.sequence"> <field name="name">Logbook Bill</field> <field name="code">report.logbook.bill</field> diff --git a/indoteknik_custom/views/mail_template_efaktur.xml b/indoteknik_custom/views/mail_template_efaktur.xml index ca0ea427..3856b591 100644 --- a/indoteknik_custom/views/mail_template_efaktur.xml +++ b/indoteknik_custom/views/mail_template_efaktur.xml @@ -5,7 +5,9 @@ <field name="name">Invoice: Send mail efaktur document</field> <field name="model_id" ref="model_account_move" /> <field name="subject">Your Invoice ${object.name}</field> - <field name="email_from">sales@indoteknik.com</field> + <field name="email_from">pajak@indoteknik.co.id</field> + <field name="reply_to">pajak@indoteknik.co.id</field> + <field name="email_cc">sales@indoteknik.com, pajak@indoteknik.co.id</field> <field name="email_to">${object.partner_id.email|safe}</field> <field name="body_html" type="html"> <p>Dengan Hormat Bpk/Ibu ${object.partner_id.name},</p> diff --git a/indoteknik_custom/views/report_logbook_bill.xml b/indoteknik_custom/views/report_logbook_bill.xml index fc461400..0564d2e5 100644 --- a/indoteknik_custom/views/report_logbook_bill.xml +++ b/indoteknik_custom/views/report_logbook_bill.xml @@ -4,7 +4,7 @@ <field name="name">report.logbook.bill.tree</field> <field name="model">report.logbook.bill</field> <field name="arch" type="xml"> - <tree create="0" delete="0"> + <tree default_order="create_date desc" create="0" delete="0"> <field name="name"/> <field name="approve_by"/> <field name="created_by"/> diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml index 147ae393..896594bb 100644 --- a/indoteknik_custom/views/report_logbook_sj.xml +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -4,7 +4,7 @@ <field name="name">report.logbook.sj.tree</field> <field name="model">report.logbook.sj</field> <field name="arch" type="xml"> - <tree create="0" delete="0"> + <tree default_order="create_date desc" create="0" delete="0"> <field name="name"/> <field name="approve_by"/> <field name="created_by"/> diff --git a/indoteknik_custom/views/shipment_group.xml b/indoteknik_custom/views/shipment_group.xml new file mode 100644 index 00000000..b66bda3c --- /dev/null +++ b/indoteknik_custom/views/shipment_group.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <record id="shipment_group_tree" model="ir.ui.view"> + <field name="name">shipment.group.tree</field> + <field name="model">shipment.group</field> + <field name="arch" type="xml"> + <tree default_order="create_date desc"> + <field name="number"/> + <field name="partner_id"/> + </tree> + </field> + </record> + + <record id="shipment_group_line_tree" model="ir.ui.view"> + <field name="name">shipment.group.line.tree</field> + <field name="model">shipment.group.line</field> + <field name="arch" type="xml"> + <tree editable="bottom"> + <field name="picking_id" required="1"/> + <field name="partner_id" readonly="1"/> + <field name="sale_id" readonly="1"/> + <field name="state" readonly="1"/> + </tree> + </field> + </record> + + <record id="shipment_group_form" model="ir.ui.view"> + <field name="name">shipment.group.form</field> + <field name="model">shipment.group</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="number" readonly="1"/> + </group> + <group> + <field name="partner_id" readonly="1"/> + </group> + </group> + <notebook> + <page string="Line"> + <field name="shipment_line"/> + </page> + </notebook> + </sheet> + <div class="oe_chatter"> + <field name="message_follower_ids" widget="mail_followers"/> + <field name="message_ids" widget="mail_thread"/> + </div> + </form> + </field> + </record> + + <record id="shipment_group_action" model="ir.actions.act_window"> + <field name="name">Shipment Group</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">shipment.group</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + action="shipment_group_action" + id="shipment_group" + parent="stock.menu_stock_warehouse_mgmt" + name="Shipment Group" + sequence="1" + /> +</odoo> diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 90f662cc..3c7f027e 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -59,7 +59,6 @@ <field name="real_shipping_id"/> </field> <field name="origin" position="after"> - <field name="status_printed"/> <field name="purchase_id"/> <field name="sale_order"/> <field name="date_doc_kirim"/> @@ -75,6 +74,10 @@ </field> <field name="group_id" position="before"> <field name="date_reserved"/> + <field name="status_printed"/> + <field name="printed_sj"/> + <field name="date_printed_sj"/> + <field name="date_printed_list"/> <field name="is_internal_use" string="Internal Use" type="object" |
