diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-08-14 13:31:36 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-08-14 13:31:36 +0700 |
| commit | ed089761d43b20ecc4190ca9d88a0bdb769d81f2 (patch) | |
| tree | 6f5ed6967a4aa20e5773561f7a6b129d91b23311 | |
| parent | 513d2b473f4fbf7245c35289e2a3215c5da556a6 (diff) | |
| parent | c091a99de4e3c3bb4f85a8b0c91d75735ebefbd4 (diff) | |
Merge branch 'production' into feature/calculate_selling_price
# Conflicts:
# indoteknik_custom/views/website_user_cart.xml
19 files changed, 215 insertions, 21 deletions
diff --git a/indoteknik_api/controllers/api_v1/lead.py b/indoteknik_api/controllers/api_v1/lead.py index 23c3bf99..d5cc7c5c 100644 --- a/indoteknik_api/controllers/api_v1/lead.py +++ b/indoteknik_api/controllers/api_v1/lead.py @@ -15,6 +15,7 @@ class Lead(controller.Controller): "file_nib": [], "file_tdp": [], "file_siup": [], + "file_quotation": [], "description": [] }) diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index 53f118ec..cd5dff20 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -20,6 +20,7 @@ class Voucher(controller.Controller): def get_vouchers_by_user_id(self, **kw): cart = request.env['website.user.cart'] code = kw.get('code') + type = kw.get('type') user_id = int(kw.get('user_id', 0)) source = kw.get('source') visibility = ['public'] @@ -32,6 +33,10 @@ class Voucher(controller.Controller): if user_pricelist: domain += [('excl_pricelist_ids', 'not in', [user_pricelist.id])] + if type: + type = type.split(',') + domain += [('apply_type', 'in', type)] + domain += [('visibility', 'in', visibility)] vouchers = request.env['voucher'].get_active_voucher(domain) checkout = cart.get_user_checkout(user_id, source=source) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 32678ef5..b3c3bc5d 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -139,6 +139,7 @@ 'views/report_logbook_bill.xml', 'views/sale_order_multi_uangmuka_penjualan.xml', 'views/shipment_group.xml', + 'views/approval_date_doc.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 116354d6..e9ce587c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -124,3 +124,4 @@ from . import report_logbook_bill from . import sale_order_multi_uangmuka_penjualan from . import shipment_group from . import sales_order_reject +from . import approval_date_doc diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py index c9af7f8d..0399c6a2 100644 --- a/indoteknik_custom/models/account_move_due_extension.py +++ b/indoteknik_custom/models/account_move_due_extension.py @@ -24,6 +24,7 @@ class DueExtension(models.Model): ('approved', 'Approved'), ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) day_extension = fields.Selection([ + ('1', '1 Hari'), ('3', '3 Hari'), ('7', '7 Hari'), ('14', '14 Hari'), diff --git a/indoteknik_custom/models/approval_date_doc.py b/indoteknik_custom/models/approval_date_doc.py new file mode 100644 index 00000000..e00b7416 --- /dev/null +++ b/indoteknik_custom/models/approval_date_doc.py @@ -0,0 +1,49 @@ +from odoo import models, api, fields +from odoo.exceptions import AccessError, UserError, ValidationError +from datetime import timedelta, date, datetime +import logging + +_logger = logging.getLogger(__name__) + +class ApprovalDateDoc(models.Model): + _name = "approval.date.doc" + _description = "Approval Date Doc" + _rec_name = 'number' + + picking_id = fields.Many2one('stock.picking', string='Picking') + number = fields.Char(string='Document No', index=True, copy=False, readonly=True, tracking=True) + driver_departure_date = fields.Datetime( + string='Driver Departure Date', + copy=False + ) + state = fields.Selection([('draft', 'Draft'), ('done', 'Done')], string='State', default='draft', tracking=True) + approve_date = fields.Datetime(string='Approve Date', copy=False) + approve_by = fields.Many2one('res.users', string='Approve By', copy=False) + sale_id = fields.Many2one('sale.order', string='Sale Order') + + @api.onchange('picking_id') + def onchange_picking_id(self): + if self.picking_id: + self.sale_id = self.picking_id.sale_id.id + + def check_invoice_so_picking(self): + for rec in self: + invoice = self.env['account.move'].search_count([('sale_id', '=', rec.picking_id.sale_id.id)]) + + if invoice < 1: + raise UserError("Sales Order Belum Memiliki Invoice, Anda Bisa Edit Di DO nya langsung") + + def button_approve(self): + if not self.env.user.is_accounting: + raise UserError("Hanya Accounting Yang Bisa Approve") + self.check_invoice_so_picking + self.picking_id.driver_departure_date = self.driver_departure_date + self.state = 'done' + self.approve_date = datetime.utcnow() + self.approve_by = self.env.user.id + + @api.model + def create(self, vals): + vals['number'] = self.env['ir.sequence'].next_by_code('approval.date.doc') or '0' + result = super(ApprovalDateDoc, self).create(vals) + return result diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 73416c48..f5b1baf9 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -396,7 +396,7 @@ class AutomaticPurchase(models.Model): domain = [ ('product_id', '=', line.product_id.id) ] - sale = self.env['v.sales.outstanding'].search(domain, limit=1) + sale = self.env['v.sales.outstanding'].search(domain, order='sale_order_create_date desc', limit=1) existing_match = self.env['automatic.purchase.sales.match'].search([ ('automatic_purchase_id', '=', self.id), diff --git a/indoteknik_custom/models/logbook_bill.py b/indoteknik_custom/models/logbook_bill.py index 578ad59b..bb956092 100644 --- a/indoteknik_custom/models/logbook_bill.py +++ b/indoteknik_custom/models/logbook_bill.py @@ -22,7 +22,9 @@ class LogbookBill(models.TransientModel): ('product_id', '=', line.product_id.id), ], order='id desc', limit=1) total += line.quantity_done * po.price_unit - return total + total_with_tax = total * 1.11 + return total_with_tax + def create_logbook_bill(self): logbook_line = self.logbook_bill_line diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 373e469a..6e4f239d 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -183,6 +183,7 @@ class OutstandingSales(models.Model): outgoing = fields.Float(string='Outgoing') brand = fields.Char(string='Brand') invoice_partner = fields.Char(string='Invoice Partner') + sale_order_create_date = fields.Datetime(string='Sale Order Create Date') def init(self): tools.drop_view_if_exists(self.env.cr, self._table) @@ -199,19 +200,23 @@ class OutstandingSales(models.Model): so.partner_invoice_id, sp.origin, rp2.name as salesperson, - coalesce(pp.default_code, pt.default_code) as item_code, pt.name as product, - sm.product_uom_qty as outgoing, xm.x_name as brand, rp.name as invoice_partner - from stock_move sm - join stock_picking sp on sp.id = sm.picking_id - join sale_order_line sol on sol.id = sm.sale_line_id - join sale_order so on so.id = sol.order_id - join res_partner rp on rp.id = so.partner_invoice_id - join res_users ru on ru.id = so.user_id - join res_partner rp2 on rp2.id = ru.partner_id - join product_product pp on pp.id = sm.product_id - join product_template pt on pt.id = pp.product_tmpl_id - left join x_manufactures xm on xm.id = pt.x_manufacture - where sp.state in ('draft', 'waiting', 'confirmed', 'assigned') - and sp.name like '%OUT%' + coalesce(pp.default_code, pt.default_code) as item_code, + pt.name as product, + sm.product_uom_qty as outgoing, + xm.x_name as brand, + rp.name as invoice_partner, + so.create_date as sale_order_create_date + from stock_move sm + join stock_picking sp on sp.id = sm.picking_id + join sale_order_line sol on sol.id = sm.sale_line_id + join sale_order so on so.id = sol.order_id + join res_partner rp on rp.id = so.partner_invoice_id + join res_users ru on ru.id = so.user_id + join res_partner rp2 on rp2.id = ru.partner_id + join product_product pp on pp.id = sm.product_id + join product_template pt on pt.id = pp.product_tmpl_id + left join x_manufactures xm on xm.id = pt.x_manufacture + where sp.state in ('draft', 'waiting', 'confirmed', 'assigned') + and sp.name like '%OUT%' ) """) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 19699aab..39faf9d3 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -48,6 +48,15 @@ class ResPartner(models.Model): user_payment_terms_purchase = fields.Many2one('res.users', string='Users Update Payment Terms') date_payment_terms_purchase = fields.Datetime(string='Date Update Payment Terms') + def write(self, vals): + res = super(ResPartner, self).write(vals) + + if 'property_payment_term_id' in vals: + if not self.env.user.is_accounting and vals['property_payment_term_id'] != 26: + raise UserError('Hanya Finance Accounting yang dapat merubah payment term') + + return res + @api.constrains('property_payment_term_id') def updated_by_payment_term(self): for rec in self: @@ -111,5 +120,10 @@ class ResPartner(models.Model): if self._name == 'res.partner': raise UserError('Maaf anda tidak bisa delete contact') + @api.onchange('customer_type') + def _onchange_customer_type(self): + if self.customer_type == 'nonpkp': + self.npwp = '00.000.000.0-000.000' + diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 5badacba..0b0a679f 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -501,6 +501,10 @@ class SaleOrder(models.Model): raise UserError("Credit Limit pada Master Data Customer harus diisi") if order.payment_term_id != partner.property_payment_term_id: raise UserError("Payment Term berbeda pada Master Data Customer") + if (partner.customer_type == 'pkp' or order.customer_type == 'pkp') and order.npwp != partner.npwp: + raise UserError("NPWP berbeda pada Master Data Customer") + if (partner.customer_type == 'pkp' or order.customer_type == 'pkp') and order.sppkp != partner.sppkp: + raise UserError("SPPKP berbeda pada Master Data Customer") if not order.client_order_ref and order.create_date > datetime(2024, 6, 27): raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") @@ -518,6 +522,10 @@ class SaleOrder(models.Model): raise UserError("Credit Limit pada Master Data Customer harus diisi") if order.payment_term_id != partner.property_payment_term_id: raise UserError("Payment Term berbeda pada Master Data Customer") + if (partner.customer_type == 'pkp' or order.customer_type == 'pkp') and order.npwp != partner.npwp: + raise UserError("NPWP berbeda pada Master Data Customer") + if (partner.customer_type == 'pkp' or order.customer_type == 'pkp') and order.sppkp != partner.sppkp: + raise UserError("SPPKP berbeda pada Master Data Customer") if not order.client_order_ref and order.create_date > datetime(2024, 6, 27): raise UserError("Customer Reference kosong, di isi dengan NO PO jika PO tidak ada mohon ditulis Tanpa PO") diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c151a543..5029a770 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -26,7 +26,10 @@ class StockPicking(models.Model): # Delivery Order driver_departure_date = fields.Datetime( string='Driver Departure Date', - readonly=True, + copy=False + ) + arrival_time = fields.Datetime( + string='Jam Kedatangan', copy=False ) driver_arrival_date = fields.Datetime( @@ -91,6 +94,21 @@ class StockPicking(models.Model): 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') + invoice_status = fields.Selection([ + ('upselling', 'Upselling Opportunity'), + ('invoiced', 'Fully Invoiced'), + ('to invoice', 'To Invoice'), + ('no', 'Nothing to Invoice') + ], string='Invoice Status', related="sale_id.invoice_status") + + @api.constrains('driver_departure_date') + def constrains_driver_departure_date(self): + self.date_doc_kirim = self.driver_departure_date + + @api.constrains('arrival_time') + def constrains_arrival_time(self): + if self.arrival_time > datetime.datetime.utcnow(): + raise UserError('Jam kedatangan harus kurang dari Effective Date') def reset_status_printed(self): for rec in self: @@ -341,6 +359,9 @@ class StockPicking(models.Model): if not self.picking_code: self.picking_code = self.env['ir.sequence'].next_by_code('stock.picking.code') or '0' + if not self.arrival_time and 'BU/IN/' in self.name: + raise UserError('Jam Kedatangan harus diisi') + if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) @@ -372,6 +393,7 @@ class StockPicking(models.Model): res = super(StockPicking, self).button_validate() self.calculate_line_no() + self.date_done = datetime.datetime.utcnow() return res @api.model diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 66f763e0..c21ef209 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -90,6 +90,7 @@ class Voucher(models.Model): 'image': ir_attachment.api_image('voucher', 'image', self.id), 'name': self.name, 'code': self.code, + 'apply_type': self.apply_type, 'description': self.description, 'remaining_time': self._res_remaining_time(), } diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 95ad57f0..5e7554a5 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -133,3 +133,4 @@ access_sale_order_multi_uangmuka_penjualan,access.sale.order.multi_uangmuka_penj 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 access_sales_order_reject,access.sales.order.reject,model_sales_order_reject,,1,1,1,1 +access_approval_date_doc,access.approval.date.doc,model_approval_date_doc,,1,1,1,1 diff --git a/indoteknik_custom/views/approval_date_doc.xml b/indoteknik_custom/views/approval_date_doc.xml new file mode 100644 index 00000000..d6a70763 --- /dev/null +++ b/indoteknik_custom/views/approval_date_doc.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="approval_date_doc_tree" model="ir.ui.view"> + <field name="name">approval.date.doc.tree</field> + <field name="model">approval.date.doc</field> + <field name="arch" type="xml"> + <tree> + <field name="number"/> + <field name="picking_id"/> + <field name="sale_id"/> + <field name="driver_departure_date"/> + <field name="state"/> + <field name="approve_date"/> + <field name="approve_by"/> + </tree> + </field> + </record> + + <record id="approval_date_doc_form" model="ir.ui.view"> + <field name="name">approval.date.doc.form</field> + <field name="model">approval.date.doc</field> + <field name="arch" type="xml"> + <form> + <header> + <button name="button_approve" + string="Approve" + type="object" + attrs="{'invisible': [('state', '=', 'done')]}" + /> + </header> + <sheet string="Approval Date Doc"> + <group> + <group> + <field name="number"/> + <field name="picking_id"/> + <field name="sale_id"/> + <field name="driver_departure_date"/> + <field name="approve_date"/> + <field name="approve_by"/> + <field name="state" readonly="1"/> + </group> + </group> + </sheet> + </form> + </field> + </record> + + <record id="approval_date_doc_action" model="ir.actions.act_window"> + <field name="name">Approval Date Doc</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">approval.date.doc</field> + <field name="view_mode">tree,form</field> + </record> + + <menuitem id="menu_approval_date_doc" name="Approval Date Doc" + parent="account.menu_finance_receivables" + action="approval_date_doc_action" + sequence="100" + /> + +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index b4fb5c0c..b2768c71 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -11,6 +11,16 @@ <field name="number_increment">1</field> </record> + <record id="sequence_date_doc" model="ir.sequence"> + <field name="name">Approval Date Doc</field> + <field name="code">approval.date.doc</field> + <field name="active">TRUE</field> + <field name="prefix">ADD/%(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_sj" model="ir.sequence"> <field name="name">Logbook SJ</field> <field name="code">report.logbook.sj</field> diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index b928b046..bfac1eb3 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -26,8 +26,17 @@ <field name="pareto_status"/> <field name="digital_invoice_tax"/> </field> + <field name="nama_wajib_pajak" position="attributes"> + <attribute name="required">1</attribute> + </field> + <field name="npwp" position="attributes"> + <attribute name="required">1</attribute> + </field> + <field name="alamat_lengkap_text" position="attributes"> + <attribute name="required">1</attribute> + </field> <field name="npwp" position="before"> - <field name="customer_type"/> + <field name="customer_type" required="1"/> </field> <field name="is_berikat" position="after"> <field name="pakta_integritas"/> diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 7567dda2..899d29eb 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -68,10 +68,14 @@ <field name="partner_id" position="after"> <field name="real_shipping_id"/> </field> + <field name="date_done" position="after"> + <field name="arrival_time"/> + </field> <field name="origin" position="after"> <field name="purchase_id"/> <field name="sale_order"/> - <field name="date_doc_kirim"/> + <field name="invoice_status"/> + <field name="date_doc_kirim" attrs="{'readonly':[('invoice_status', '=', 'invoiced')]}"/> <field name="summary_qty_operation"/> <field name="count_line_operation"/> <field name="account_id" @@ -118,7 +122,7 @@ <group> <group> <field name="note_logistic"/> - <field name="driver_departure_date"/> + <field name="driver_departure_date" attrs="{'readonly':[('invoice_status', '=', 'invoiced')]}"/> <field name="driver_arrival_date"/> <field name="delivery_tracking_no"/> <field name="driver_id"/> diff --git a/indoteknik_custom/views/website_user_cart.xml b/indoteknik_custom/views/website_user_cart.xml index 9e88f3d4..11573121 100755 --- a/indoteknik_custom/views/website_user_cart.xml +++ b/indoteknik_custom/views/website_user_cart.xml @@ -62,7 +62,6 @@ <field name="code">model.action_mail_reminder_to_checkout()</field> <field name="state">code</field> <field name="priority">75</field> - <field name="active">False</field> </record> <record id="mail_template_user_cart_reminder_to_checkout" model="mail.template"> |
