diff options
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 31 | ||||
| -rw-r--r-- | indoteknik_api/models/res_users.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 10 | ||||
| -rw-r--r-- | indoteknik_custom/models/account_move_multi_update.py | 26 | ||||
| -rw-r--r-- | indoteknik_custom/models/bill_receipt.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/product_sla.py | 9 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 10 | ||||
| -rwxr-xr-x | indoteknik_custom/models/stock_vendor.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/report/purchase_order.xml | 6 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move.xml | 11 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move_multi_update.xml | 33 | ||||
| -rw-r--r-- | indoteknik_custom/views/bill_receipt.xml | 1 |
16 files changed, 125 insertions, 24 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 8803bae3..7ec6459b 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -16,31 +16,40 @@ class Product(controller.Controller): @controller.Controller.must_authorized() def get_product_template_stock_by_id(self, **kw): id = int(kw.get('id')) + date_7_days_ago = datetime.now() - timedelta(days=7) product = request.env['product.product'].search([('id', '=', id)], limit=1) product_sla = request.env['product.sla'].search([('product_variant_id', '=', id)], limit=1) - + stock_vendor = request.env['stock.vendor'].search([ + ('product_variant_id', '=', id), + ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S")) + ], limit=1) + qty_available = product.qty_onhand_bandengan - qty_available -= 10 - if qty_available < 10: - qty_available = 0 qty = 0 sla_date = '-' - + is_altama_product = product.x_manufacture.id in [10,122,89] if is_altama_product: try: + # Qty Altama qty_altama = request.env['product.template'].get_stock_altama(product.default_code) qty_altama -= int(qty_altama * 0.1) qty_altama = math.ceil(float(qty_altama)) - qty = qty_altama - if qty_available > 10: - qty += qty_available + total_adem = qty_altama + # Qty Stock Vendor + qty_vendor = stock_vendor.quantity + qty_vendor -= int(qty_vendor * 0.1) + qty_vendor = math.ceil(float(qty_vendor)) + total_excell = qty_vendor + if qty_available > 0: + qty = qty_available + total_adem + total_excell sla_date = '1 Hari' - elif qty_altama > 0: + elif qty_altama > 0 or qty_vendor > 0: + qty = total_adem if qty_altama > 0 else total_excell sla_date = '2-4 Hari' - else: - sla_date = 'Indent' + else: + sla_date = '3-7 Hari' except: print('error') else: diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 69981e41..0fe9008b 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -20,6 +20,7 @@ class ResUsers(models.Model): data = { 'id': res_user.id, 'parent_id': res_user.parent_id.id or False, + 'parent_name': res_user.parent_id.name or False, 'partner_id': res_user.partner_id.id, 'name': res_user.name, 'email': res_user.login, diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index b6dea5a0..dfe22fd2 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -84,6 +84,7 @@ 'views/product_sla.xml', 'views/voucher.xml', 'views/bill_receipt.xml', + 'views/account_move_multi_update.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 929fc8ba..5b8fcc54 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -71,4 +71,5 @@ from . import token_storage from . import product_sla from . import account_move_due_extension from . import voucher -from . import bill_receipt
\ No newline at end of file +from . import bill_receipt +from . import account_move_multi_update
\ No newline at end of file diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index bc6061ee..4db97706 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -15,6 +15,7 @@ class AccountMove(models.Model): date_kirim_tukar_faktur = fields.Date(string='Kirim Faktur') resi_tukar_faktur = fields.Char(string='Resi Faktur') date_terima_tukar_faktur = fields.Date(string='Terima Faktur') + payment_schedule = fields.Date(string='Jadwal Pembayaran') shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') due_extension = fields.Integer(string='Due Extension', default=0) new_due_date = fields.Date(string='New Due') @@ -114,4 +115,11 @@ class AccountMove(models.Model): add_days += line.days due_date = tukar_date + timedelta(days=add_days) invoice.invoice_date_due = due_date -
\ No newline at end of file + + def open_form_multi_update(self): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_account_move_multi_update') + action['context'] = { + 'move_ids': [x.id for x in self] + } + return action +
\ No newline at end of file diff --git a/indoteknik_custom/models/account_move_multi_update.py b/indoteknik_custom/models/account_move_multi_update.py new file mode 100644 index 00000000..4b650868 --- /dev/null +++ b/indoteknik_custom/models/account_move_multi_update.py @@ -0,0 +1,26 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class AccountMoveMultiUpdate(models.TransientModel): + _name = 'account.move.multi_update' + + payment_schedule = fields.Date(string="Jadwal Pembayaran") + + def save_multi_update(self): + move_ids = self._context['move_ids'] + moves = self.env['account.move'].browse(move_ids) + moves.update({ + 'payment_schedule': self.payment_schedule + }) + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Account Move berhasil diubah', + 'next': {'type': 'ir.actions.act_window_close'}, + } + }
\ No newline at end of file diff --git a/indoteknik_custom/models/bill_receipt.py b/indoteknik_custom/models/bill_receipt.py index 5e03fdce..76449c1f 100644 --- a/indoteknik_custom/models/bill_receipt.py +++ b/indoteknik_custom/models/bill_receipt.py @@ -89,7 +89,6 @@ class BillReceipt(models.Model): 'partner_id': invoice.partner_id.id, 'invoice_id': invoice.id, 'date_invoice': invoice.invoice_date, - 'efaktur_id': invoice.efaktur_id.id, 'reference': invoice.ref, 'total_amt': invoice.amount_total, 'open_amt': invoice.amount_residual_signed, @@ -114,8 +113,6 @@ class BillReceiptLine(models.Model): partner_id = fields.Many2one('res.partner', string='Customer') invoice_id = fields.Many2one('account.move', string='Invoice') date_invoice = fields.Date(string='Invoice Date') - # due_date = fields.Date(string='Due Date') - efaktur_id = fields.Many2one('vit.efaktur', string='Faktur Pajak') reference = fields.Char(string='Reference') total_amt = fields.Float(string='Total Amount') open_amt = fields.Float(string='Open Amount') diff --git a/indoteknik_custom/models/product_sla.py b/indoteknik_custom/models/product_sla.py index f969502f..2e663d30 100644 --- a/indoteknik_custom/models/product_sla.py +++ b/indoteknik_custom/models/product_sla.py @@ -51,12 +51,9 @@ class ProductSla(models.Model): qty_available = 0 qty_available = product.qty_onhand_bandengan - qty_available -= 10 - if qty_available < 10: - qty_available = 0 - - if qty_available > 10: + + if qty_available > 0: self.sla = '1 Hari' query = [ @@ -80,7 +77,7 @@ class ProductSla(models.Model): rounded_leadtime = math.ceil(avg_leadtime) self.avg_leadtime = rounded_leadtime if rounded_leadtime >= 1 and rounded_leadtime <= 5: - self.sla = '3-6 Hari' + self.sla = '3-7 Hari' elif rounded_leadtime >= 6 and rounded_leadtime <= 10: self.sla = '4-12 Hari' elif rounded_leadtime >= 11: diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 1a83b702..7abdf1c1 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -221,7 +221,7 @@ class ProductTemplate(models.Model): datas = json.loads(response.text)['data'] qty = 0 for data in datas: - availability = int(data['availability']) # Mengonversi ke tipe data int + availability = float(data['availability']) # Mengonversi ke tipe data int qty += availability # Mengakumulasi qty dari setiap data return qty diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index deea64a1..552f1b0a 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -243,6 +243,16 @@ class SaleOrder(models.Model): self.npwp = parent_id.npwp self.sppkp = parent_id.sppkp self.customer_type = parent_id.customer_type + + @api.onchange('partner_id') + def onchange_partner_id(self): + # INHERIT + result = super(SaleOrder, self).onchange_partner_id() + parent_id = self.partner_id.parent_id + parent_id = parent_id if parent_id else self.partner_id + + self.partner_invoice_id = parent_id + return result def _get_purchases(self): po_state = ['done', 'draft', 'purchase'] diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py index 1e5bce16..f214a5e1 100755 --- a/indoteknik_custom/models/stock_vendor.py +++ b/indoteknik_custom/models/stock_vendor.py @@ -1,5 +1,6 @@ from odoo import fields, models, api import logging +from datetime import datetime, timedelta _logger = logging.getLogger(__name__) diff --git a/indoteknik_custom/report/purchase_order.xml b/indoteknik_custom/report/purchase_order.xml index 09ded9dc..0f392630 100644 --- a/indoteknik_custom/report/purchase_order.xml +++ b/indoteknik_custom/report/purchase_order.xml @@ -5,5 +5,11 @@ <b>NPWP</b><br/>74.226.022.7-086.000<br/><b>PT. INDOTEKNIK DOTCOM GEMILANG</b><br/>JALAN BANDENGAN UTARA BLOK 85A NO 8-9<br/>PENJARINGAN, PENJARINGAN<br/>KOTA ADM, JAKARTA UTARA DKI JAKARTA 14440 </div> </xpath> + <xpath expr="//div[@id='informations']" position="inside"> + <div t-if="o.date_planned" class="col-3 bm-2"> + <strong>Receipt Date:</strong> + <p t-field="o.date_planned" class="m-0"/> + </div> + </xpath> </template> </odoo> diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index f115da56..6e11bc5b 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -63,3 +63,4 @@ access_product_sla,access.product_sla,model_product_sla,,1,1,1,1 access_voucher,access.voucher,model_voucher,,1,1,1,1 access_bill_receipt,access.bill.receipt,model_bill_receipt,,1,1,1,1 access_bill_receipt_line,access.bill.receipt.line,model_bill_receipt_line,,1,1,1,1 +access_account_move_multi_update,access.account.move.multi_update,model_account_move_multi_update,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index a1d3eaaa..26168561 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -10,6 +10,9 @@ <button name="indoteknik_custom.action_view_invoice_reklas" string="Reklas" type="action" class="btn-primary" attrs="{'invisible': [('state', '!=', 'posted')]}"/> </button> + <field name="invoice_date" position="after"> + <field name="payment_schedule" attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"/> + </field> <field name="invoice_user_id" position="after"> <field name="date_kirim_tukar_faktur"/> <field name="shipper_faktur_id"/> @@ -70,5 +73,13 @@ </field> </field> </record> + + <record id="account_move_multi_update_ir_actions_server" model="ir.actions.server"> + <field name="name">Multi Update</field> + <field name="model_id" ref="account.model_account_move"/> + <field name="binding_model_id" ref="account.model_account_move"/> + <field name="state">code</field> + <field name="code">action = records.open_form_multi_update()</field> + </record> </data> </odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/account_move_multi_update.xml b/indoteknik_custom/views/account_move_multi_update.xml new file mode 100644 index 00000000..dbd90340 --- /dev/null +++ b/indoteknik_custom/views/account_move_multi_update.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <data> + <record id="view_account_move_multi_update_form" model="ir.ui.view"> + <field name="name">Account Move Multi Update</field> + <field name="model">account.move.multi_update</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="payment_schedule" /> + </group> + </group> + </sheet> + <footer> + <button name="save_multi_update" string="Multi Update" type="object" default_focus="1" class="oe_highlight"/> + <button string="Cancel" class="btn btn-secondary" special="cancel" /> + </footer> + </form> + </field> + </record> + + <record id="action_account_move_multi_update" model="ir.actions.act_window"> + <field name="name">Account Move Multi Update</field> + <field name="res_model">account.move.multi_update</field> + <field name="type">ir.actions.act_window</field> + <field name="view_mode">form</field> + <field name="view_id" ref="view_account_move_multi_update_form"/> + <field name="target">new</field> + </record> + </data> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/bill_receipt.xml b/indoteknik_custom/views/bill_receipt.xml index c9ab492a..15d82e7b 100644 --- a/indoteknik_custom/views/bill_receipt.xml +++ b/indoteknik_custom/views/bill_receipt.xml @@ -25,7 +25,6 @@ <field name="partner_id"/> <field name="invoice_id"/> <field name="date_invoice"/> - <field name="efaktur_id"/> <field name="reference"/> <field name="total_amt"/> <field name="open_amt"/> |
