summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-05-30 16:09:35 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-05-30 16:09:35 +0700
commit65fe5e9cb0865293eb6d0626d2c99f35d6862b3c (patch)
tree9b101f91df2be5e08a489991579b9edd691cbdfd
parentc0bc0039928cdb7e2eef8e39dc5daad6e5ecfc28 (diff)
add invoice_date_due and terima faktur on bills
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/account_move.py9
-rw-r--r--indoteknik_custom/models/account_move_multi_update_bills.py26
-rw-r--r--indoteknik_custom/models/purchasing_job.py15
-rwxr-xr-xindoteknik_custom/models/sale_order.py2
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv1
-rw-r--r--indoteknik_custom/views/account_move.xml13
-rw-r--r--indoteknik_custom/views/account_move_multi_update_bills.xml33
9 files changed, 96 insertions, 5 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index fa0188e6..5b43781e 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -125,6 +125,7 @@
'views/apps_stored.xml',
'views/ged_tracking.xml',
'views/dunning_run_ged.xml',
+ 'views/account_move_multi_update_bills.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 33aa0784..cd1e4d29 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -113,3 +113,4 @@ from . import sales_order_fullfillment
from . import res_partner_site
from . import external_api
from . import ged
+from . import account_move_multi_update_bills
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index b306b6af..aa8b97be 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -246,7 +246,7 @@ class AccountMove(models.Model):
due_date = tukar_date + timedelta(days=add_days)
invoice.invoice_date_due = due_date
- @api.onchange('date_terima_tukar_faktur')
+ @api.constrains('date_terima_tukar_faktur')
def change_date_terima_tukar_faktur(self):
for invoice in self:
if not invoice.date_terima_tukar_faktur:
@@ -266,6 +266,13 @@ class AccountMove(models.Model):
}
return action
+ def open_form_multi_update_bills(self):
+ action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_account_move_multi_update_bills')
+ action['context'] = {
+ 'move_ids': [x.id for x in self]
+ }
+ return action
+
@api.constrains('efaktur_id', 'ref', 'date', 'journal_id', 'name')
def constrains_edit(self):
for rec in self.line_ids:
diff --git a/indoteknik_custom/models/account_move_multi_update_bills.py b/indoteknik_custom/models/account_move_multi_update_bills.py
new file mode 100644
index 00000000..d348beed
--- /dev/null
+++ b/indoteknik_custom/models/account_move_multi_update_bills.py
@@ -0,0 +1,26 @@
+from odoo import models, fields
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class AccountMoveMultiUpdateBills(models.TransientModel):
+ _name = 'account.move.multi_update_bills'
+
+ date_terima_tukar_faktur = fields.Date(string="Terima Faktur")
+
+ def save_multi_update_bills(self):
+ move_ids = self._context['move_ids']
+ moves = self.env['account.move'].browse(move_ids)
+ moves.update({
+ 'date_terima_tukar_faktur': self.date_terima_tukar_faktur
+ })
+ 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/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py
index 86f8afcc..373e469a 100644
--- a/indoteknik_custom/models/purchasing_job.py
+++ b/indoteknik_custom/models/purchasing_job.py
@@ -188,9 +188,18 @@ class OutstandingSales(models.Model):
tools.drop_view_if_exists(self.env.cr, self._table)
self.env.cr.execute("""
CREATE OR REPLACE VIEW v_sales_outstanding AS (
- select sm.id, sm.id as move_id, sp.id as picking_id, sm.product_id, so.id as sale_id,
- sol.id as sale_line_id, rp.id as partner_id, so.user_id as salesperson_id, so.partner_invoice_id,
- sp.origin, rp2.name as salesperson, coalesce(pp.default_code, pt.default_code) as item_code, pt.name as product,
+ select sm.id,
+ sm.id as move_id,
+ sp.id as picking_id,
+ sm.product_id,
+ so.id as sale_id,
+ sol.id as sale_line_id,
+ rp.id as partner_id,
+ so.user_id as salesperson_id,
+ 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
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index dd6753aa..9a4f9035 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -423,7 +423,7 @@ class SaleOrder(models.Model):
if self.payment_term_id.id == 31 and self.total_percent_margin < 25:
raise UserError("Jika ingin menggunakan Tempo 90 Hari maka margin harus di atas 25%")
- if self.warehouse_id.id != 8: #GD Bandengan
+ if self.warehouse_id.id != 8 and self.warehouse_id.id != 10: #GD Bandengan
raise UserError('Gudang harus Bandengan')
if self.state not in ['draft', 'sent']:
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index a5605f3b..223504e6 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -116,3 +116,4 @@ access_ged_api,access.ged.api,model_ged_api,,1,1,1,1
access_ged_tracking,access.ged.tracking,model_ged_tracking,,1,1,1,1
access_ged_tracking_line,access.ged.tracking.line,model_ged_tracking_line,,1,1,1,1
access_ged_tracking_log,access.ged.tracking.log,model_ged_tracking_log,,1,1,1,1
+access_account_move_multi_update_bills,access.account.move.multi_update_bills,model_account_move_multi_update_bills,,1,1,1,1
diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml
index 1be6d118..93145fea 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -111,6 +111,8 @@
<field name="bill_day_to_due" string="Due Date" widget="remaining_days"/>
<field name="is_efaktur_uploaded" optional="hide"/>
<field name="is_invoice_uploaded" optional="hide"/>
+ <field name="invoice_date"/>
+ <field name="invoice_date_due"/>
</field>
<field name="invoice_date_due" position="attributes">
@@ -131,6 +133,9 @@
{'column_invisible': [('parent.move_type', '!=', 'in_invoice')]}
</attribute>
</field>
+ <field name="invoice_incoterm_id" position="after">
+ <field name="date_terima_tukar_faktur"/>
+ </field>
</field>
</record>
@@ -141,6 +146,14 @@
<field name="state">code</field>
<field name="code">action = records.open_form_multi_update()</field>
</record>
+
+ <record id="account_move_multi_update_bills_ir_actions_server" model="ir.actions.server">
+ <field name="name">Update Terima Faktur Bills</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_bills()</field>
+ </record>
<record id="account_move_multi_create_reklas_ir_actions_server" model="ir.actions.server">
<field name="name">Create Reklas Penjualan</field>
diff --git a/indoteknik_custom/views/account_move_multi_update_bills.xml b/indoteknik_custom/views/account_move_multi_update_bills.xml
new file mode 100644
index 00000000..73f92d16
--- /dev/null
+++ b/indoteknik_custom/views/account_move_multi_update_bills.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="view_account_move_multi_update_form_bills" model="ir.ui.view">
+ <field name="name">Account Move Multi Update Bills</field>
+ <field name="model">account.move.multi_update_bills</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <group>
+ <field name="date_terima_tukar_faktur" />
+ </group>
+ </group>
+ </sheet>
+ <footer>
+ <button name="save_multi_update_bills" string="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_bills" model="ir.actions.act_window">
+ <field name="name">Account Move Multi Update Bills</field>
+ <field name="res_model">account.move.multi_update_bills</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_bills"/>
+ <field name="target">new</field>
+ </record>
+ </data>
+</odoo> \ No newline at end of file