summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-07-25 08:53:19 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-07-25 08:53:19 +0000
commit5ead2c84fb9b56d51520f77af8227160b56aeaca (patch)
tree4c0e32918e1ddf4e7a3e9116d3abb186ad417c7f
parentc344ccd81208b5b466ae047dbb9e084dd5d0f358 (diff)
parente933a05e9b03e489b581f27d1aa304774aafc320 (diff)
Merged in production (pull request #68)
Production
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py12
-rw-r--r--indoteknik_api/controllers/api_v1/voucher.py13
-rwxr-xr-xindoteknik_custom/__manifest__.py2
-rwxr-xr-xindoteknik_custom/models/__init__.py3
-rw-r--r--indoteknik_custom/models/account_move.py9
-rw-r--r--indoteknik_custom/models/account_move_multi_update.py26
-rw-r--r--indoteknik_custom/models/voucher.py2
-rw-r--r--indoteknik_custom/report/purchase_order.xml6
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv1
-rw-r--r--indoteknik_custom/views/account_move.xml8
-rw-r--r--indoteknik_custom/views/account_move_multi_update.xml33
-rwxr-xr-xindoteknik_custom/views/voucher.xml2
12 files changed, 95 insertions, 22 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 6c878197..208789af 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -355,13 +355,13 @@ class SaleOrder(controller.Controller):
manufacture_id = line.product_id.x_manufacture.id or False
if len(manufacture_ids) > 0 and manufacture_id not in manufacture_ids:
continue
- voucher_discount_line = line.price_subtotal / amount_untaxed * voucher_discount
- line.amount_voucher_disc = voucher_discount_line
+ voucher_disc_line = line.price_subtotal / amount_untaxed * voucher_discount
+ line.amount_voucher_disc = voucher_disc_line
- discount_decimal = line.discount / 100
- voucher_discount_item = voucher_discount_line / line.product_uom_qty
- voucher_disc_before_line_disc = voucher_discount_item / (1 - discount_decimal)
- line.price_unit -= voucher_disc_before_line_disc
+ voucher_disc_item = voucher_disc_line / line.product_uom_qty
+ voucher_disc_subtotal = line.price_subtotal - voucher_disc_item
+
+ line.discount = (line.price_unit - voucher_disc_subtotal) / line.price_unit * 100
cart_ids = [x['cart_id'] for x in products]
user_cart.browse(cart_ids).unlink()
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py
index a6a88cad..4baa93b7 100644
--- a/indoteknik_api/controllers/api_v1/voucher.py
+++ b/indoteknik_api/controllers/api_v1/voucher.py
@@ -31,9 +31,6 @@ class Voucher(controller.Controller):
apply_status = ''
products = checkout['products']
min_purchase_amount = voucher['min_purchase_amount']
- max_discount_amount = voucher['max_discount_amount']
- discount_type = voucher['discount_type']
- discount_amount = voucher['discount_amount']
can_apply = True
difference_to_apply = 0
@@ -60,14 +57,8 @@ class Voucher(controller.Controller):
apply_status = 'MPA'
difference_to_apply = min_purchase_amount - subtotal
- discount_voucher = 0
- if discount_type == 'fixed_price':
- discount_voucher = discount_amount
- if discount_type == 'percentage':
- discount_voucher = subtotal * discount_amount / 100
-
- if max_discount_amount > 0 and discount_voucher > max_discount_amount:
- discount_voucher = max_discount_amount
+ obj_voucher = request.env['voucher'].browse(voucher['id'])
+ discount_voucher = obj_voucher.calculate_discount(subtotal)
voucher['can_apply'] = can_apply
voucher['apply_status'] = apply_status
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index ead47bd3..dfe22fd2 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -84,7 +84,7 @@
'views/product_sla.xml',
'views/voucher.xml',
'views/bill_receipt.xml',
- # 'views/account_bills.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 33fb73b5..4db97706 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -115,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/voucher.py b/indoteknik_custom/models/voucher.py
index b3a55499..a7151398 100644
--- a/indoteknik_custom/models/voucher.py
+++ b/indoteknik_custom/models/voucher.py
@@ -107,7 +107,7 @@ class Voucher(models.Model):
if self.discount_type == 'percentage':
discount = price * self.discount_amount / 100
max_disc = self.max_discount_amount
- return max_disc if discount > max_disc else discount
+ return discount if max_disc == 0 else min(discount, max_disc)
return 0
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 0fd6b5b5..26168561 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -73,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/voucher.xml b/indoteknik_custom/views/voucher.xml
index c6741a8d..0bafcd55 100755
--- a/indoteknik_custom/views/voucher.xml
+++ b/indoteknik_custom/views/voucher.xml
@@ -59,7 +59,7 @@
<field name="end_time" required="1"/>
<field name="limit" required="1"/>
<field name="manufacture_ids" widget="many2many_tags"/>
- <field name="excl_pricelist_ids" widget="many2many_tags"/>
+ <field name="excl_pricelist_ids" widget="many2many_tags" domain="[('id', 'in', [4, 15037, 15038, 15039])]"/>
</group>
</group>
<notebook>