summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-07-02 11:48:35 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-07-02 11:48:35 +0700
commitdd93d36b4c7cec4e1681d69e296a7cff559386a0 (patch)
tree247cf5e739b60592d630b8d86ed6a2be0863dc85
parent9c17104f86f116782f0ed36f82d7c3de7130d363 (diff)
search invoice marketplace and add discount on order line purchase and add biaya lain lain on purchase
-rwxr-xr-xfixco_custom/__manifest__.py1
-rwxr-xr-xfixco_custom/models/__init__.py2
-rw-r--r--fixco_custom/models/purchase_order.py43
-rw-r--r--fixco_custom/models/purchase_order_line.py38
-rw-r--r--fixco_custom/views/purchase_order.xml22
-rwxr-xr-xfixco_custom/views/stock_picking.xml12
6 files changed, 118 insertions, 0 deletions
diff --git a/fixco_custom/__manifest__.py b/fixco_custom/__manifest__.py
index 0d8f259..53df90a 100755
--- a/fixco_custom/__manifest__.py
+++ b/fixco_custom/__manifest__.py
@@ -31,6 +31,7 @@
'views/sale_pricelist.xml',
'views/upload_ginee.xml',
'views/report_picking_list.xml',
+ 'views/purchase_order.xml',
],
'demo': [],
'css': [],
diff --git a/fixco_custom/models/__init__.py b/fixco_custom/models/__init__.py
index 4fd81d8..226e6b9 100755
--- a/fixco_custom/models/__init__.py
+++ b/fixco_custom/models/__init__.py
@@ -16,3 +16,5 @@ from . import print_picking_list
from . import stock_picking_print_picking_list
from . import uangmuka_penjualan
from . import upload_ginee
+from . import purchase_order_line
+from . import purchase_order
diff --git a/fixco_custom/models/purchase_order.py b/fixco_custom/models/purchase_order.py
new file mode 100644
index 0000000..a623ae4
--- /dev/null
+++ b/fixco_custom/models/purchase_order.py
@@ -0,0 +1,43 @@
+from odoo import fields, models, api, _
+from odoo.exceptions import AccessError, UserError, ValidationError
+from dateutil.relativedelta import relativedelta
+from datetime import datetime, timedelta
+import logging
+from pytz import timezone, utc
+import io
+import base64
+try:
+ from odoo.tools.misc import xlsxwriter
+except ImportError:
+ import xlsxwriter
+
+_logger = logging.getLogger(__name__)
+
+
+class PurchaseOrder(models.Model):
+ _inherit = 'purchase.order'
+
+ amount_discount = fields.Monetary(
+ string='Total Discount',
+ compute='_compute_amount_discount',
+ store=True
+ )
+
+ biaya_lain_lain = fields.Float(
+ 'Biaya Lain Lain',
+ default=0.0,
+ tracking=True
+ )
+
+ @api.depends('order_line.price_total', 'biaya_lain_lain')
+ def _amount_all(self):
+ super(PurchaseOrder, self)._amount_all()
+
+ for order in self:
+ amount_total = order.amount_untaxed + order.amount_tax - order.biaya_lain_lain
+ order.amount_total = order.currency_id.round(amount_total)
+
+ @api.depends('order_line.discount_amount')
+ def _compute_amount_discount(self):
+ for order in self:
+ order.amount_discount = sum(line.discount_amount for line in order.order_line) \ No newline at end of file
diff --git a/fixco_custom/models/purchase_order_line.py b/fixco_custom/models/purchase_order_line.py
new file mode 100644
index 0000000..8cac3d1
--- /dev/null
+++ b/fixco_custom/models/purchase_order_line.py
@@ -0,0 +1,38 @@
+from odoo import models, fields, api
+
+class PurchaseOrderLine(models.Model):
+ _inherit = 'purchase.order.line'
+
+ discount = fields.Float(
+ string='Discount (%)',
+ digits='Discount',
+ default=0.0
+ )
+ discount_amount = fields.Float(
+ string='Discount Amount',
+ compute='_compute_discount_amount'
+ )
+
+ @api.depends('price_unit', 'product_qty', 'discount')
+ def _compute_discount_amount(self):
+ for line in self:
+ discount = line.discount or 0.0
+ line.discount_amount = (line.price_unit * line.product_qty * discount) / 100.0
+
+ def _prepare_compute_all_values(self):
+ res = super(PurchaseOrderLine, self)._prepare_compute_all_values()
+ price_unit = res['price_unit'] * (1 - (self.discount or 0.0) / 100.0)
+ res.update({
+ 'price_unit': price_unit,
+ })
+ return res
+
+ @api.depends('product_qty', 'price_unit', 'taxes_id', 'discount')
+ def _compute_amount(self):
+ return super(PurchaseOrderLine, self)._compute_amount()
+
+ def write(self, values):
+ res = super().write(values)
+ if 'discount' in values:
+ self._compute_amount()
+ return res \ No newline at end of file
diff --git a/fixco_custom/views/purchase_order.xml b/fixco_custom/views/purchase_order.xml
new file mode 100644
index 0000000..1aa438c
--- /dev/null
+++ b/fixco_custom/views/purchase_order.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="purchase_order_form_view_inherit" model="ir.ui.view">
+ <field name="name">Purchase Order</field>
+ <field name="model">purchase.order</field>
+ <field name="inherit_id" ref="purchase.purchase_order_form"/>
+ <field name="arch" type="xml">
+ <field name="currency_id" position="after">
+ <field name="biaya_lain_lain"/>
+ </field>
+ <field name="amount_untaxed" position="after">
+ <field name="amount_discount" class="oe_currency_line"/>
+ </field>
+ <field name="price_unit" position="after">
+ <field name="discount"/>
+ <field name="discount_amount" optional="hide"/>
+ </field>
+ </field>
+ </record>
+ </data>
+</odoo> \ No newline at end of file
diff --git a/fixco_custom/views/stock_picking.xml b/fixco_custom/views/stock_picking.xml
index e8aee28..c2d899b 100755
--- a/fixco_custom/views/stock_picking.xml
+++ b/fixco_custom/views/stock_picking.xml
@@ -49,6 +49,18 @@
</field>
</record>
+ <record id="view_picking_internal_search_custom" model="ir.ui.view">
+ <field name="name">stock.picking.internal.search.custom</field>
+ <field name="model">stock.picking</field>
+ <field name="inherit_id" ref="stock.view_picking_internal_search"/>
+ <field name="arch" type="xml">
+ <field name="name" position="replace">
+ <field name="name" string="Transfer"
+ filter_domain="['|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('invoice_mp', 'ilike', self)]"/>
+ </field>
+ </field>
+ </record>
+
<record id="stock_picking_shipment_group_ir_actions_server" model="ir.actions.server">
<field name="name">Shipment Group</field>
<field name="model_id" ref="stock.model_stock_picking"/>